83 Commits
Author SHA1 Message Date
CatoandClaude 6d4d0a7eba feat(allowance): monthly CHF allowance, own-key vault, UsageMeter (1.32.0) (#120)
Co-authored-by: Claude <noreply@anthropic.com>
2026-12-03 01:53:43 +01:00
bitbaum-fleet 28e9708a69 release v1.31.0 2026-11-15 18:51:45 +00:00
CatoandClaude 43b629d307 feat(prices): what the paid calls cost, from the vendors' own pages (1.30.0) (#118)
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>
2026-11-15 10:53:47 +01:00
dependabot[bot] 9bf4faafee chore(deps-dev): bump typescript-eslint (#117)
Bumps the minor-and-patch group with 1 update: [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `typescript-eslint` from 8.72.1 to 8.72.2
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.2/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: typescript-eslint
  dependency-version: 8.72.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 12:47:03 +01:00
CatoandClaude 85984ad223 feat(usage-log): a call says what it was for (1.29.0) (#116)
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>
2026-11-14 10:24:43 +01:00
CatoandClaude 542103a15b feat(usage-log): write to the box's log with no per-app setup (#114)
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>
2026-11-13 23:37:31 +01:00
CatoandClaude 30003a6999 feat(usage-log): one line per model call for every app on a box; a reader and a summary (1.27.0) (#113)
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>
2026-11-13 10:05:53 +01:00
Cato 3901ff0342 feat(spend): Google out of the free chain; paid AI off unless a feature opts in, and capped (1.26.0) (#112)
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.
2026-11-12 22:27:29 +01:00
CatoandClaude 5c9102e286 feat(web): keyless fallback backends for when every configured one is down (1.25.0) (#111)
* 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>
2026-11-12 08:00:02 +01:00
dependabot[bot] 9a65a34c10 chore(deps): bump the minor-and-patch group with 4 updates (#110)
Bumps the minor-and-patch group with 4 updates: [linkedom](https://github.com/WebReflection/linkedom), [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint) and [globals](https://github.com/sindresorhus/globals).


Updates `linkedom` from 0.18.14 to 0.18.15
- [Commits](https://github.com/WebReflection/linkedom/compare/v0.18.14...v0.18.15)

Updates `@types/node` from 26.6.5 to 26.6.6
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.13.0 to 10.14.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.13.0...v10.14.0)

Updates `globals` from 17.13.0 to 17.14.0
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v17.13.0...v17.14.0)

---
updated-dependencies:
- dependency-name: linkedom
  dependency-version: 0.18.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.6.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: globals
  dependency-version: 17.14.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-07 16:07:51 +01:00
bitbaum-fleet 8dfe7f343a release v1.24.0 2026-11-02 19:22:53 +00:00
Cato aec87370fd feat(images): one image-generation transport (images, openrouter-chat, gemini) (#108) 2026-11-02 20:19:07 +01:00
bitbaum-fleet 6589926cfe release v1.23.0 2026-11-02 10:31:16 +00:00
CatoandClaude 80da12607b feat(mcp): an MCP client, the way a product's bots reach a connector (1.22.0) (#106)
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>
2026-11-01 06:43:01 +01:00
dependabot[bot] bff0fa4ddb chore(deps-dev): bump typescript-eslint (#105)
Bumps the minor-and-patch group with 1 update: [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `typescript-eslint` from 8.72.0 to 8.72.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.1/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: typescript-eslint
  dependency-version: 8.72.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-31 12:47:16 +01:00
bitbaum-fleet b1ea5ad12d release v1.21.5 2026-10-28 23:44:18 +00:00
Cato 224cb56bf2 fix(sse): assemble multiline events and handle CR framing (v1.21.4) (#93) 2026-10-25 09:18:15 +01:00
dependabot[bot] a3e27e8a13 chore(deps-dev): bump the minor-and-patch group with 2 updates (#92)
Bumps the minor-and-patch group with 2 updates: [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `eslint` from 10.12.0 to 10.13.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.12.0...v10.13.0)

Updates `typescript-eslint` from 8.71.2 to 8.72.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 10.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.72.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-24 16:53:50 +02:00
Cato 1a48792ec0 Prioritize article content before the model character limit (#91) 2026-10-24 07:30:36 +02:00
Cato 3e69a8c1ad Preserve article citation links in model-visible text (#90) 2026-10-24 07:12:41 +02:00
Cato 65e3ce962c Fix public IPv4 range classification and mapped-address guards (#89) 2026-10-24 07:08:01 +02:00
dependabot[bot] 621489fd22 chore(deps-dev): bump the minor-and-patch group with 3 updates (#87)
Bumps the minor-and-patch group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [prettier](https://github.com/prettier/prettier) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.6.4 to 26.6.5
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `prettier` from 3.9.9 to 3.9.10
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.9...3.9.10)

Updates `typescript-eslint` from 8.71.1 to 8.71.2
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.2/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.10
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.71.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-17 15:11:10 +02:00
CatoandClaude Opus 5.5 f7c2d89fb8 feat(usage): what the budget numbers mean, defined once (1.21.0) (#85)
* 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>
2026-10-12 06:34:09 -07:00
dependabot[bot] 5d6e68f251 chore(deps-dev): bump the minor-and-patch group with 4 updates (#84)
Bumps the minor-and-patch group with 4 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint), [globals](https://github.com/sindresorhus/globals) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.6.3 to 26.6.4
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.11.0 to 10.12.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.11.0...v10.12.0)

Updates `globals` from 17.12.0 to 17.13.0
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v17.12.0...v17.13.0)

Updates `typescript-eslint` from 8.71.0 to 8.71.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.1/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.12.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: globals
  dependency-version: 17.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.71.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-10 04:16:05 -07:00
dependabot[bot] bd49d82250 chore(deps): bump the minor-and-patch group across 1 directory with 5 updates (#83)
Bumps the minor-and-patch group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [ai-forms](https://github.com/bitbaum/ai-forms) | `0.1.2` | `0.1.3` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.6.1` | `26.6.3` |
| [eslint](https://github.com/eslint/eslint) | `10.10.0` | `10.11.0` |
| [prettier](https://github.com/prettier/prettier) | `3.9.7` | `3.9.9` |
| [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.70.0` | `8.71.0` |



Updates `ai-forms` from 0.1.2 to 0.1.3
- [Commits](https://github.com/bitbaum/ai-forms/compare/v0.1.2...v0.1.3)

Updates `@types/node` from 26.6.1 to 26.6.3
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.10.0 to 10.11.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.10.0...v10.11.0)

Updates `prettier` from 3.9.7 to 3.9.9
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.7...3.9.9)

Updates `typescript-eslint` from 8.70.0 to 8.71.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: ai-forms
  dependency-version: 0.1.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.6.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.11.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.9
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.71.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-08 10:29:48 -07:00
CatoandClaude Opus 5.5 9510350083 fix(reasoning): light reasoning for gemini-flash-latest only (1.20.1) (#82)
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>
2026-10-02 10:05:05 -07:00
CatoandClaude Opus 5.5 ae0a311bc8 feat(speech): speechChain, speechConfigured and looksLikeSilence, defined once (1.20.0) (#81)
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>
2026-10-02 04:55:54 -07:00
CatoandClaude Opus 5.5 6c8ae77f0e fix(stream): parallel tool calls without an index stay separate calls (1.19.1) (#80)
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>
2026-10-02 02:58:50 -07:00
CatoandClaude Opus 5.5 a4aab78b65 fix(transcribe): a language Whisper has no code for never fails the take (1.19.0) (#79)
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>
2026-10-01 07:50:23 -07:00
CatoandClaude Opus 5.5 102ab386e7 fix(byok): a reader's own key never touches the deployment's bookkeeping (1.18.0) (#77)
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>
2026-09-26 03:31:03 -07:00
CatoandClaude Opus 5.5 13c8e8c0cb feat(byok): "does this key work, and what can it use?" — probeByokKey (1.17.0) (#76)
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>
2026-09-25 07:32:17 -07:00
CatoandClaude Opus 5.5 66e20a5f7e feat(transcribe): word timings, opt-in (1.16.0) (#75)
`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>
2026-09-24 23:51:55 -07:00
CatoandClaude Opus 5.5 4bab700495 feat(stream): firstTokenMs — walk on from a link that streams nothing (1.15.0) (#73)
timeoutMs bounds the whole stream, so it must allow for a long answer, and a
link that thinks silently or hangs was waited on for all of it. Measured on
substrata's Ask 2026-09-25: 38 s to first text behind OpenRouter links that
never produced a token. firstTokenMs aborts only the opening; once a token is
out, timeoutMs alone bounds the stream.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:59:25 -07:00
CatoandClaude Opus 5.5 610fa7762f fix(chain): drop rotted groq qwen3.6-27b; cool a 404 link for an hour (1.14.1) (#72)
qwen/qwen3.6-27b left Groq's catalogue (listed 2026-09-25: gpt-oss-120b,
gpt-oss-20b, qwen3.8-27b) and 404'd on every Ask turn that reached it in
substrata's timing log. A 404 now also cools its link for an hour, so the next
rotted id costs one round trip per process-hour rather than one per turn.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:46:16 -07:00
CatoandClaude Opus 5.5 37107965ca feat(latency): per-model daily refusals, rolling-window cooldowns, light reasoning (1.14.0) (#71)
Measured on the box 2026-09-25 while substrata's Ask took 9-33s to its first
word:

- Groq meters its day PER MODEL: gpt-oss-20b refused "for model
  `openai/gpt-oss-20b` ... TPD" while gpt-oss-120b served on the same key.
  walkChain now condemns the vendor only for a daily refusal naming no model.
- Groq's "per day" is a rolling window: 20b refused at 00:14 and served at
  00:17. The cooldown now honours the wait the refusal names, daily ones too;
  UTC midnight is only the fallback. Before, one refusal kept the fastest link
  out of a process for most of a day.
- reasoning: "light" sends reasoning_effort=low to Groq gpt-oss (first content
  649ms -> 205ms on a 3k-token prompt). Only probed settings are listed.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:24:28 -07:00
CatoandClaude Opus 5.5 cdc15cae72 feat(budget): priority classes over one daily budget — background capped and kept off the reader reserve (#70)
classBudget + BACKGROUND_POLICY (max 25% of the day, never below a 50% floor)
+ estimateTokens. 1.13.0.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 14:20:53 -07:00
CatoandClaude Opus 5.5 bc0b09f763 feat(byok): a reader's own key, sealed at rest, and a cooldown for links that refused (#69)
- ai-kit/byok: closed OpenAI-shaped vendor list (OpenRouter, OpenAI, Anthropic,
  Gemini, Groq, Mistral, DeepSeek, xAI, Together, Cerebras), isByokConfig,
  byokChain -> a one-link chain with a call-scoped env
- ai-kit/seal: AES-256-GCM sealSecret/openSecret (OrangeCat's scheme) for keys at rest
- createLinkCooldown: skip a link until its 429 resets (daily -> UTC midnight)
- 1.12.0

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 12:38:10 -07:00
dependabot[bot] e3e3665cfd chore(deps-dev): bump the minor-and-patch group with 2 updates (#67)
Bumps the minor-and-patch group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [prettier](https://github.com/prettier/prettier).


Updates `@types/node` from 26.5.0 to 26.6.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `prettier` from 3.9.6 to 3.9.7
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.6...3.9.7)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.7
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-23 13:39:02 -07:00
CatoandClaude ae260fc51a feat(vision): a picture goes only to a model that can read one (#68)
`complete()` has forwarded `image_url` parts since the first release. What it
never did was CHOOSE a link for them — and `freeChain()` is ordered for text,
so a screenshot meets four Groq links that cannot read it before reaching one
that can. A blind model handed a picture does not fail usefully: it answers the
words around the image, fluently, about nothing.

Three products paid for that absence separately, in three repositories:

  heidi     had the users and REFUSED them — /api/chat returns 400 "Reading a
            picture needs your own model", and byok.ts states as fact that "the
            free chain has no model that can read a picture". Never true of
            free models; true of a chain with no vision routing.
  loki      built a SECOND chain beside this one (config/vision-models.ts) and
            it drifted immediately — never learned about Google, still carries
            a dead Groq seat.
  orangecat built the decision rule and had nobody to call it with. Its own
            capability-gate reason string reads 'no caller sends images'.

The rule, the verified model list and the users existed; none could reach the
other two.

What lands:

- `Provider.visionModels` — which ids accept an image, populated from evidence
  with the provenance stated beside each entry. Groq's empty list is a claim
  (live-probed 2026-08-13: no vision model on this account); OpenRouter's
  `google/gemma-4-26b-a4b-it:free` is the strong kind (probed live, answered
  "Red" correctly); Google's three are declared-not-probed and say so.
- `src/vision.ts` — three verdicts, never two. A model in `models` but not in
  `visionModels` is "no"; a model in NEITHER (env override, private
  deployment, an id a user brought) is "unknown", and unknown is TRIED. Reading
  silence as a denial is the inversion OrangeCat's ADR-0008 named, where the
  stronger the model a user brings, the less the agent can do.
- `complete()` and `completeStream()` route on it through one shared helper, so
  the two paths cannot disagree about which model can see — the same reason
  they already share `walkChain`.
- `NoVisionLinkError`, thrown BEFORE any request when the whole chain is blind,
  naming what it skipped. "No model here can see" and "every vendor failed"
  need different answers and are indistinguishable once both arrive as
  ChainExhaustedError; the first is knowable without spending a token.
- `scripts/probe-vision.mjs` (`pnpm run check:vision`) — a claim in a list is
  worth what the last check was. Sends a real image, asks one word, and treats
  HTTP 200 with EMPTY content as a failure: that is the shape loki found in
  nemotron-nano-12b-v2-vl, and it reads as a successful analysis of a picture
  nobody looked at.

`walkChain`'s chain resolution is extracted as `walkLinks` so the filter and
the walk resolve the same defaults once. Named `walkLinks`, not `resolveChain`
— that name is taken by resolve.ts, which answers a different question.

Inert for text: a plain turn returns the caller's own options object untouched
and costs one typeof per message. Pinned by a test, because breaking that would
break every text caller in the fleet.

301 tests pass, both directions pinned: a declared-blind model must never be
sent a picture, and an unclassified one must never be refused one.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 05:39:49 -07:00
CatoandClaude Opus 5 a0f04ea08a chore(release): 1.10.0 — transcribe() (#65)
A minor, because the change is purely additive: `transcribe()` is a new
export and nothing existing moved. `complete()` and `completeStream()` are
byte-identical in behaviour — `walkChain` takes a named subset of what it
already read, which `CompleteOptions` satisfies structurally.

Bumped on a branch rather than by `npm version` on main, so the version
reaches main the same way every other change does: through a PR and CI. The
tag is pushed separately, which is what the publish workflow watches.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 08:28:26 -07:00
CatoandClaude Opus 5 5119b59eb5 feat(stream): the chain can stream, so apps stop going around it (#62)
This package could not stream. `complete()` is request/response only, so every
app that wanted tokens to appear as they arrived used ai-kit to pick the model,
classify the 429 and track health — and then threw all of it away for the one
call that matters. Measured across the fleet on 2026-09-15: six hand-rolled
provider clients, four SSE readers, four emitters with divergent headers, under
~20,800 lines of chat UI in nine apps.

The duplication was real and it was in the wrong place. The apps were not
reinventing streaming because streaming is hard; they were reinventing it
because the package that owned the chain had no door for it.

ONE WALK, NOT TWO

`complete()` and `completeStream()` now share `walkChain`, extracted from
complete() unchanged. They must agree about what a dead vendor is, or the fleet
gets two answers to "is this provider out of budget" and the streaming path —
the one every chat surface uses — is the one that gets it wrong. complete()'s
existing suite is what proves the extraction was faithful; all 278 tests pass.

WHERE FALLBACK STOPS, AND WHY

A non-streaming walk can try every link because nothing has been shown yet. A
streaming walk cannot: once the first token is out, falling back would replay
the answer from the beginning into somebody already reading it. So the boundary
is explicit. Fails before the first delta -> LinkFailure, the walk continues.
Fails after -> StreamInterrupted, carrying the partial text, no silent recovery,
because there is no honest one.

That is also why a link is "served" only once a first token is really out. A 200
that then says nothing demotes, which is the same judgement complete() already
makes about an empty completion.

THE BUG THIS ENDS

ai-kit/sse carries both ends of the wire, lifted from loki, which had them
right. The reader KEEPS THE REMAINDER between chunks. A ReadableStream chunk is
a TCP-sized slice ending wherever the network put the boundary — routinely
mid-frame. Two apps split each chunk on newlines and dropped whatever straddled
it: a word vanishes from a long answer under load, nobody reports it, nobody can
reproduce it, and every short test passes.

12 new tests, choosing their own chunk boundaries because the boundaries ARE the
bug — including a frame cut mid-JSON and a chunk cut inside a two-byte "ü".
Proven by mutation: reintroducing the shipped `split` with no remainder turns
the suite red.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 02:31:37 -07:00
CatoandClaude Opus 5 982b26f909 feat(chain): a third vendor that is actually free — Gemini (#61)
The free chain had two vendors and both are shared. Groq's daily TOKEN pool is
org-wide and OpenRouter's 50 requests a day are account-wide, so on a box where
several apps hold the same key they share the exhaustion too. A Google project
is per-app, which is the property being bought here — not the model.

Nothing below rests on an inference. Verified with a real key 2026-09-15:

  GET  /v1beta/openai/models          -> 200, 56 models
  POST /v1beta/openai/chat/completions
       models/gemini-flash-latest       -> NATIVE tool_call {"city":"Zurich"}
       models/gemini-flash-lite-latest  -> NATIVE tool_call
       models/gemma-4-31b-it            -> NATIVE tool_call
       plain completion                 -> non-empty, finish=stop

THE 404 WAS AUTH, NOT ABSENCE. A consumer wrote this vendor off on the reasoning
that "the compat layer likely serves /chat/completions without a catalogue, so
its ids could never be rot-checked". That came from an UNKEYED 404 on
/v1beta/openai/models; with a key the same path answers 200. An unkeyed probe
cannot separate "absent" from "hidden behind auth" in either direction — the
same blind spot that let a paid vendor in elsewhere on a 403.

THE `models/` PREFIX IS LOAD-BEARING. The catalogue lists all 56 ids prefixed,
with no bare form anywhere, while /chat/completions accepts both (checked across
max_tokens 64/256/1024 — identical answers). A bare id therefore serves
perfectly AND is reported missing by checkCatalog on every run: a permanent
false rot alarm about a working model, which is worse than no alarm because it
teaches the reader to ignore the one that matters. Pinned by a test.

ALIASES, NOT VERSIONS. `-latest` is repointed by Google as the model behind it
retires — the property that makes `openrouter/free` the most durable entry in
the list. Not theoretical: `gemini-2.5-flash`, the id reached for from memory
while writing this, is already refused for new accounts with "no longer
available to new users, please update your code to use models/gemini-3.6-flash".
`gemma-4-31b-it` sits last and earns its place differently: Google's pricing
gives it a free column and no paid one, so it is the single id here that cannot
be quietly reclassified as billable.

ORDERING IS CAPACITY, NOT PREFERENCE. Google sits before OpenRouter for the same
reason Groq does: OpenRouter's unpaid tier is the scarcest pool in the chain, so
it is drained last. Now pinned by a test, since it was previously only a comment.

`dailyTokens: 50_000` is a deliberate under-estimate, not a figure. Google
publishes no fixed free-tier table — limits are per project, shown in AI Studio
— and no rate-limit headers come back on a completion either. Per this field's
contract, estimating high is what produces the wall the rationing exists to
prevent.

Also fixes a test that only worked while the chain had exactly two vendors: it
hard-coded two key names and compared against the sum over EVERY provider. It
now derives keys from the chain, and gains the assertion that only became
possible with a third vendor — that a keyed SUBSET contributes exactly its own
capacity.

The free-tier trade, for consumers to weigh: Google's free tier states content
is used to improve its products; the paid tier states the opposite. This is the
second-to-last link, reached only when the pools above it are spent.

266 tests pass, verify clean.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 20:42:44 -07:00
CatoandClaude Opus 5 107c605e3f fix(grounding): a citation is its ID, not its bracket shape (#59)
The unknown-citation rule is described in this file as catching "the strongest
possible signal of fabrication — it invents its own proof". It matched
/\[[FD]\d+\]/ — ASCII brackets only — and models do not reliably write those.

Observed 2026-09-13, two models on Groq, both unprompted, from a prompt whose
every example used [F1]:

  openai/gpt-oss-120b   The most recent feedback was on project Heidi【F3】.
  groq/compound-mini    ...concerned project **Heidi**【F3】.

An ASCII-only match does not flag those as bad citations. It does not SEE them.
So `【F9】` on a turn holding three records sails straight past the rule, while
`[F9]` is caught — a hole opened by a character variant, in the one check whose
whole job is invented proof.

Nothing else covers it. A false citation hung on an otherwise attested claim
trips neither the proper-noun rule nor the number rule: every name and number in
the sentence really is in the records. Only the proof is invented, and that is
exactly the shape a reader is least able to check.

Brackets are normalised before matching — fullwidth 【】, lenticular 〔〕 and
fullwidth square []. Every substitution is one character for one character, so
offsets into the normalised copy still address the original, and the violation
reports the citation VERBATIM. Telling an author their `[F9]` is wrong when they
wrote `【F9】` sends them looking for a string that is not in their answer.

Proved by mutation: dropping the normalisation fails the new fullwidth test and
nothing else, which is the point — the rest of the suite could not see this.

263 tests pass, verify green.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 10:28:32 -07:00
CatoandClaude Opus 5 d37b905eb7 feat(chain): two more Groq links, because the meter is per model (#58)
#57 established that Groq rations requests and TPM PER MODEL. This is the
consequence: a second, third and fourth id at the same vendor are real
fallbacks, not the illusory same-pool step-down the header warns about.

The same key already reaches two more general-purpose chat models. Probed live
2026-09-13 with a real tool call, using the prompt the loop actually sends —
protocol each answered on, and the window each reported back within the same
minute:

  openai/gpt-oss-120b   native   7,551 / 8,000 tokens this minute
  openai/gpt-oss-20b    native
  qwen/qwen3.8-27b      text     7,360 / 8,000
  qwen/qwen3.6-27b      text     7,362 / 8,000

Three distinct counters inside one minute on one key. That is the argument.

THE QWEN PAIR ANSWER ON TEXT ONLY

No native `tool_calls` — exactly the case a native-only client loses in silence,
and exactly why complete() parses both protocols. Both returned correct
arguments and both carry 131k context, so they sit after the native pair for
parse reliability, not for capability.

They sit BEFORE OpenRouter on purpose. OpenRouter's unpaid tier is 50 REQUESTS a
day for the whole account, so every Groq pool worth draining should be drained
before one of those 50 is spent.

dailyTokens IS NOT RAISED

Four links buy four minute windows and four request counters. They do not buy
one extra daily token, because TPD is org-wide. Multiplying the figure by the
model count would be the exact failure the field's contract warns about —
fair-share rationing capacity that does not exist, with the wall arriving later
in the day and harder to diagnose.

Measured, not assumed: what motivated this was a real outage. One app spent an
afternoon returning 503s to its operator with two Groq links configured, both
request-limited, while two more usable models sat behind the same key.

261 tests pass, verify green.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 09:05:58 -07:00
CatoandClaude Opus 5 b7f741048b feat(meter): read the limit that only the refusal admits to (#56)
Headers do not describe every limit a vendor enforces.

Groq publishes its per-minute token window and its per-day REQUEST count as
headers, and meters a third limit — tokens per DAY — that appears in no header
at all. It is stated once, in prose, inside the body of the 429 enforcing it:

  on tokens per day (TPD): Limit 200000, Used 199773, Requested 571.

Observed on production 2026-09-13, and the surrounding numbers are the point:
every header on that same response looked healthy — 2,672 of 8,000 tokens left
this minute, 999 of 1,000 requests left today — while the account was locked out
of the model for the rest of the day. A dashboard fed only by headers reported a
working provider throughout an outage.

That is exactly the failure the top of this file exists to prevent ("reports a
full tank during an outage"), arriving through a door it left open. The module
refused to poll a usage endpoint because the endpoint lies; it then trusted
headers to be complete, and they are not.

readingFromRefusalBody() takes the body and returns the counter the vendor named
there — scope, window, limit, and remaining computed from the stated Used.

STILL NEVER INVENTS ONE

Returns null unless the body states numbers. OpenRouter's daily refusal names no
counter, so it yields nothing and the caller falls back to readingFromRefusal(),
which records the one fact any 429 carries: spent, now. Inventing a reading here
would be the same bug with the sign flipped — an invented outage.

Two details that cost a measurement each: the window comes from the vendor's own
sentence, so unlike a header name it is not overridden by the provider profile
(TPD read as a minute understates it 1440x); and remaining is clamped at zero,
because a vendor counting the rejected request against the total would otherwise
render a negative tank.

4 new tests, proved by mutation: breaking the arithmetic fails 3 of them.
261 tests pass, verify green.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 06:43:56 -07:00
CatoandClaude Opus 5 41874578af feat(resolve): let the vendor's catalogue pick the models, not a file (#55)
The chain replaced one pinned model with a list of pinned models. catalog.ts
then noticed the list rots too and added a check. But a check only produces a
SENTENCE — somebody still has to read it, edit a file, open a PR, wait for CI
and deploy, and until they do the app hands users a model that answers 404.

That round trip is this module's origin. On 2026-09-13 a health check scheduled
minutes earlier alerted that two ids in a consumer's registry were gone from
OpenRouter. The alert was correct and fast and completely dependent on a human
being awake. The vendor had published the truth the whole time.

So resolveChain() treats the declared list as a PREFERENCE and asks each vendor
what it actually serves. A retirement stops being an incident and becomes a
no-op.

Three rules, each paid for by a real failure:

1. NEVER SHRINK ON IGNORANCE. An unreadable catalogue keeps the declared list
   verbatim and sets `unverified`. While building this, a checkout without
   GROQ_API_KEY got a 401 and the first draft printed GONE for both Groq
   models — both live. Resolution that trusted that would let an expired key
   empty the chain. Tested against 401, 500, 404 and a missing key.

2. DISCOVERY EXTENDS THE TAIL, NEVER THE HEAD. Declared ids were probed with a
   real tool call; five of nine free models turned out to emit tool calls only
   as text. A discovered id has no such evidence, so it is a last resort and
   never a first choice.

3. DISCOVER ONLY WHAT THE VENDOR CALLS FREE AND USABLE — read, not guessed.
   Price, not the `:free` suffix: OpenRouter lists 19 ids ending `:free` and 22
   priced at zero, and the zero-priced ids WITHOUT the suffix include
   `openrouter/free`, the auto-router that is the most rot-resistant entry in
   the whole chain. Groq publishes prices too and none are zero, so discovery
   there correctly finds nothing and that vendor stays curated.
   Then suitability: of the 19 free ids one was `nemotron-3.5-content-safety`,
   a classifier and the only one declaring tools:false, and two more
   zero-priced ids were `lyria-3-*`, which emit AUDIO. Adding every zero-priced
   model would have put a safety classifier and a music generator in front of a
   user asking a question. Requiring text-out and declared tools removes
   exactly those three and nothing else.

Silence is refused rather than assumed throughout: a model that publishes no
price is never discovered. Guessing wrong in that direction spends money, so
the default declines.

Measured against the live catalogues, replaying Groq's real body so no secret
moved: the declared chain is 7 models, resolution yields 17 — and it flagged
`dots-3-note-preview:free` as ending 2026-09-30, seventeen days of warning,
because vendors sometimes publish an expiration_date and honouring it turns rot
from detected-afterwards into avoided-in-advance.

catalog.ts's own GET now reads the shared fetch in catalog-fetch.ts rather than
keeping a second, slightly different copy — the failure its header objects to.
Both vendor schemas are normalised there, because they do NOT agree: OpenRouter
puts modalities under `architecture` and tools in `supported_parameters`, Groq
puts modalities at the top level and uses `supported_features`. A reader that
knows only one shape silently drops a working vendor.

What this does NOT fix, stated plainly: presence in a catalogue is not proof a
model works. This package already records an id that answered "Provider
returned error" and one that returned HTTP 200 with EMPTY content. Resolution
fixes "the id does not exist"; demoting an id that exists and misbehaves needs
observed outcomes, and is not in this change.

Verified: 257 tests pass (18 new), format, lint, typecheck and both builds
clean.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 05:50:05 -07:00
ce95a19b5b fix(grounding): a markdown table is not a fabrication (#54)
A live answer laid its findings out as a table and was reported as fabricating.
Every claim in it was cited and correct; the flagged "novel proper nouns" were:

    Item
    Item Status Notes Pending

Those are the header cells of `| Category | Item | Status | Notes |`. A pipe is
not a word character, so it was not a boundary — the header tokenised as one
capitalised run, and the run then continued past the row break into the FIRST
CELL OF THE NEXT ROW to produce a phrase that appears nowhere on screen.

This is the worst direction for this check to fail in. FleetCrown now renders a
prominent "some of this is not backed by your records" warning on a flagged
answer, so a false positive does not merely add noise — it teaches the operator
to dismiss the warning, which costs more than the fabrication the check exists
to catch. A grounding check that cries wolf is worse than one that is absent,
because absence is at least legible.

Fix: pipes become line breaks alongside the existing code-fence stripping. A
cell is its own utterance and a run must not span two of them.

Recall is barely touched, and the test says so. Splitting per cell makes each
header word cell-initial, and sentence-initial single words were ALREADY skipped
for exactly this reason ("Rotate the key" must not flag "Rotate"). A fabrication
inside a cell still trips its remaining tokens — pinned by a test asserting that
"Program Manager at Impact Hub Zurich" in a table cell is caught as both the
composite run and its individual tokens. If that test ever goes quiet, this
boundary has become a blindfold.

Found by reading the grounding verdict on a real production answer rather than
by testing the parser, which is the only way this shape shows up: it needs a
model that chose a table, and every unit fixture used prose.

239 tests, up from 236.

Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 12:37:49 -07:00
dependabot[bot] a4930f1ad5 chore(deps-dev): bump the minor-and-patch group with 3 updates (#53)
Bumps the minor-and-patch group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.4.1 to 26.5.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.9.1 to 10.10.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.9.1...v10.10.0)

Updates `typescript-eslint` from 8.69.0 to 8.70.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.70.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.5.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.10.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: typescript-eslint
  dependency-version: 8.70.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-12 04:14:34 -07:00
CatoandClaude Opus 5 1bf0074f95 fix(capability): recognise the refusal in the form vendors actually write it (#51)
`tools are not supported by this model` matched nothing. Eleven patterns, and
every one of them assumed a singular subject with `is` — so the plural-and-
`are` form, which is what vendors actually send, fell straight through.

The header said a false negative "costs one request". That was the reasoning
error underneath the gap, and it is wrong. The caller that sends tool
definitions also DROPS its prose action catalogue, because definitions are
meant to replace it. So an unrecognised refusal leaves the model unable to
call a tool AND no longer told how to act without one — and because nothing
is recorded, it happens again on the next turn, and every turn after. A missed
phrasing is not a wasted request; it is a permanently mute model.

The bar is unchanged and still conservative: NAME tools or functions, and
NEGATE support, both halves explicitly. What changes is that the boring
grammatical variants now clear it — plural, `are`, `cannot use`, `no tool
support`.

Both directions are pinned. Seventeen real refusal phrasings must match;
thirteen real 400s that say nothing about tools must not — including the near
misses that make widening risky, `streaming is not supported for this model`
and `vision is not supported by this model`.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 03:36:48 -07:00
0bd6c38103 feat(tool-protocol): read the OTHER way models ask for a tool (#50)
`chain.ts` carries a probe table from nine free models called with a real tool.
Four answered with native `tool_calls`. Five answered only in TEXT. Three of the
seven models in the chain this package ships TODAY are in that second group:

  google/gemma-4-26b-a4b-it:free      text
  cohere/north-mini-code:free         text
  openrouter/free                     text

`complete()` read only `message.tool_calls`. So on nearly half its own chain it
returned ZERO tool calls — and handed the model's narration of the call back as
ordinary content. A turn that should have looked up a record instead returns a
confident sentence describing the lookup it never performed, and every layer
downstream treats that as an answer.

That is not a missing feature. It is a fabrication path, and the package's own
evidence said it was open.

The old comment called text parsing "the caller's business, because its
convention differs per app". True of the convention; false of the consequence.
An app that declines to parse does not get less capability, it gets invented
answers — and the one app in this fleet that does parse had to keep its whole
HTTP client to do it, which is why "put every app on one caller" was blocked.

WHAT CHANGES

`complete()` now reads both protocols and merges them, native winning ties so a
model emitting the real call plus a prose echo runs the tool once. Parsed lines
are stripped from `text`, because a narrated call must never reach a user as
prose.

Inert unless you use tools: parsing is skipped when no `tools` are supplied — a
model does not narrate a call it was never offered. No consumer passes `tools`
to complete() today, so this changes behaviour for nobody and unblocks the one
that needs it. `toolProtocol: "native"` opts out for a caller that parses the
lines itself and would otherwise execute each call twice.

Ordering matters: after stripping, a reply that was ONLY a narrated call has
empty text. `complete()` treats an empty 200 as a link failure, so tool calls
are counted first or a working model gets demoted off the chain.

DETAILS WORTH THE TESTS

- The closed set comes from the `tools` array the caller already passed. Two
  lists that must agree are one list that cannot disagree, and the split version
  fails silently — a missing name makes the parser ignore a real call.
- The JSON walker is string-aware. Naive brace counting closes at the `}` inside
  `{"q": "a } b"}` and the arguments vanish.
- Unparseable stays null, distinct from `{}`. Returning `{}` satisfies a
  caller's `?? {}` and silently drops arguments the model put on the next line —
  exactly what a ```json fence after ARGS: produces.
- Every tolerated shape (markdown bolding, list bullets, `=`, copied parens,
  fenced or multi-line ARGS, a missing ARGS line) is one a small model actually
  emitted. Rejecting any is a turn failed over formatting.
- `TEXT_TOOL_PROTOCOL_HINT` ships the prompt wording beside the parser that has
  to read it back. A prompt and its parser are one contract.

232 tests, up from 211.

Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 01:59:27 -07:00