Files
ai-kit/package.json
T
97ac6cfa17 feat(policy): one statement of who may spend what, read by the gate AND the screen (#49)
Across this fleet the same feature exists twice, half each. One app enforces a
daily AI budget with no interface at all: the user is refused, and never learns
why or what their share was. Another draws a quota meter with its own separate
notion of tier, which the enforcement path does not read. Both are correct in
isolation and they cannot agree, because there was no single statement of the
policy for them to agree ABOUT.

`decide(policy, state)` is that statement. The gate asks it whether to allow;
the settings page asks it what to draw. A number on screen the gate does not use
is decoration, and a gate whose reasoning cannot be rendered is a wall.

Pure, by the same rule as fair-share: no database, no clock, no provider.

WHY A REFUSAL CARRIES A LADDER

Shared free capacity is a fixed cost carried on behalf of strangers, and its
only job is to be good enough, once, that someone wants more of it. The moment
it runs out is the only moment anybody changes anything — which makes the
refusal the most important screen in the product, not an error state.

So `decide` returns a `Wall`, not a boolean. The default order offers the exits
that cost the user NOTHING before the one that costs money: asking someone to
make a free account elsewhere converts better than asking them to pay, and it
takes them off the shared pool just as completely.

FOUR PROPERTIES WORTH THE TESTS THEY COST

- `wait` is always the floor, and a config cannot remove it. A refusal with no
  way forward reads as a broken product; "it refills at 01:00" is a path.
- An unknown tier fails CLOSED. A typo in a config should cost nothing, not
  hand out the shared pool.
- Uncapped is `null`, never 0. Rendering null as a gauge at zero would tell a
  user on their own key that they are out — the opposite of true.
- A rung the user cannot take is marked unavailable rather than dropped.
  Dropping it makes the list differ per user for reasons nobody can see.

`shouldSurface()` keeps the indicator quiet until it matters: a permanent gauge
at 96% trains people to ignore the one at 4%.

190 tests, up from 179.


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

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

109 lines
3.0 KiB
JSON

{
"name": "@bitbaum/ai-kit",
"version": "1.2.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 \u2014 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"
},
"./web": {
"types": "./dist/web/index.d.ts",
"default": "./dist/web/index.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
}
}
}