Files
ai-kit/package.json
T
CatoandClaude Opus 5 ac5027df4d feat(web): the agent can see the web, and cite what it saw (#45)
* ci(auto-merge): correct the reason this repo passes a PAT

The comment added a few hours ago says GITHUB_TOKEN cannot merge a PR that
touches .github/workflows. That is contradicted by this fleet's own history:
github-actions[bot] merged datacat#253 and ai-kit#42 today, and both change a
workflow file. I asserted it from the reusable workflow's docstring without
checking, then found the counter-evidence while looking for something else.

Two stalled PRs were offered as proof and neither survives either. ai-kit#11
opened 2026-08-29 and this repo's sweep was not added until 2026-09-04, so for
most of that PR's life nothing was sweeping at all. aoz-housing#122 is still
unexplained — I merged it before diagnosing it, which destroyed the evidence.

The THROUGHPUT reason is unaffected and is why the line stays. A dispatch made
with GITHUB_TOKEN triggers no workflows — the same rule the deploy reconciler
exists for — so after a merge the re-armed CI run's completion fires no
workflow_run and nothing wakes the sweep for the next PR. It waits for the
cron, which GitHub throttles: fleetcrown's sweeps land 50-65 minutes apart
against a */10 schedule. A PAT-created dispatch does emit workflow_run.

The wrong claim is recorded in the file rather than quietly deleted, so the
next reader does not re-derive it from the same docstring I did.

No behaviour change: an undefined secret still resolves to empty and the
reusable workflow still falls back to github.token.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

* feat(web): the agent can see the web, and cite what it saw

Adds `@bitbaum/ai-kit/web`: search over a provider chain, a page reader
safe to point at an agent-chosen URL, and a mapping of both onto the
`Fact` type the grounding harness already verifies.

Every AI product in this fleet is about to need this, and each one is a
distinct way to be wrong:

- WHICH backend. Same fallback-chain problem `chain.ts` solved for
  models, for the same reason — a single pinned backend is a scheduled
  outage. searxng (self-hosted, no key, nobody told what users search
  for) -> brave (an independent index, so the fallback is not the same
  index asked twice) -> tavily. Only the ones the env configures.

- WHETHER it answered. The result is three-valued: found / nothing /
  could_not_look. "Found nothing" and "could not look" are different
  answers and collapsing them into [] is how an expired API key becomes
  a confident sentence about what does not exist on the internet. A
  backend answering 200 with zero results is walked past rather than
  believed — that is what a metasearch instance does when its upstreams
  refuse it, and stopping there would report an outage as a fact.

- FETCHING a page the MODEL chose, which is a different security problem
  from fetching one a user typed. There is no human to blame for the
  address, and any page the agent reads can hand it a link to the
  metadata service. So: http(s) only, ports 80/443, no credentials,
  every resolved address checked (not the first — a hostname with one
  public and one private record is rebinding with the work done), and
  `redirect: "manual"` with the full check re-run on every hop.
  Validating the first URL and then letting fetch follow the 302 is not
  a check, and it passes every test that only feeds it URLs.

- CITATIONS. Search without citation binding makes hallucination worse,
  not better: the invented sentence is now surrounded by real ones. So
  results become Facts with an id and a url, page text becomes evidence
  labelled with the id that licenses it, and `verifyAnswer` checks the
  binding mechanically. Web content and database rows now go through one
  verifier instead of two.

`published` and the rest are declared in FACT_KINDS precisely because
engines omit them: a rendered `published: <not recorded>` is what stops
a model putting a year on an undated page.

39 new tests, written against the contract rather than the
implementation — the repo has already shipped a regression test that
asserted the buggy behaviour and went green. The reader's title path had
a real bug (tag-stripping left double spaces); the test found it and the
implementation was fixed, not the test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 04:36:21 -07:00

109 lines
3.0 KiB
JSON

{
"name": "@bitbaum/ai-kit",
"version": "0.16.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"
},
"./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
}
}
}