A pasted chat in OrangeCat's article brief returned "Invalid request": the
route capped the topic at 300 characters and answered with a bare phrase.
- fitPromptText: keeps a brief whole up to PROMPT_TEXT_MAX_CHARS (12k),
otherwise keeps start and end around a "characters left out" marker.
- explainInputIssues: turns zod-shaped issues into sentences that name the
field, its length, the limit and the fix; never a bare "Invalid request".
Claude-Session: https://claude.ai/code/session_019MDtmsN9mz8QfGDCrNhY9p
Co-authored-by: Claude <noreply@anthropic.com>
PRICE_LIST names each paid model's USD per 1M tokens and the page it was read
from (2026-11-15). summariseUsage tallies gain costUSD for the server's paid
answered calls and unpriced for those it cannot price, never counted as zero.
Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq
Co-authored-by: Claude <noreply@anthropic.com>
WalkOptions.feature / CompleteOptions.feature is written beside the app; the
summary groups each app's calls by it. Solon spent Groq's whole free day
before 09:10 UTC on 14 Nov with nobody using any app, and the log could say
which app but not what for. CompleteOptions.app is now typed as well.
Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq
Co-authored-by: Claude <noreply@anthropic.com>
Files from bitbaum/fleet `templates/package` that this repository does not have yet:
- `.github/workflows/release-notify-tagged.yml`
Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.
Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
1.27.0 wrote only where AI_USAGE_DIR was exported; apps whose launch script
predates it wrote nothing. usageDir() falls back to /opt/fleet/ai-usage when
it exists; AI_USAGE_DIR=off writes nowhere. Release 1.28.0.
Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq
Co-authored-by: Claude <noreply@anthropic.com>
About $567 went to Google on 10-11 Nov 2026 and nobody could say which app
spent it, on what, or when: each app counted its own calls in its own
process, or not at all.
The chain walk now reports every link it touches (app, vendor, model;
served, failed with status and kind, or refused with the spend rule; tokens
and time when known; never content). With AI_USAGE_DIR set the event is
appended to <dir>/<UTC day>.jsonl through process.getBuiltinModule, so the
package root stays importable in a browser bundle. readUsageDay and
summariseUsage give the per-vendor and per-app picture.
test/usage-log.test.js: the three outcomes from a real walk, the file sink,
null for could-not-look, torn lines, a throwing sink, the summary.
Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq
Co-authored-by: Claude <noreply@anthropic.com>
freeChain() put Google's Gemini API second, on a fleet-wide GEMINI_API_KEY
described as a free per-project tier. The project had billing; every app on
the box fell through to it whenever Groq's pool was spent, about $567 on
10-11 Nov 2026. Google is not in the chain any more; it bills.
- freeChain(): Groq, then OpenRouter :free. visionProviders() loses the
Google seat; the free vision left is OpenRouter's :free Gemma id.
- spend: a provider is paid when marked so or when it is Google's Gemini
API, xAI, Anthropic or OpenAI (by host or key name, also prefixed). A
reader's own key is never paid by us.
- AI_PAID_DISABLED is on when unset; AI_PAID_OK / {PREFIX}_AI_PAID_OK opts an
app in. usableChain() drops paid providers unless allowed.
- Daily caps (UTC): fleet 90 calls / 120,000 in / 60,000 out; per-app rows
(about 60% of the fleet named), aliases, unknown apps 1 / 800 / 400, no-AI
apps 0; xAI 0 until opted in, then 2 / 2,000 / 1,000; a 5,000-call free
loop guard. Env overrides per prefix. A reached cap throws SpendLimitError
("limit reached") and never walks onto another paid vendor.
- images: every paid transport, the gemini one included, is gated the same
way; ownKey for a person's own key.
- README, docs/providers.md and CHANGELOG say plainly that Google bills.
Tests: test/spend.test.js (kill switch on/off/missing, no xAI or Google
link without opt-in, caps and headroom, aliases, unknown app, env
overrides, cap hit without walking to another paid vendor, fleet cap,
token cap, BYOK past spent caps, free loop guard); chain, images and vision
tests updated. 425 pass.
* feat(web): keyless fallback backends for when every configured one is down
A self-hosted SearXNG is refused by upstream engines from time to time;
without a paid key the chain then has nothing left, and every app on the
box says it could not look (seen on Substrata, 2026-11-11 to -12).
- gdeltProvider: GDELT DOC 2.0 news search, keyless. Paced to one request
every five seconds per process (GDELT's own ask); a call that cannot wait
its turn fails as rate_limited without being sent. Its plain-text refusals
are typed failures, never empty results.
- wikipediaProvider: one Wikipedia edition's search, keyless, no invented
date (the API's timestamp is the last edit).
- keylessProviders() and withKeylessFallback(env): one call to opt in.
defaultProviders is unchanged.
- A provider may declare coverage: "partial"; a partial index answering
empty never turns a search into "nothing".
Version 1.25.0.
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
* fix(web): keyless providers, from review
- GDELT query: OR and the parentheses grouping it are kept; a short
acronym ("AI", "EU") is joined to its neighbour as a phrase instead of
dropped; lower-case function words go; CJK words are quoted; unbalanced
quotes are removed.
- GDELT: a non-object body or row is bad_response, not "unreachable"; a
non-finite or negative interval falls back to 5 s instead of corrupting
the shared pacing; a call left with under a second is not sent.
- Wikipedia: a site naming an edition searches that edition; edition codes
such as "simple" and "zh-yue" are honoured and an unknown hint falls back
to the configured edition; a MediaWiki error in a 200 body is a failure,
never an empty search.
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
---------
Co-authored-by: Claude <noreply@anthropic.com>
The fleet's products already serve MCP (OrangeCat's and Loki's /api/mcp),
and the next thing every one of them wants is to call one: a bot on
OrangeCat asking Loki as the person, a product reaching a vendor's server
with the person's token. Each would write the same forty lines of JSON-RPC
over Streamable HTTP, and each would get one of the two response shapes
wrong (a server may answer a POST with JSON or with an SSE stream, per
request). So the client lives here, once.
@bitbaum/ai-kit/mcp: McpClient (initialize once with the session id carried,
tools/list, tools/call, both response shapes read the same way, a tool
error as data and a JSON-RPC error as McpError), toolDefinitionsFrom (the
server's tools in the shape complete() takes). No OAuth flow, no stdio, no
resources or prompts until a caller needs them. Tests against a fake server
in both answer shapes, plus the failed-handshake path.
Claude-Session: https://claude.ai/code/session_019MDtmrXvMqAqZtbpQ4x3et
Co-authored-by: Claude <noreply@anthropic.com>
Files from bitbaum/fleet `templates/package` that this repository does not have yet:
- `.github/workflows/release-notify.yml`
Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.
Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
Files from bitbaum/fleet `templates/package` that this repository does not have yet:
- `AGENTS.md`
- `CLAUDE.md`
Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.
Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
Files from bitbaum/fleet `templates/package` that this repository does not have yet:
- `.github/workflows/git-release.yml`
- `.github/workflows/release.yml`
Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.
Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
auto-merge.yml has always re-armed publish.yml after a merge
(rearm_workflows: "ci.yml publish.yml"), but publish.yml only listened for
tag pushes, so every one of those dispatches was dropped and a merged
version sat unpublished until someone with tag rights pushed a tag. 1.21.0
sat merged for three days that way.
- publish.yml accepts workflow_dispatch, and refuses one from anything but
main.
- The tag-matches-version check runs only for a tag push; a dispatch has
no tag to match.
- Permissions are unchanged (contents: read, id-token: write). A dispatched
release is traced to its commit by npm provenance.
- The existing registry check makes every other merge a green no-op.
README: releasing is merging — raise the version in the PR.
Claude-Session: https://claude.ai/code/session_015QRNwA4BorkdoSCd8j5Xvu
Co-authored-by: Claude <noreply@anthropic.com>
* feat(usage): what the budget numbers mean, defined once (1.21.0)
Loki's Settings → AI and OrangeCat's /settings/usage each grew the half a
meter leaves out — does today's pace last, the week, when it refills, what
the assistant still reads, levers with their consequence — separately, in
October 2026, with the same rules and slightly different sentences. The
product-neutral half moves here so the next app starts with it:
- paceForecast / paceLine: lasts the day, or runs out at "12:00 UTC"; silent
before there is a rate (PACE_MIN_USED, PACE_MIN_DAY_FRACTION, or minUsed).
- weekSummary: total, active days, days the cap was reached; null for an
empty or unreadable week, never "0".
- refillsIn: "in 4 hours", "in under a minute", "now", or null — never a
guessed time.
- admissionsLeft: answers a remainder buys, counted the way a gate admits
(one at the estimate, then per measured answer), not a bare division.
- historyWindowLine: what the assistant still reads of a conversation.
- countOf, clockAt, nextUtcMidnight; UsageAction / UsageExplanation types;
UTC_RESET_EXPLANATION.
Numbers go through the caller's formatter so a page never groups digits two
ways. Plan names, prices and which levers are open stay in each app.
Additive: minor release.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QRNwA4BorkdoSCd8j5Xvu
* fix(usage): the reset sentence claims only what the counter does
UTC_RESET_EXPLANATION gave a reason — "that is when the model providers'
free allowances refill" — which is false of Groq, whose limits refill on a
rolling clock. OrangeCat's usage page had shipped the same reason and took
it back in bitbaum/orangecat#1318; a shared sentence that is wrong is wrong
in every app at once, so it now states only that the count is kept per UTC
day. weekSummary and the README also say the other #1318 lesson: seven rows
ending today are "last 7 days", not "this week".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QRNwA4BorkdoSCd8j5Xvu
* refactor(usage): utcResetExplanation(unit) instead of a fixed sentence
OrangeCat counts messages and Loki a share; "Unused allowance does not roll
over" was right for neither. The reset is now utcResetExplanation("messages")
→ "Unused messages don't roll over.", defaulting to "allowance". Still claims
only what the counter does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QRNwA4BorkdoSCd8j5Xvu
* test(usage): countOf's formatter test no longer depends on ICU data
CI (Node 24) groups de-CH with ' and this sandbox (Node 22) with ’, so the
test asserted a runtime's locale data rather than that countOf uses the
formatter it is given. It now passes a formatter with no locale behind it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QRNwA4BorkdoSCd8j5Xvu
---------
Co-authored-by: Claude <noreply@anthropic.com>
Probed 2026-10-02: on gemini-flash-latest the default spends ~500 hidden
reasoning tokens out of max_tokens (Substrata answers cut mid-word at ~550
visible tokens of 2400) and 4.1 s vs 2.5 s per answer turn. reasoning_effort
low removes them. Not sent to flash-lite (low turns its thinking ON) or
gemma (refused).
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Heidi defined its Groq Whisper chain and its silence denylist in its own
lib; Loki has copies; Substrata had none, so its microphone had no server
leg. ai-kit owns the chains: this is the dictation one, beside freeChain,
with the guard against Whisper's silence artefacts ('Untertitelung des
ZDF', 'Amen.') typing words nobody said.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Gemini's OpenAI-compatible stream sends parallel tool calls with no
'index' and their own ids. Keyed on index alone they were glued into one
call whose arguments ({"query":"Russia"}{"kind":"country"}) parsed to
nothing, so every call ran with empty arguments — seen live in
Substrata's Ask. A new id on a slot that already holds a named call now
starts a new call, and glued argument objects are split back as a last
line of defence. Two tests, both failing on the old assembly.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
heidi's Swiss German pages passed their locale, gsw, as the language hint.
Groq answered 400 'unsupported language: gsw' on every link, and the
microphone said dictation did not work in this browser. Romansh (rm) failed
the same way. whisperLanguage() maps a tag or locale to a hint Whisper
accepts: gsw -> de, de-CH -> de, unknown -> none (auto-detect).
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
byokChain links share their provider id with the deployment's link to the same
vendor (groq is groq), and every shared ledger in this package keys on it. So:
- Provider.byok marks an own-key link (set by byokChain).
- dayCapacityTokens never counts it, even with a *_DAILY_TOKENS override.
- createLinkCooldown never cools a link because of it — one reader's
exhausted personal quota used to cool groq/<model> for everybody.
- tryChain / walkChain / completeStream record no health for it: one reader's
bad key says nothing about whether the site's AI works.
- Quota readings about it carry byok: true, so an app's store can skip them.
- dailyTokens is 0, not Infinity: a caller summing it by hand adds nothing.
- New exports: isOwnKeyLink(link), healthFor(chain, health).
No live app was exposed (checked loki, substrata, heidi, orangecat, evig,
petvity: none fed an own-key chain into capacity); this closes the trap for
the next one. Each guard mutation-checked.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The moment a reader pastes a key, a settings screen needs two answers: does
it work, and which models can it reach — so it can preselect the best one
instead of showing a text box and failing in the chat later. OrangeCat
answered the first and threw the second away; Loki had neither.
probeByokKey checks a key the way each vendor checks keys, verified against
the live endpoints on 2026-09-25:
- OpenRouter's /models is a public catalogue that answers 200 to a FAKE key,
so its key is checked at /key.
- Anthropic's model list wants x-api-key plus a version header.
- Google and xAI reject a bad key with 400, not 401 — any non-2xx fails,
in the vendor's own words, with the key masked if the vendor echoes it.
- An unreachable vendor is "couldn't check", never "your key is wrong".
The suggestion names no model (the newest ids that day were
claude-opus-5.5, gpt-6-luna-pro, grok-4.7 — none of which this package had
seen). It is the newest model in the strongest tier the key can use: tier
from the name, age from the vendor's dates or, where there are none
(Google), from the version in the name, with a vendor's -latest alias as
newest; speed variants never on top; a router's frontier-lab namespaces
first. Run live against real Groq, Gemini and OpenRouter keys it suggests
gpt-oss-120b, gemini-pro-latest and anthropic/claude-opus-5.5.
readCatalog is the one GET behind fetchCatalog, keeping the status and the
vendor's message that fetchCatalog deliberately collapses; ModelRecord gains
`created`. Additive: no existing export changes behaviour.
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`transcribe({ words: true })` asks for `verbose_json` with word granularity
and returns normalised `words: [{ word, start, end }]`.
Why: Heidi measures HOW somebody spoke — speech rate, pauses between words,
length of run — and the text alone says which words, never when. The call
belongs here, not in Heidi: ai-kit owns every vendor request, and a second
hand-rolled Whisper call is the drift transcribe() was written to end.
The contract is absent-is-not-empty. `words` is omitted when timings were not
asked for or the vendor ignored the granularity ("not measured"), and is `[]`
only for a recording that was measured and contained nothing. A caller reading
absence as zero words would report a fluent speaker as silent. Missing timings
never fail the link — walking the chain would re-upload the audio to every
vendor for a nice-to-have. Impossible timings (end before start, NaN, empty
word) are dropped, not trusted.
Opt-in because dictation, the common caller, needs only the text and the
verbose body is several times larger. Proven by mutation: removing the
granularity request fails the request-shape test.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>