Files
ai-kit/test
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
..