9 Commits
Author SHA1 Message Date
CatoandClaude 53400228b0 chore(deps): @bitbaum/ai-kit 1.26.0: Google out of the free AI chain (#147)
ai-kit <=1.25 put Google's Gemini API in the free model chain on the
fleet-wide GEMINI_API_KEY. That key sits on a billed Google project and
cost about $567 on 10-11 Nov 2026. 1.26 builds no Google link (free chain
is Groq, then OpenRouter :free), keeps paid AI off unless an app opts in,
and adds daily caps.

- the freeAvailability test now pins that a Gemini key switches nothing
  on, and that Groq comes before OpenRouter
- README, live-check warning and the live check's comments no longer name
  GEMINI_API_KEY as a free key


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 10:06:56 +01:00
CatoandClaude Opus 5.5 6cf21ce9e7 feat(agent): read the law of all 26 cantons through LexFind (#44)
* feat(agent): read the law of all 26 cantons through LexFind

lib/law/lexfind.ts finds a cantonal act by abbreviation (StG), systematic
number (631.1) or title through LexFind's public API (Institute of
Federalism, University of Fribourg), reads the canton's official PDF
with unpdf, drops repeated page headers, rejoins hyphenated words and
cuts out one § or Art., stopping at the next heading but not at a
reference to it. The source link is the canton's own page.

read_law reads a non-federal act from the matter's canton, or from one
named with the new canton field. Checked live: ZH StG § 140, BE StG
Art. 187, VD LI Art. 1 (and LU, GE by hand).

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

* fix(agent): a runaway reply runs 8 calls, a turn 12 law reads; point the agent at read_law

Agent check on d13d436: one model reply asked for read_law ~150 times and
the turn failed; in the tax case the model searched instead of reading
Zürich's StG and answered too late to be corrected.

- One reply runs at most 8 tool calls; the rest, and any exact repeat,
  are answered 'not run' so the model can ask again.
- Per turn: read_law 12, web_search 8, read_page 8 (with the writes).
- The Swiss and Liechtenstein market notes now tell the agent read_law
  reads federal, cantonal and Liechtenstein acts, with an example.

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

* fix(agent): keep the turn's real answer when a correction ends in a call note

Agent check on 51ac8c7: the tax answer (a table with the deadline) was
flagged for narrating a call; two corrections later the last reply was
only '(called add_task)', so the person saw 'could not finish' although
the deadline was recorded. The turn now keeps its best real answer,
narration removed, and stores that when the last reply has nothing.

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

* fix(agent): a turn never ends with nothing; cantonal letters mean the canton's act

Agent check on 2a4221e: the tax turn's only reply came in round 6, too
late for a correction, and was just '(called note_fact)'; the deadline
was recorded but the person saw 'could not finish'. Such a turn now gets
one more round without tools, to answer in words.

The model also never read Zürich's StG: the matter's canton was set
mid-turn, after the jurisdiction note was written. The system prompt now
says a cantonal authority's letter rests on the canton's own act, to be
read with read_law.

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

* fix(agent): a turn with no answer gets one rescue round, by another model

Agent check on 4126c2e: the agent now reads Zürich's StG, but the
tool-less last round was answered by a text-protocol model with a TOOL
line, so the person saw 'could not finish'. A turn that has produced no
real answer at all now gets one more round, past the limit if need be,
by the next model in the chain, told that tools are gone and to answer
in words from what they returned.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 18:59:29 +02:00
CatoandClaude d9dfb24089 feat(agent): read Liechtenstein law from gesetze.li; one read_law per country (#40)
lib/law/lilex.ts reads one provision of a Liechtenstein act from Lilex,
the Government's consolidated collection: art:n and par:n anchors, a
provision ending at the next provision or heading, a link scrolled to
it. Lilex has no API and puts its listings behind a browser proof-of-
work, so acts come from a map checked against the live pages (LV, ABGB,
SR, PGR, ZPO, StGB, StPO, LVG, AuG, SteG, ArG), and a challenge page is
reported as unreachable with one polite retry, never parsed as law.

lib/law/index.ts picks the collection by the matter's country first
(StGB and ZPO exist in both) and follows update_matter during the turn.
A country is added by giving it a reader there.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 18:16:27 +02:00
CatoandClaude af0757a737 feat(agent): read Swiss federal law from Fedlex, no search engine needed (#36)
A read_law tool: an act by abbreviation (OR, ZGB, SchKG, DBG, AIG, CO,
CC, LP…, all three official languages) or SR number, and an article.
lib/law/fedlex.ts asks Fedlex's open SPARQL endpoint which consolidated
version applies today, fetches its HTML from the official file store and
cuts out the article (paragraph numbers kept, footnote markers dropped).
The text comes back with its Fedlex link as a numbered source.

Free and on our side of the wire, so the agent can source federal law
while web search is down; an unsourced answer is corrected toward
read_law, and stored unverified only when Fedlex is unreachable too.
live/law.live.ts (pnpm run check:law) reads real articles and checks
that every SR number in the abbreviation map is a real act.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 11:08:38 +02:00
CatoandClaude Opus 5.5 1efd80ab5c feat(matters): ask the same questions of every document (#33)
* feat(matters): ask the same questions of every document

Up to three questions across a matter's documents, answered as a table
with each answer's quoted passage. A quote not found in the document is
dropped, never shown. The table is saved as a draft. Personal data is
redacted before the model sees it and restored after.

Also: a one-letter account name no longer makes matter creation fail
(wordsToHide trims and drops words shorter than two letters).

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

* fix(agent): a deadline given in the answer must be recorded

The real-model Agent check saw the model compute the tax objection
deadline correctly (4 November 2026) and never call record_deadline, so
no reminder was set. An answer naming a deadline date while the matter
holds none now gets the one correction, like a narrated call.

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

* fix(agent): a model that writes its calls out hands the retry on

Agent check run on b33cf5d: a text-protocol model in the free chain wrote
update_matter and note_fact as JSON blocks and, corrected, answered
'(called web_search, web_search)'. Correcting the same model with no
format to use cannot work. Now a narrated answer moves the serving link
to the back of the chain for the rest of the turn, and the correction
alone carries TEXT_TOOL_PROTOCOL_HINT (in the system prompt it broke the
native callers). Calls written as JSON naming the tool count as narrated.

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

* fix(agent): narration left after the correction is never stored

Agent check on 7decfe8: the final round offers no tools, so a text-protocol
model's TOOL lines there were never parsed and became the stored answer;
a bare '(called note_fact)' was stored likewise. Such an answer is now
stripped of TOOL lines, call notes and fenced JSON naming a tool; if
nothing remains, the existing 'could not finish' message is shown. The
live test logs which model served each turn.

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

* fix(agent): two corrections, each answered by the next model

Agent check on 8639cc8: groq gpt-oss-20b computed the tax deadline,
was told to record it, and answered again without recording it; the
rent answer claimed '(recorded)' with nothing recorded. A model that
ignored the rule ignores its correction too. Every correction now moves
the serving link to the back of the chain, and a turn gets up to two.

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

* fix(agent): eight rounds, so a late answer can still be corrected

Agent check on 8f903eb: qwen3.8-27b researched for four rounds, its
answer arrived too late for a correction, and the final tool-less round
produced only narration, so the person saw 'could not finish'.

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

* test(live): trace every round of a real-model turn

runTurn takes an optional onRound callback (served link, calls asked
for, what the answer check found, the text's start). The live check
prints it, so a failing run shows what each model did, not only the end.

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

* test: the answer check corrects an unrecorded deadline; live trace printed after the turn

A scripted-model test proves the loop: a deadline answered without
record_deadline is sent back, recorded, then answered. The live check
now collects its round trace and prints it with the other lines.

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

* fix(agent): a search outage cannot eat the turn

Agent check on 2952096, traced: every web_search came back empty, so
gpt-oss-120b searched six rounds running and the answer arrived in the
last, uncorrectable round. Search is now withdrawn for the turn after an
outage or two empty searches, the model is told to answer from the
matter and name what it could not check, and a missing source is no
longer 'corrected' by asking for a search that cannot happen: the answer
is stored marked unverified. The live check logs each search backend's
outcome.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 10:08:56 +02:00
CatoandClaude Opus 5.5 eba1b0abb5 fix(agent): no tool calls written out, no law without a source (#32)
* fix(agent): no tool calls written out, no law without a source

Found on the live site: a free model answered a Zürich rent-increase
question without calling one tool, wrote update_matter(…) and
record_deadline(…) into its answer as text, and stated rules of law with
no source. Nothing was searched or recorded.

- The system prompt now carries ai-kit's TEXT_TOOL_PROTOCOL_HINT, so a
  model that calls tools in text uses the format complete() parses.
- lib/matters/answer-check.ts checks every final answer: tool calls
  narrated instead of made, or law (Art./§/OR/ZGB/SchKG/SR/LGBl…) stated in
  a turn with no source. One precise correction, then a retry; an answer
  still failing is stored under a visible 'unverified' step.
- live/agent.live.ts gains the failing question as a real-model case.

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

* fix(agent): the tool-format hint actually reaches the model

The previous commit imported TEXT_TOOL_PROTOCOL_HINT but its edit to the
system prompt was lost; lint flagged the unused import.

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

* test(live): show the rent case's lines in the Agent check output

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

* fix(agent): withdraw the text tool hint; '(called …)' is not an answer

The real-model Agent check failed with TEXT_TOOL_PROTOCOL_HINT in the
prompt: the chain's models (all native callers) switched to text calls and
answered '(called note_fact)', copying the loop's own note of a call. It
passed without the hint. The hint is withdrawn, and an answer that is only
such a note now counts as narrated, so it gets the one correction.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 09:44:23 +02:00
CatoandClaude Opus 5.5 35faee8843 Agent: set the matter up, cite every rule, answer in the reader's language (#19)
* Agent: set the matter up first, cite every rule, answer in the person's language

From the first real-model run: it found the right deadline but answered a
question written in English in German (the letter's language), wrote ß, cited
the federal act for a cantonal assessment without a source number, and left
the matter untitled.

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

* Agent answers in the reader's interface language

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 13:45:33 -07:00
CatoandClaude Opus 5.5 4a610f612d Search queries keep their placeholders; a real-model agent check (#18)
* Provision: record 0000_init in the shared deploy's schema ledger

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

* Search queries keep their placeholders; a real-model agent check that runs on the box

The agent restored placeholders in every tool's arguments, so a search query
the model wrote as "[NAME-1] …" went to the search engine with the name in
it. Arguments are now restored only for tools that write into the matter;
web search, page reads and domain lookups go out as the model wrote them.

live/agent.live.ts runs one turn through the real free chain on PGlite and
asserts a recorded deadline and that no request carried the name; the Agent
check workflow runs it on the box, where the keys are.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 13:31:58 -07:00
CatoandClaude Fable 5.1 1ccc37cdea Build out Causius: cases, own model, helpers, EN/DE/FR (#7)
* Build out Causius: case intake, case file, helper marketplace

Replace the day-zero page with the product: a landing page, letter intake
with env-gated AI analysis, a case view (deadline, checklist, translations,
draft reply), browser-only case storage with export/import, and the helper
marketplace rules for legal assistants and licensed lawyers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Put Causius on the fleet's stack and its three planes

- AI: replace the hand-rolled single-vendor fetch with @bitbaum/ai-kit
  complete() over the shared free chain; no pinned model id. Add the
  fleet's own-model flow (ai-kit byok + probe), key kept in the browser.
- Validation with zod, rate limits with limitkit, tests with Vitest.
- Identity rendered from the Loki fleet map; ROADMAP.md and CHANGELOG.md
  as the public record, shown through bip-kit.
- Helpers live on OrangeCat as services; OrangeCat and Solon links appear
  only when the fleet map reports the profiles exist.
- Nav contract: routes constant, aria-current, 44px targets. Beta label.
- CI and auto-merge from the current site template; TypeScript 6,
  ESLint 10, Node 24; AGENTS.md from the fleet template.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Speak English, German and French; make intake work end to end

- next-intl with locale routing (en unprefixed, /de, /fr), every string in
  the message catalogues, a parity test, Swiss German spelling.
- The analysis is written in the reader's language.
- Several pages per letter; photos are shrunk in the browser so a phone
  picture fits.
- The deadline is shown with the sentence it was read from, and the model
  is told never to compute a date the letter does not state.
- /api/health, and the intake page says up front what the free models can
  do. `pnpm run check:analyze` runs the sample letter through a real model.
- A down fleet map no longer stalls on-demand pages.
- Refuse the two build scripts next-intl brought, so installs stay clean.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 18:59:28 +02:00