mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-03 22:47:44 +01:00
main
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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>
|
||
|
|
d3cfbe096b |
feat: v0.7.0 — release the call, and prove the engine RUNS (#33)
Merging #32 gave this package an HTTP client but published nothing: the version stayed at 0.6.2, so no consumer could reach it. This releases it. It also closes the gap that a shared engine makes dangerous. Every check in this repo was hermetic — `test/` drives an injected fetch, `check-catalog` asks whether ids still EXIST — so all of them could be green while the package could not complete one real turn. That was survivable while two repos imported it. It stops being survivable when one engine sits behind every app, because then its bugs arrive everywhere simultaneously. scripts/smoke.mjs makes a real generation against the live free tier. It earned its place on first run, finding two things no hermetic test could: - `maxTokens: 16` made groq/openai/gpt-oss-20b return 200 with EMPTY content. The chain leads with REASONING models, which spend the budget thinking before emitting a visible token — so a small budget makes a healthy model indistinguishable from a dead one, walks the entire chain, and reports every link broken. Documented on CompleteOptions.maxTokens where a consumer will actually hit it, and the smoke now asks for 256. - A single-quoted value in a .env inlines its QUOTES into the key, and OpenRouter answers that with "Missing Authentication header" — which reads as a missing key rather than a malformed one. Scheduled, never a PR gate: it calls other people's servers, so as a required check it would redden pull requests for a vendor's 500 and train everyone to ignore red. The `|| status=$?` in the workflow is load-bearing — Actions runs steps under `bash -e`, so a bare failing command aborts before its exit code can be read, and the "no keys" branch would be unreachable. Both scheduled jobs refuse to pass while blind: a probe that looked at nothing has told us nothing, and green would be a lie. Verified: catalog check run live — all 7 default pins present at their vendor, confirmed both locally and in Actions ("7 id(s) confirmed present"). Smoke run live — groq/openai/gpt-oss-120b answered "blue" in 878ms. verify green: format + lint + typecheck + build + 91 tests. Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
79165471db |
chore: pnpm — the fleet has one package manager (#26)
* chore: pnpm — the fleet has one package manager Convert from npm to pnpm (fleet standard, STACK.md): - packageManager pin pnpm@11.25.0 (corepack SSOT) - pnpm-lock.yaml via `pnpm import` from package-lock.json (resolutions preserved), then package-lock.json deleted - CI + publish workflows: pnpm/action-setup@v6, cache: pnpm, `pnpm install --frozen-lockfile`, `pnpm run verify` - package.json scripts and contributor docs use pnpm; consumer install lines stay npm — consumers choose their own package manager - npm publish invocation unchanged (works from a pnpm-managed tree) Clean-room proven: rm -rf node_modules && pnpm install --frozen-lockfile && tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix(ci): node 22 — pnpm 11 requires >= 22.13 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn --------- Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
9009d73d3f |
chore: add a formatter (#22)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (27 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(ci): ignore dist-cjs, which only exists on the runner format:check passed locally and failed in CI on six files under dist-cjs/. The ignore list covered 'dist' but not its siblings, and CI builds before verify — so those files exist on the runner and never locally. A clean local check is no evidence when a build precedes the gate. Widened to dist-* so dist-esm and friends cannot repeat this. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
07c492ce27 |
fix: four of the nine default pins were already retired (#4)
* fix: four of the nine default pins were already retired
Checked `freeChain()` against the live catalogues on 2026-08-25. Four of its
nine ids no longer exist:
groq llama-3.3-70b-versatile GONE
groq llama-3.1-8b-instant GONE <- whole vendor dead
openrouter openai/gpt-oss-20b:free GONE <- was FIRST in the list
openrouter nvidia/nemotron-3-nano-30b... GONE
The chain exists because a single pinned free model is a scheduled outage. That
reasoning has a hole this package fell into: the chain is ITSELF a list of pins,
so it rots too — and a chain whose first vendor is entirely dead is a slower
version of the failure it was built to prevent. Every caller paid two Groq 404s
and then a third on the preferred OpenRouter fallback before reaching a model
that could answer.
Consumers inherited it. FleetCrown used the same Groq id for direct, unchained
calls and was silently broken for eight days: its nightly frontier digest fell
back to a canned headline, and activity digests, calendar extraction, proposal
extraction and hosted-runner analysis all failed one at a time, quietly enough
that nothing looked broken.
Replacements probed, not guessed — the package's own rule. `openai/gpt-oss-120b`
and `openai/gpt-oss-20b` each returned a correct native tool_call with correct
arguments. The two retired OpenRouter ids are removed; the other five were
confirmed present in the 419-model catalogue.
── catalog: the check that can actually run on a timer ──────────────────────
New module, exported as `checkCatalog` / `hasRot` / `deadProviders` /
`catalogReport`. One GET /models per provider and ZERO tokens, which is the
entire point: a tool-call probe costs real money and therefore can never be
scheduled, so the only existing defence was a command someone had to remember
to type. Existence is cheap enough to check nightly. `npm run check:catalog`
runs it against this package's own defaults and exits 1 on confirmed rot.
It lives here rather than in each app because the check is the same everywhere,
and the first app to need it had already written its own, slightly differently.
Three states, not two. `live: null` means the catalogue could not be READ — no
key, network failure, non-200, or a body that parses but lists nothing. That is
not an empty catalogue. Reporting it as rot invents an outage; reporting it as
a pass hides one. `hasRot` counts only CONFIRMED absences, so an offline or
keyless run cannot fail a pipeline for something it never saw.
That distinction earned itself immediately: Node's global fetch is intermittently
broken on the laptop this was written on, and the checker correctly reported
7 UNCHECKED rather than "every model retired" — which would have sent me
"fixing" ids that were live.
`deadProviders` is separate from `hasRot` on purpose: a chain missing some
models is degraded, a chain missing an entire vendor is back to being a single
point of failure, and those deserve different words.
── modelCost is provider-dependent, and was silently wrong about it ─────────
The existing `paidModelsIn` guard caught the new Groq pins and called them PAID.
It was not a false alarm to suppress — it was the guard finding a real hole in
its own rule.
`modelCost` decides from the id: a slashed id without `:free` is paid. That is
right for OpenRouter, where `openai/gpt-oss-20b` genuinely bills. It is wrong
for Groq, where the same string is just that vendor's name for a model whose
cost is the account's tier. The rule was only ever safe because direct vendors
used bare ids (`llama-3.1-8b-instant` → "unknown"); Groq now ships
vendor-prefixed ids, so the shape stopped identifying the vendor.
So `Provider` gains `routed?: boolean` (true for OpenRouter), and `modelCostAt`
judges an id AT its provider. At a direct vendor the verdict is "unknown" —
never "free", which would reopen the hole this module was written to close.
`modelCost(id)` is unchanged for existing callers, with a docstring saying what
it assumes.
A false "paid" here is not harmless: it pressures someone into "fixing" a
working free model, and a guard that cries wolf gets disabled — taking the three
real cases it does catch with it. Pinned by a test that the routed vendor's
`anthropic/claude-sonnet-5` and `google/gemini-2.0-flash-001` are still flagged.
verify: 44/44 pass. Live catalogue check: all 7 pins present, no rot. Mutation:
restoring the retired pins turns it red (exit 1, deadProviders ["groq"]).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore: 0.2.1 — retired pins replaced, catalog check added
Consumers pin this package by git TAG (FleetCrown:
github:maonakamoto/ai-ration#v0.2.0), so the retired-model fix only reaches
them once a new tag exists and their pin moves. Bumping here keeps
package.json and the tag in agreement — the previous release left an installed
copy reporting 0.1.0 under a #v0.2.0 pin, which makes 'which code is actually
running' unanswerable from the tree.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|