mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-04 08:48:20 +01:00
A vendor that accepts the connection and then never answers is the most
common partial outage there is, and it was the one this chain could not
survive: without a deadline `await fetch` never returns, link two is
never reached, and the fallback becomes the thing holding the request
open. Every one of the fleet's hand-rolled clients has the same hole.
`timeoutMs` (default 30s) is PER LINK, and that is the whole point. The
obvious alternative — passing a budget as `signal` — is actively worse
than nothing: link one spends all of it and links two onward inherit an
already-aborted signal, so the fallback fails instantly and reports every
vendor broken when only the first was slow. A deadline and a fallback can
both be true only if each link gets its own.
Also: when the CALLER's signal aborts, the walk now stops. Touring the
remaining vendors spends a daily budget on an answer nobody will read,
then reports "every vendor failed" about vendors never asked.
A timeout names itself in the failure. "This operation was aborted" in a
log is indistinguishable from a caller cancelling, and the two want
opposite reactions from whoever reads it.
The probe takes a tighter 10s: a monitor asking "is the AI up?" has given
up long before a chain of 30s links finishes being patient, and a health
route that takes a minute to say "down" has become a second outage.
Two test-quality fixes found by mutation, both worth more than the
feature:
- the first "abandoned, next link serves" tests PASSED with the
deadline deleted. Without a signal the helper threw instantly, the
walk demoted, and the test proved demotion rather than the deadline
it was named for. Asserting inside the fake fetch does not fix it
either — `complete` catches everything a link throws, so a failed
assertion becomes just another demotion. The deadline is now recorded
and asserted outside the walk.
- the probe's tighter deadline was "covered" by asserting a signal
existed. complete's own 30s default supplies one, so that test stayed
green with the tighter deadline removed. It now measures WHEN the
abort lands, which costs ~10s of suite time and is the only shape
that observes the thing it names.
Dropped an unref() on the timer that I had justified with a scenario
that does not hold: it is always cleared in dispose, so there is nothing
to save, and an unref'd timer stops firing when nothing else keeps the
loop alive — a deadline that sometimes does not happen.
109 tests. Each new guarantee verified by mutation.
Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
105 lines
2.9 KiB
JSON
105 lines
2.9 KiB
JSON
{
|
|
"name": "@bitbaum/ai-kit",
|
|
"version": "0.9.0",
|
|
"description": "One install for the AI layer of an app: which model to call, what to do when the vendor retires it, how to walk the fallback chain and know when none of it worked, how to read the three kinds of 429, a fair daily budget across users, headless AI form filling — and now the model registry (one SSOT for every callable id, with the paid/free boundary as a field) and the grounding harness (facts, contract, deterministic fabrication check).",
|
|
"license": "MIT",
|
|
"author": "Mao Nakamoto",
|
|
"homepage": "https://github.com/bitbaum/ai-kit#readme",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/bitbaum/ai-kit.git"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/bitbaum/ai-kit/issues"
|
|
},
|
|
"keywords": [
|
|
"ai",
|
|
"llm",
|
|
"form-fill",
|
|
"fallback",
|
|
"failover",
|
|
"health-check",
|
|
"free-tier",
|
|
"rate-limit",
|
|
"quota",
|
|
"fair-share",
|
|
"groq",
|
|
"openrouter"
|
|
],
|
|
"type": "module",
|
|
"sideEffects": false,
|
|
"packageManager": "pnpm@11.25.0",
|
|
"engines": {
|
|
"node": ">=20"
|
|
},
|
|
"publishConfig": {
|
|
"access": "public",
|
|
"provenance": true
|
|
},
|
|
"files": [
|
|
"dist",
|
|
"dist-cjs",
|
|
"src"
|
|
],
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.js"
|
|
},
|
|
"./forms": {
|
|
"types": "./dist/forms.d.ts",
|
|
"default": "./dist/forms.js"
|
|
},
|
|
"./react": {
|
|
"types": "./dist/react.d.ts",
|
|
"default": "./dist/react.js"
|
|
},
|
|
"./server": {
|
|
"types": "./dist/server.d.ts",
|
|
"default": "./dist/server.js"
|
|
},
|
|
"./registry": {
|
|
"types": "./dist/registry.d.ts",
|
|
"require": "./dist-cjs/registry.js",
|
|
"default": "./dist/registry.js"
|
|
},
|
|
"./grounding": {
|
|
"types": "./dist/grounding/index.d.ts",
|
|
"require": "./dist-cjs/grounding/index.js",
|
|
"default": "./dist/grounding/index.js"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist-cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
|
|
"lint": "eslint .",
|
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
"test": "node --test test/*.test.js",
|
|
"check:catalog": "pnpm run build && node scripts/check-catalog.mjs",
|
|
"smoke": "pnpm run build && node scripts/smoke.mjs",
|
|
"verify": "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm run build && pnpm test",
|
|
"prepare": "pnpm run build",
|
|
"format": "prettier --write .",
|
|
"format:check": "prettier --check ."
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^10.0.1",
|
|
"@types/node": "^26.4.1",
|
|
"eslint": "^10.9.1",
|
|
"globals": "^17.12.0",
|
|
"prettier": "3.9.6",
|
|
"typescript": "^6.0.3",
|
|
"typescript-eslint": "^8.69.0"
|
|
},
|
|
"dependencies": {
|
|
"ai-forms": "^0.1.2"
|
|
},
|
|
"peerDependencies": {
|
|
"react": ">=18"
|
|
},
|
|
"peerDependenciesMeta": {
|
|
"react": {
|
|
"optional": true
|
|
}
|
|
}
|
|
}
|