* Practice: choose or type, one switch above every question A remembered habit (heidi.practice.habit.v2) decides, for each word that has both, whether its meaning is chosen or its sentence typed. A flip swaps the questions still ahead one for one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: a word typed right comes back later than one chosen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: one hardness number for every question Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Plans: your own AI key is offered, and the pass card says what a pass is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Knowledge map: a deterministic layout, and every node's state from the ledger lib/visual/knowledge-map is the first knowledge-map layout in the fleet, written to be extracted: plain data in, coordinates out, no app imports. Clusters packed into columns, nodes in rows under each cluster's name, labels wrapped with the real font's widths; no two cells meet, so no two labels can, at 320px as at 1280px. Same input, same picture. lib/domain/progress reads where a learner stands on every situation, grammar topic and word group (not started / started / shaky / solid / mastered) from the learner model, the review memory and the situation readings the situation pages already use, and orders the few lines worth acting on: the learner's own situations first, then new ones in their areas, then what wobbles, then the words that keep slipping. Nothing is counted in advance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * «Was du kannst»: the map page, the weak-spots card, and the ways to it /[locale]/progress draws the whole course as a map coloured by the learner's own answers, with a legend and one motion (what is known fills in, off under reduced motion). Tapping a node opens a sheet with what it is, the numbers (asked, right, last seen, due) and «Üben», «Bis es sitzt» (goal=nail), and for a situation «Situation starten»; an area's name opens its situations and practises the whole area (module=…). Works signed out from this device and signed in with the synced views; with no data it is the course, not started, and where to begin. The card «Was sitzt, was fehlt» is on the personal page and above the map; /practice links to the map; the avatar menu lists it. Personal and noindex like settings, so not in the sitemap. Strings in all seven dictionaries; the responsive audit measures /progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: an area scope, «Nail it», hardest first, and nothing right today asked again - module=<area>: every scene of one situation area (care, hospitals, ...) and the words said in them; subjects=<list>: named words and lines, for the weak spots. - goal=nail (nail.ts): a drill over a scope until each question is right twice in a row, the second at least three questions later and in the typed form where a word has one; a miss comes back after two to four others; at most 30 subjects, hardest not-known first. - order=hard: hardest first by hardness(); «Harder» prefers the harder question inside its band. - A sitting's order is shuffled (order.ts), never the same subject back to back and the same kind only where unavoidable; cards keep their most-heard-first order. - Answered right today and not wrong today, on any screen (stats now date every wrong answer): not new again today in a sitting; read instead of asked in a situation run (withKnownRead), unless its review is due. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Play together: a challenge link and a live round A challenge is ten fixed questions behind a link (/play/c/<id>): the same questions in the same order with the same option order for everyone, a nickname and no account, marked on the server, and a board of names, right answers and times. It is kept 30 days, and expired ones are removed when somebody next touches the table. A live round is a host screen (/play/host) with a six-digit code and a QR code, players on their phones (/play?code=), 20 seconds a question, points for right plus speed, counts per option on the host's screen, a short board on the phones and a podium. Realtime is short polling against Postgres: one primary-key read with a version, 204 when nothing moved. At most 50 players per room; a room is gone two hours after its last move, checked on access. Host actions need the host secret kept on the host's device; creating rooms and joining are limited with limitkit; nicknames are cleaned, capped at 24 and only ever rendered as text. Five new tables (migration 0033), two privacy flows, the strings in all seven languages, one section on /practice and one button at the end of a sitting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: wrong answers a German reader cannot see through, and «Find the German word» A harness (scripts/audit/options.ts, not shipped) measures how often a reader who knows no Zurich German answers each chosen-answer question by looks alone: most like the prompt, least like it, odd shape, longest. options.test.ts holds the rates near chance. - «Say it in Zurich German» (run): the wrong lines are the right line with one word changed: a Standard German word from the pack's leaks or the course's own cognate pairs, a form the pack places elsewhere, or an article the noun never takes. By looks: 99% -> 32%. Other lines only where a line has fewer than two such changes. - Look-alikes skip Zurich words that stand for two standard words (bi: bin/bei, wänn: wann/wenn) and course pairs that are not cognates, so a planted word is certainly not Zurich German. - «Stimmt das?»: a false claim is a near miss of the line's meaning (near-miss.ts), never another line; no near miss, no false claim. By resemblance: 96% -> 64%. - «What is meant?»: more near-miss meanings (modals, Herr/Frau, times, places, colours...), the closest first. Lines with one: 21% -> 42%. - Cognates («gah», gehen) are asked from German with real course words as the other options; the rest by meaning, with distractors as alike as the answer (resembles: letters and consonant skeleton). - Options, banks and columns are laid out from a seed per sitting and the question id (present.ts), one helper for practice and the runs. - hardness.ts counts giveaways, confusable options and odds; a cognate asked from Zurich rates easier than the same word asked from German. - New kind «Find the German word» (spot): a course line with one word in Standard German, tap the word; the answer shows the Zurich word and the line. Strings in all seven languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: «Tschüss» is never offered as the certainly-wrong German word Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Exercises: read before moving on, and tap the words instead of typing The moment after an answer (exercises/chrome.tsx, useMoveOn): - a right answer shows the whole line where the question showed part of it, its meaning and the reason, then moves on after a beat as long as that text: 1.3 s + 45 ms a character, at most 6 s (move-on.ts); - a touch, wheel or focus on the session screen, or «Anhalten» beside «Weiter», holds it: the bar fades and the control reads «Angehalten» in the same box, so nothing moves; Enter or Space continues; - a wrong answer or a skip never moves on; - «Von selbst weiter: An | Aus» in the sitting's sheet, remembered on the device (heidi.practice.move-on.v1, person-level, on the privacy page); - reduced motion: no draining bar, the seconds are counted on «Weiter». The situation run's follow steps use the same hook and controls, and the run now has the same sheet behind the sliders. Tap instead of type (tiles.ts, exercises/tiles.tsx, answer-how.tsx): - every translate question can be built from tiles: its own words plus two or three real course words from the same scene, topic or word group, look-alikes first; marked against the course line (case and punctuation ignored), typed answers stay self-marked; - the build kind's tile UI is now TileAnswer, shared by both; - the habit is «Wählen | Antippen | Tippen»; old stored values stay valid; on a typed question it is that question's switch, and «Wählen» is not offered where there is no meaning question; - the run's «Lieber schreiben» link is the same «Wörter antippen | Tippen» switch, above the question; - tiles are recorded as mode "tap": not typed, not scheduled as recalled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Heidi Plus: a subscription that renews, monthly or yearly, with an intro price The one-time pass becomes «Heidi Plus»: a monthly plan that renews until cancelled, a yearly one at a saving, and an optional lower price for the first months, through Stripe (paykit 0.6 `stripeBilling`). The pass stays, offered below as «Lieber einmal zahlen?». - /plans is paykit's PlanPicker: Free | Heidi Plus (recommended) | Eigener KI-Schlüssel | Organisationen. The own-key tier is CHF 0 to Heidi, names the providers from ai-kit's BYOK_VENDORS and leads to /settings#model; the old own-key section is gone. Without prices, Plus is «Bald verfügbar» with the notify form. - A review step before Stripe (paykit's PlanReview): summary, notes, the account, the renewal box that must be ticked (Heidi has no terms page, so no terms box), the practice reminders as an optional box, and an active pass or subscription shown with «Abo verwalten» instead of a second one. - Prices only from HEIDI_PLUS_MONTH_CHF, HEIDI_PLUS_YEAR_CHF, HEIDI_PLUS_INTRO_CHF, HEIDI_PLUS_INTRO_MONTHS; the proposal is on /owner/payments and in .env.example, marked as one. - Stripe webhook: subscription events verified, handled once by event id (pay_events), the record in pay_subscriptions (migration 0034). A paid period moves the same entitlements row a pass uses, never back. - Settings: «Abo verwalten» opens Stripe's portal, with the status line (renews / ends / payment failed / ended). - Deleting the account cancels the subscription at Stripe first. - Privacy: the passPayments flow names the subscription, its tables and the email Stripe receives; the flows have anchors. - Strings in all seven languages. package.json asks for @bitbaum/paykit ^0.6.0; the lockfile follows once it is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Play together: «Find the German word» can be played; the said-too list lives in the packs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Practice: «Was willst du üben?» on /practice and the personal page; «Bis es sitzt» drills - The builder: what (everything, words, forms and grammar, a situation, an area, my weak spots), which (a searchable list, each row with the learner's state: not started, in progress, strong), how (quick round, Nail it, test; hardest first). It opens a URL of the sitting contract. - A «Nail it» sitting shows «12 of 20 nailed», says when the drill took only the hardest 30, and ends with a short summary; it resumes where it was left. - A situation run shows a line answered right today as a line to read. - «Bis es sitzt üben» on every situation page and grammar topic page with questions. - Strings in all seven dictionaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * «Which one is Zurich German?»: a wrong article names its noun; a form Zurich speakers use is never planted as wrong (tested) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Session bar: progress keeps its room, repeats shorten below 380px; audit measures the new answer moment The top bar's progress bar keeps a minimum width, and the «+1 repeat» note collapses to «+1 ↻» on the narrowest phones so 2/8 never pushes it off. The responsive audit gains ONLY= to narrow to changed pages, measures a held run step, measures a typed question as tiles before switching to typing, and answers the meaning gate (after hydration) where a language shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Situation run: the reason for each wrong line is shown once, with the article's noun Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Situation run: what a step asks is the sitting's own small line above the question (one shape with practice) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Changelog 2026-12-03: the exercise revamp Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Plan test: new questions per sitting checked over 40 learners, not one lucky seed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * /practice: one picker — the quick round's mix sits under «Was willst du üben?» without a second «what / test» row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Changelog 2026-12-03: plans (Free, Heidi Plus, own AI key, Organisations) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Lockfile: @bitbaum/paykit 0.6.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Heidi: «Was du kannst» answers next step, standing per area, what to do inside The knowledge map (unlabelled dots in rows, lines that meant nothing) is replaced by a page that answers, in order: one next step with its reason and one black button; per area a segmented bar of lines that sit, wobble and were never asked, with untouched areas collapsed to one line; inside an area every situation, topic or word group with its bar, status word and the action that fits it, sorted by what to do next. The step comes from a pure planOf (lib/domain/progress/plan.ts) that the personal page's card uses too, so the two never disagree. The map layout module, its tests and the weak-spots card are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: one standard for practice, runs and play Every question now passes the same five rules, written down in code in lib/domain/questions/standard.ts and checked by tests: 1. Ask only what a German reader doesn't get for free. A line that can be read straight off its German is read, not asked. «Chasch mer schnäll hälfe?» is now a line to read. 2. Wrong options are the same kind of thing as the answer. «mir» is offered with «wir», «uns» and «euch», never with «nirgends» or «übermorgen». The reading shelf no longer fills a short list with words of another kind. 3. A question must not be solvable without knowing Zurich German. Seven solvers that don't know the language (look-alike, longest, odd one out and others) may beat chance by at most 15 points per kind; balance() drops the questions that let them do better. 4. Feedback gives the rule, other lines with the same word, and a line where the word means something else. A later line of the run asks the word again (transfer). 5. Hardness is real: it is measured from the options. Homographs: a word whose meaning depends on the line is asked only when the line's German proves the taught meaning (provesMeaning). The «wo» cue ", wo" matched «Ah, wo denn?», where «wo» is the question word. That cue is gone, and comma cues now end at a word boundary. This removes 5 false proofs, including «wohin». The sourced Einsiedeln text now asks «cho». Close is not wrong: choosing a look-alike that differs only by a form said in another Swiss region («geit», Bern) gets «Fast», with where that form is said. It is scheduled as FSRS «hard», not as a lapse. One rule, lookalikeVerdict, decides this. A Standard German word stays wrong. Questions are now chosen from ASKED_ITEMS, the items that meet the standard. PACK_ITEMS still holds everything, so stored progress, glosses and reminders keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r * Questions: rules that are rules, fair German-first words, spot, transfer - A rule line appears only where there is a rule. The line «Merk es dir im Satz…» shown under every plain word is gone (ruleOf in questions/standard.ts). «mir» and «si» now carry how their line tells the two meanings apart (homograph-role, homograph-modal), with examples taken from course lines, in all seven languages. The pack names which rule applies to which homograph. - Asked from German: wrong options come from the word's own group, are never rude, and look as much like the German word as the answer does. If the answer is the only word that looks like the German one, the word is not asked. Balance no longer keeps a kind's last question when a solver wins it. - Spot never plants a mere spelling of the Zurich word («bestelle» for «bstelle», «gehört» for «ghört»). It never plants a lone word ending in «-en» either, since that can be found by its ending alone. The word is quoted without its punctuation. - Transfer: a run asks a word at most twice. A homograph's second question goes to a later line that uses the other meaning, when the part has one («bi mir» after «Mir händ…»). A contrast question is never the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r --------- Co-authored-by: Claude <noreply@anthropic.com>
19 KiB
Passes: Bitcoin to Heidi's OrangeCat account
A pass is one payment for a fixed number of days: 30 or 365. Bitcoin has no recurring charge, so nothing renews by itself; paying again before a pass runs out adds the days to the end. A pass changes three things, all per person and all counted on the server (see "Usage caps" below): the daily chat count, the server voice (Gemini) and the dictation allowance (Groq). And a pass holder's chat takes its own route, which is the free chain until the deployment points it elsewhere (see "The model a pass buys").
A pass starts in one of two ways: a Bitcoin invoice paid here, or a code the owner issued (see "Pass codes" below). The first needs the master switch on and a price; the second needs only a database and accounts. Organisations stay on manual codes: there is no checkout and no price for an organisation.
The money goes from the learner's wallet to the wallet behind Heidi's OrangeCat entity. Heidi never holds it and stores no wallet address.
What is in the package and what is here
@bitbaum/paykit owns everything that moves or checks money: the provider
interface, the OrangeCat provider (invoice, status, webhook signature), the
entitlement arithmetic and applySettlement, which grants once per payment.
This app owns configuration, storage and words:
| Where | What |
|---|---|
lib/config/payments.ts |
which passes exist, their prices and the payee, all from the environment |
lib/pay/store.ts |
pay_checkouts and entitlements on Postgres (drizzle/0014_passes.sql) |
lib/pay/service.ts |
joins the package to the config and the database |
app/api/pay/checkout |
POST {plan} creates an invoice; GET /<id> reads its state and settles when paid |
app/api/pay/webhook |
receives OrangeCat's payment.settled |
app/[locale]/pass |
the field that takes a pass code; when a price is set, the passes and the link to OrangeCat; while selling is off, one line that says so; /pass/checkout/<id> shows the invoice |
lib/pay/codes.ts |
pass codes: making one, keeping its hash, granting it once (drizzle/0020_pass_codes.sql) |
app/api/pay/redeem |
POST {code} redeems a code for the signed-in person |
app/api/owner/pass-codes |
owner only: GET what was issued and how much is used, POST {count, days, label} issues codes |
app/[locale]/owner/pass-codes |
the owner's form for the same, since a phone cannot send a POST from its address bar |
lib/domain/model/pass-model.ts |
the model a pass buys, as one paid row in front of the free chain |
lib/config/sales.ts |
the master switch HEIDI_SALES_ENABLED, off by default |
lib/config/caps.ts, lib/domain/usage-meter.ts |
the usage caps and what a person has used of a pass block (drizzle/0031_usage_meter.sql) |
lib/domain/dictation-cap.ts, lib/voice/voice-cap.ts |
the gates in front of Whisper and the Gemini voice |
app/api/pay/webhook/stripe |
Stripe's checkout.session.completed, on its own path and secret |
lib/pay/readiness.ts, app/[locale]/owner/payments |
the owner's checklist: each rail, the master switch, the caps, what is set, what is missing |
How a payment runs
- A signed-in learner presses a pass's button on
/plans. Heidi asks OrangeCat for an invoice paying the configured entity (through paykit: the keyedPOST /api/v1/payments, or the account-lessPOST /api/v1/payments/public) and stores the checkout: OrangeCat'spayment.settlednames only the payment, so the stored row is the only link back to the learner. /pass/checkout/<id>shows the invoice as a QR code and as a wallet link.- Settlement arrives two ways, and both end in the same
applySettlement: OrangeCat calls the webhook, and the open checkout page pollsGET /api/pay/checkout/<id>every four seconds, which asks OrangeCat. The first to arrive grants the days; the other is a duplicate.
A payment made on OrangeCat's own page for the entity reaches the same wallet but starts no pass, because nothing links it to a Heidi account. The webhook acknowledges it and does nothing.
Switching it on
Two things switch selling on, and both are needed: HEIDI_SALES_ENABLED=1
and at least one price. The switch is off by default and beats any price.
While either is missing, /plans shows one line, "Passes are not on sale here
yet", with no payment and no error; POST /api/pay/checkout answers 503 and no
invoice is created, even with prices set. A checkout created while selling was
on still settles after it is switched off (the webhook and the page's poll never
read the switch): the buyer paid and the days are owed.
No price is written in this repository. Prices come from
HEIDI_PASS_30_SATS and HEIDI_PASS_365_SATS, in whole sats, decided by the
owner. (The CFO's suggestion of CHF 9 for 30 days and CHF 79 for a year is not
confirmed; convert it to sats at the day's rate when it is.)
The button on /plans that opens Heidi's public OrangeCat page needs no
configuration, and is shown only together with the passes: a payment there
grants nothing in Heidi.
The values go in the app's .env on the box, beside the others
(.env.example lists them):
| Name | Value | Needed |
|---|---|---|
HEIDI_SALES_ENABLED |
1 to sell; unset or anything else keeps every sale off |
yes: the master switch |
HEIDI_PASS_30_SATS |
price of 30 days, in whole sats | yes, with the switch |
HEIDI_PASS_365_SATS |
price of 365 days, in whole sats | no |
ORANGECAT_API_KEY |
an ock_… integration key with the scopes payments.write and payments.read |
no, see below |
ORANGECAT_WEBHOOK_SECRET |
the ock_whk_… secret of the webhook endpoint |
no, but without it only the open checkout page settles a payment |
ORANGECAT_PAY_ENTITY_ID |
the OrangeCat entity that is paid | no: Heidi's project when unset |
ORANGECAT_PAY_ENTITY_TYPE |
its kind | no: project when unset |
On OrangeCat, signed in as the account that owns the paid entity, at
https://orangecat.ch/settings/integrations:
- Webhook. Add an endpoint for the account's personal actor with the URL
https://heidi.orangecat.ch/api/pay/webhookand the eventpayment.settled. The secret is shown once; it isORANGECAT_WEBHOOK_SECRET. - Integration key. Mint a key with
payments.writeandpayments.read; it isORANGECAT_API_KEY.
About the key: OrangeCat records a key's owner as the buyer of a keyed payment and refuses an owner paying their own entity ("You cannot pay for your own entity"). A key minted by the account that owns Heidi's project is that case. paykit then asks for the invoice through OrangeCat's account-less call instead, so the learner still gets one; the money and the webhook are the same either way. A key from a different OrangeCat account is used as it is.
The wallet behind the entity has to be one OrangeCat can watch settle: wallet-connect (NWC), a Lightning address whose provider supports LUD-21 verification, or an on-chain address. With a bare Lightning address OrangeCat cannot see the payment arrive, and neither the webhook nor the poll will ever report it paid.
Paying in francs: card, TWINT, wallets
Off, and meant to stay off until the owner decides otherwise. A second rail beside Bitcoin, through a Stripe account:
the buyer pays on Stripe's own page, so no card number reaches Heidi, and
Stripe is told nothing about the Heidi account (sendReference: false).
To switch it on:
- Open a Stripe account for whoever receives the money, and finish its verification.
- In Stripe, Settings → Payments → Payment methods: switch on TWINT and any other method. Heidi does not choose: Stripe offers what is on there for a price in CHF. TWINT through Stripe is CHF only and at most 5000.00 CHF a payment.
- On the server:
STRIPE_SECRET_KEYandHEIDI_PASS_30_CHF(andHEIDI_PASS_365_CHFif a year is sold). Prices in francs:12or12.50. - In Stripe, Developers → Webhooks: add
https://<host>/api/pay/webhook/stripeforcheckout.session.completedandcheckout.session.async_payment_succeeded, and put itswhsec_…secret inSTRIPE_WEBHOOK_SECRET. Without it a pass still starts, when the buyer is back on Heidi's checkout page.
/owner/payments shows, for the owner only, which of these are set (names,
never values) and the addresses to paste.
Stripe stays off for now: no STRIPE_SECRET_KEY is set, so the rail does not
exist. Individuals pay in Bitcoin. The provider is stripeProvider from
@bitbaum/paykit/stripe (paykit 0.5); the local copy is gone.
Each rail is on or off by itself. /plans shows one card per pass, with a
price and a button for each rail that sells it, francs first.
Heidi Plus: the subscription
A monthly plan that renews until cancelled, a yearly one, and an optional
lower price for the first months, through the same Stripe account and the
same webhook endpoint as the franc pass. Off until STRIPE_SECRET_KEY,
STRIPE_WEBHOOK_SECRET, HEIDI_SALES_ENABLED=1 and HEIDI_PLUS_MONTH_CHF or
HEIDI_PLUS_YEAR_CHF are set (HEIDI_PLUS_INTRO_CHF and
HEIDI_PLUS_INTRO_MONTHS for the intro). No price is in the code; the
proposal is on /owner/payments and in .env.example, marked as one.
- What it gives is what a pass gives: the same
entitlementsrow, moved to the end of each paid period and never back (lib/pay/plus.ts). - The way in is the plans, sign-up if needed, the review step
(
?review=month|year, paykit'sPlanReview: the renewal box must be ticked, the practice reminders are an optional box, an active pass or subscription is shown instead of a second one), then Stripe's page. - Stripe's side is
stripeBillingfrom@bitbaum/paykit/stripe(0.6): Checkout inmode=subscription, the intro as a repeating coupon, the customer portal for «Abo verwalten» in Settings, and the webhook eventsinvoice.paid,invoice.payment_failedandcustomer.subscription.created/.updated/.deleted, each handled once (pay_events). The record ispay_subscriptions. - Deleting the account cancels the subscription at Stripe first.
Usage caps
Required before any sale: a pass that bought unlimited use of something that
bills per call would lose money on every sale. Every ceiling is per signed-in
person, free and pass alike, counted on the server in Postgres
(rate_limits for the daily counts, usage_meter for the pass-period counts),
so a restart or a deploy gives nobody a fresh allowance. Defaults and the
reading of every value are in lib/config/caps.ts.
| Name | What | Default |
|---|---|---|
HEIDI_CAP_FREE_DAILY |
questions a day without a pass; chat and speaking judgements share this one count. 0 switches it off. Old name still read: HEIDI_FREE_TURNS_PER_DAY |
100 |
HEIDI_CAP_PASS_DAILY |
the same with a pass. 0 switches it off |
60 |
HEIDI_CAP_PASS_VOICE_SECONDS |
seconds of new server voice (Gemini TTS) per 30-day block of a pass | 1200 |
HEIDI_CAP_PASS_DICTATION |
dictation clips (Groq Whisper) per 30-day block of a pass | 200 |
HEIDI_CAP_FREE_DICTATION_DAILY |
dictation clips a day without a pass | 10 |
- The pass daily default is 60, below the free 100, on purpose: a pass
holder is on their own route (below), which is meant to become a paid one,
so the default is what that route can carry. While the pass route is still
the free chain, set
HEIDI_CAP_PASS_DAILY=300(three times the free number, what a pass used to mean). If it is unset butHEIDI_FREE_TURNS_PER_DAYis set, the pass gets that value times three (PASS_CHAT_MULTIPLIER). - Server voice is a pass holder's. Somebody without a pass is read to by
their browser's own voice, which is free (
/api/speakanswers 403 withfallback: "browser"andGETsays it is not available). Only new audio counts, by its length; a line served from the cache is free, even when the period's voice is spent. The check comes before the synthesis and the charge after it, so a clip that crosses the line is delivered and the next is refused (429, again withfallback: "browser": the reader goes on with the browser voice). - Periods. A pass's blocks are 30 days counted back from its end. A 365-day pass therefore gets the voice and dictation numbers in each 30-day block, which is the allowance pro rata. Paying again before the pass runs out keeps the block; a pass that lapsed and is bought afresh starts new ones.
- Dictation is counted in both routes that send audio to Whisper
(
/api/transcribe,/api/speaking/transcribe). A refusal is 429 withlimit: "dictation". - What the person sees. A spent daily count is the chat's existing "Today's requests are used up. Tomorrow you can ask again." with one link. Voice falls back to the browser's. A spent dictation allowance is a 429 the microphone reports in its usual words.
- An own key does not count at all: those calls are paid on the learner's account.
- Paid OpenRouter stays off:
AI_PAID_DISABLEDandHEIDI_AI_PAID_OKare untouched, and no paid key was added.
Pass codes
For a pass that was paid for where Heidi cannot see it: an organisation paying
in francs for its people, or a pass given away. The owner issues one code per
person; each person redeems theirs on /plans, signed in. A code grants its
days once, through the same extendEntitlement of @bitbaum/paykit a settled
payment goes through, so codes and payments add up.
- Name the owner in the app's
.env(OWNER_EMAILSorOWNER_ACTOR_IDS, the same gate as/api/owner/numbers). - Signed in as the owner, open
/owner/pass-codes. Say who the codes are for, how many, and how many days each. Up to 200 codes and 366 days a time. - The codes are shown once. Copy them and send them on. The database keeps only each code's SHA-256 and its last four characters.
- The same page lists what was issued, by label, and how many are used.
A code is sixteen characters without I, L, O and U, written in four groups. What somebody types is read forgivingly: case, spaces and dashes do not matter. Redeeming is limited to ten attempts in ten minutes per account.
Nothing here sets a price. What an organisation pays, and how, is agreed with it directly; the page for organisations says so and offers a mail link.
The model a pass buys
THE PASS ROUTE. A pass holder's chat (/api/chat, saved conversations,
reading, speaking judgements) takes its own chain, chainFor(true) in
lib/domain/model/chain.ts. With nothing below set it is the free chain, link
for link. To move pass holders off the shared free pool without a release:
HEIDI_PASS_GROQ_API_KEY is a Groq key used only for them (the day it is a
paid one; the link is then groq-pass, so its rate-limit bookkeeping is not
shared with the free key's), and HEIDI_PASS_GROQ_MODELS names their models
in order. The same two shapes exist for the other vendors of the free chain
(HEIDI_PASS_<VENDOR>_API_KEY, _MODELS). No paid key is added by this repository.
On top of that, off until configured: HEIDI_PASS_MODELS names one or more model ids at
OpenRouter, in order; they use the deployment's OPENROUTER_API_KEY. A pass
holder's turn tries them first and falls back to the free chain. Somebody who
brought their own key still gets their own model.
The row is marked paid, so every rule of @bitbaum/ai-kit's spend module
applies and none is restated here: it is in the chain only with
AI_PAID_DISABLED=0 and HEIDI_AI_PAID_OK=1, and a call is made only inside
Heidi's daily paid cap (HEIDI_DAILY_PAID_CALLS, _INPUT_TOKENS,
_OUTPUT_TOKENS) and the fleet's. A call the rules refuse is not made and the
free chain answers.
/plans promises the stronger model only while all of that is set. No model
id is written in this repository.
Read-aloud from the server
/api/speak (lib/voice/server-tts.ts) speaks with Google's Gemini TTS on
GEMINI_API_KEY, which bills per call. It is a paid call like the pass model:
refused unless AI_PAID_DISABLED=0 and HEIDI_AI_PAID_OK=1 (the kill switch
is on when unset), and counted in @bitbaum/ai-kit's spend ledger and usage
log (feature read-aloud) against HEIDI_DAILY_PAID_CALLS, _INPUT_TOKENS,
_OUTPUT_TOKENS and the fleet's caps. A refused or capped call is never
fetched: GET /api/speak says available: false, POST answers 503 with
fallback: "browser", and the page reads with the browser's own voice, with no
error shown. Lines already spoken are served from an in-memory cache and
cost nothing. The existing 40 per 5 minutes rate limit still applies. A
per-user per-period voice cap is not built yet.
Trying it without money
lib/pay/codes.test.ts issues and redeems against the real migrations,
including one code redeemed three times at once.
lib/domain/model/pass-model.test.ts asks ai-kit itself whether a pass link
would be let through.
lib/pay/sales.test.ts covers the master switch: off by default, off with
prices set, no invoice created, and an invoice made while on still settling
when off. lib/domain/usage-caps.test.ts covers the caps against the real
migrations: the daily count shared by chat and speaking, the pass-period meter,
dictation and voice.
lib/pay/store.test.ts settles against the real migrations on an in-process
Postgres, including the same payment reported three times at once.
app/api/pay/webhook/route.test.ts covers the off state and forged calls. The
package's own tests cover the signature and the OrangeCat request shapes.
The plans page (/plans)
/plans is where Heidi Plus and a pass are bought and /pass only redirects
to it (the checkout stays under /pass/checkout/<id>: Stripe and open invoices
hold that address). The screen is @bitbaum/paykit/react's PlanPicker: a
switch Free | Heidi Plus (recommended, chosen first) | Your own key |
Organisations. Your own key is CHF 0 to Heidi and leads to
/settings#model; its provider names come from @bitbaum/ai-kit/byok
(BYOK_VENDORS). Below it, «Rather pay once?» offers the one-time pass on
whichever rail has a price.
- Nothing is typed into the page. The questions a day come from
lib/config/caps.ts; the prices fromHEIDI_PASS_30_CHF/HEIDI_PASS_365_CHF(lib/pay/plans.ts), paid in Bitcoin on the rail that has a sats price, else by card; Heidi's own voice and the stronger model only where configured (lib/pay/plan-cards.ts). - The saving badge on the year is
1 - year / (12 × month)in whole percent, shown only when both periods are priced in the same currency. - Sales off or no price: no price is shown anywhere; the pass button is
«Coming soon, get notified», which stores the address in
pass_interest(/api/plans/notify, rate limited, deleted with the account whose address it is, no third party). - Counts (no tracker):
go:plans:view,go:plans:signup,go:plans:checkout,go:plans:paidinusage_counts. - The way to a pass is three screens: the plans, sign-up on the same page
(back to
/plans?buy=<period>, which starts the checkout), the invoice. A paid pass opens the chat with a confirmation.