mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:27:37 +01:00
feat/shared-knowledge-map
28
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5199fff1dd |
feat(orangecat): a browser of its own for every bot; a picture a thread can show (#1697)
* feat(orangecat): a browser of its own for every bot; a picture a thread can show Cat Bot's computer use (OrangeCat docs/PARITY.md, plan step 2), Loki's half. POST /api/orangecat/browser, on the signed rail for the linked account, takes one step in the bot's browser: open, click, type, press, scroll, back, look, close. Every answer carries what the page now shows: address, title, the readable text, what can be clicked or typed into (numbered, so a model that cannot see pictures can still drive), and a picture. - lib/bot-browser: one session per (account, bot) in Loki's own Chromium, the whole context kept out of the private network, cookies kept between sessions in a file only this server reads. Closed after three idle minutes, twenty at the outside; two at once on the box, and a session in use is never closed for another. The page reader is sent as a string: a bundler that names inner functions made it read every page as empty. - lib/bot-browser-rules: pure. A bot never types a password, a sign-in code or a card; the step stops and says the owner does that. - lib/bot-shots + GET /api/orangecat/shot/[token]: a thread shows a picture only from a web address, so pictures are kept a week under a name nobody can guess. The site walk now answers a failed page with that address instead of bytes. - page-picture exports its private-network guard and its browser lookup, so there is still one of each. scripts/test/bot-browser.ts (11), site-walk.ts (13). Driven for real from a sandbox browser against orangecat.ch: open, numbered elements, click by label, scroll, back, a password field refused, a private address refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * docs(handoff): Cat Bot parity with Grok Bot, the running checkpoint Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
198d77e523 |
feat(auth): an agent's token opens a browser session, with the token's power and no more (#1679)
* feat(auth): an agent's token opens a browser session, with the token's power and no more A browser cannot send a Bearer header on a page load, so a Viewer seat with a ck_ token was sent to sign-in from /projects, /terminal, the workbench, history and feedback. - POST /api/token-session (Bearer ck_ only) mints a link that opens once, within two minutes. The link carries a random code; the server keeps its SHA-256 (token_sessions, migration 0138). The token is never in the link. - GET /api/auth/loki/token-session (an AccountKit plugin endpoint) opens it: a session for the token's user that ends after an hour, is never refreshed, and is recorded as the token's before its cookie is set. - Such a session reads like the user (pages, GET on the API) and writes only where a token is accepted: the proxy marks its writes and person-only routes read them as signed out. It never reaches tokens, a shell, the password, linked sign-ins or export, nor AccountKit's passkey and second factor endpoints. Revoking or expiring the token signs it out. Tests: scripts/test/token-session.ts (landing paths, the refused routes, the middleware decision, the wiring); scripts/test/token-session-db.ts in test:db (single use, expiry, revoked and expired tokens, hash-only storage). * style(drizzle): format the 0138 snapshot and journal |
||
|
|
b912cb4d91 |
feat(notify): every person chooses what reaches their own Telegram (#1543)
* feat(notify): every person chooses what reaches their own Telegram Loki is multi-tenant, but Telegram was one hard-wired chat (the operator's) on a bot whose incoming messages belong to OpenClaw. Now each account sets it up in Settings → Notifications → Telegram: - Connect Telegram opens Loki's notification bot with a one-time code; pressing Start links that chat (POST /api/telegram/webhook, verified by Telegram's secret-token header). No chat ids, nothing to type. /stop or blocking the bot unlinks. The webhook registers itself on first use. - Six kinds of message (config/notify-categories.ts), each on/off per person; "servers" is shown to the operator only. - Every app sender now goes through the gateway as that person (lib/notify/person.ts → deliverNotice): approvals, feedback, fixes, runs, studio, build requests, sign-ups, autopilot, site live, gateway down. The gateway applies the person's choices, sends to their own linked chat, and falls back to the operator's old chat for the operator only. scripts/test/one-telegram-door.ts fails the build on a direct send. - Buttons Loki composes from its own records (a customer's own site) are trusted; links from outside still meet the host allowlist. - Migration 0132 adds the link and choices to notification_preferences. - New env: TELEGRAM_NOTIFY_BOT_TOKEN, TELEGRAM_NOTIFY_BOT_USERNAME (checked as a pair at boot). Until set, Settings says Telegram is not set up and the operator's existing chat keeps working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * fix(openclaw): the heartbeat follows the same one-tap contract The box audit (openclaw-day-plan run 3) found the sender of "Gateway was not running. Restarted automatically. All good now.": the OpenClaw workspace's tools/health-guardian.sh, not in any repo, whose status lines the agent relays. The contract now goes on HEARTBEAT.md too (between markers, backed up, idempotent), and the installer prints how health-guardian is started and its speaking lines, numbers and secrets redacted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * style(drizzle): format the generated 0132 snapshot and journal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
59cd3e7b10 |
feat(terminal): a plain shell on the builder, operator-only behind the PIN (#1449)
* feat(terminal): a plain shell on the builder, operator-only behind the PIN Sessions -> Plain shell opens a real bash login shell in a PTY the builder owns: no project, no agent, no inject wrapper. It is one more kind of session on the existing transport (open_shell command, peek-stream, the rawkey lane, tab-memory), not a second terminal. Security: operator account only (browser session, never a bearer token); a PIN must be set and the shell's own unlock (10 min idle, 60 max) entered; opens rate-limited and capped at 3 per builder; no queued command except open/close/peek may name a shell tab (queue, validator and injectPty); tenant and sealed builders never offer one; shell environment carries no engine keys. Every open/close/denied/unlock is on an append-only audit trail with no content. Threat model: docs/architecture/plain-shell.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * test(terminal): keep the repo's gates true for the plain shell Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * docs(plain-shell): name where provision-service.py lives Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
105f75ef88 |
feat(chat): the answer feedback loop — thumbs, transcript export, nightly review (#1417)
chatkit 0.14 carries the contract both ways; this is Loki's side of the
fleet chat-review loop (docs/architecture/chat-review.md).
- Thumbs under every Loki answer: chatkit's AnswerActions with onFeedback
replaces the hand-rolled "Bad answer" button and ReportAnswer form. The
thumb goes to POST /api/chat/feedback (new chat_feedback table, migration
0128); a thumb down is still filed as a report in Loki's own inbox through
the same plumbing the old button used (lib/loki/answer-report-file.ts).
The terminal's Loki rail and the prompt Run sheet pass onFeedback to
ChatThread.
- GET /api/chat/review-export: Loki's day of conversations as
ChatTranscript[] behind the shared CHAT_REVIEW_TOKEN (bearer, constant
time, 503 while unset), scope derived from Loki's own prompt
(lokiChatScope). Never a temporary chat; no names or user ids.
- src/config/chat-review.ts (SSOT): the four products, their export URLs
and repos, the night's budgets.
- Cron review-chats at 03:40: fetch each product's export, then start one
agent run on the product's Loki project (found by gitUrl, as its owner)
carrying chatkit's CHAT_REVIEW_INSTRUCTION + reviewPrompt for every
conversation and the door to file findings through (widget token + agent
pass, Origin = the product). The route calls no model: no box timer may
spend the free AI tier (no-free-background-ai), so the judge is the
project's agent, the way AI review reads a live page. Outcome per product
under debug_logs crons/review-chats.
- share-chat-review-token.yml: generate the token on the box into Loki's
env, copy it to heidi, orangecat, substrata when absent, redeploy all four;
the value is never printed.
- .env.example, docs/architecture/chat-review.md, link from the widget doc.
Verified: pnpm run verify green through test:unit (540 files) and the
remaining gates; test:ops fails only on .env ownership in the root sandbox.
Thumbs rendered at 390px in headless Chromium: 44px targets, no sideways
scroll, the app receives {messageId, verdict, reason} on Send.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
8e8ffa0b82 |
feat(change): see your own site changed in under a minute, before any account (#1328)
A stranger on /change now taps "Show it on my site" and gets their live homepage, photographed by Loki's browser, then the same spot with what they asked for drawn on it, compared with a slider. No account, no repository, no build: the widget's "Show me" edits (same closed vocabulary, same sanitising) applied in a headless page on the server, never in their site. - widget/instant-page.ts bundles the widget's outline + applyPreview for that page (public/instant-page.js, built with the widget). It is evaluated, not injected, so a site's own CSP cannot block it. - page-picture: withLivePage shares the picture's queue, private-network guard and patience with a caller that photographs more than once. - POST /api/site-consult/preview streams NDJSON: their site the moment it exists (~5 s), then before/after. The address must pass the consultation first. It spends the owner's AI on purpose, behind a per-visitor and an everyone-per-hour limit and the owner's daily budget. - The preview prompt drops its "was just changed for" line when nothing was. Claude-Session: https://claude.ai/code/session_01HyfPCAeTFi2sjpVY44Y1JJ Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
fd5164981b |
feat(previews): private tiles get real pictures; a preview can move to its right name (#1298)
Private tiles on bitbaum.orangecat.ch/private/ now render through the same tile as the public work grid (bitbaum PR #136). This adds the picture they show: GET /api/fleet/private/shot/<slug>, owner only, a 1280x800 picture of the project's site (a preview through Loki's own route with the owner's cookie, its widget left out), kept for twelve hours. A site behind its own access-code page is not photographed, so its tile is text, not a code page. takePagePicture takes a viewport; wider than a phone is a desktop browser. The owner check is one helper (studioOwnerCheck) shared by the list and its pictures. A preview can now move: POST /api/previews/<slug>/move { to, name } attaches the new address, renames the folder, moves the project row and its name in one transaction (the folder moves back if that fails), points the widget at the new address and detaches the old one. Center SOM was born center-com-3 from a domain spelled in look-alike Latin letters; this is how it becomes tsentr-som. previews.yml gains `move` and `ask` (send the builder a change). A website preview's one line names the site by host ("center-com.ru"), not by its URL. Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
d079f972ab |
feat(widget): one widget everywhere, the state in every shape, record now and build later (#1295)
The owner (2026-10-18): the widget looked different on different pages
and sites, it should always be clear when Loki is watching, and they want
to record comments while it watches and implement them afterwards.
One widget, everywhere
- Loki's own site draws the same panel every customer site gets, not the
chatkit view (data-fc-chat="kit" stays an opt-in).
- No Loki page hides the launcher any more: the project workspace, the
agent conversation, inspection, the project loading state and an open
/loki conversation were "hidden" — no launcher, or the watch top bar
instead. They show the edge tab. feedback-widget-reach fails on any
page that hides it, in either the literal or the expression form;
only an open dialog and the sign-in wall may.
The state in every shape
- The owner's edge tab carries the same live dot and ring as the corner
pill, at full weight.
- The owner's pill sits in a bottom corner or becomes the tab; it no
longer climbs to the middle or top of the screen (Heidi at 390px).
Record now, build later
- After a voice note the owner's card leads with Save (then Fix it now,
Ask). Saved notes lead the status line ("Watching · 3 notes saved"),
and "Build all 3 saved notes" starts each as its own build, oldest
first: POST /api/widget/owner/build, rule in lib/feedback/saved-notes.ts.
- The owner check for the widget's owner routes is one helper,
lib/widget/owner-request.ts, used by owner/changes and owner/build.
Claude-Session: https://claude.ai/code/session_01E1qoQ9syUYXCRNbyrpqPGa
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
fae80d11f0 |
fix(fleet): private client work opens for the studio owner's session only (#1267)
The private list opened with the preview access code, but that code is the one each client is given for their own preview — so any client could read every other client's project. Now only the studio owner, signed in to Loki, gets it: bitbaum.orangecat.ch and loki.orangecat.ch are the same site, so the studio page's credentialed fetch carries the Loki session. /studio-private is the sign-in door that lands back on the studio page. Claude-Session: https://claude.ai/code/session_014d9r6dNr1vW789Q75hPcHF Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
77b21ab14e |
feat(fleet): private client projects behind the access code (#1223)
* feat(fleet): private client projects behind the access code - POST /api/fleet/private: client work without the client's consent, for the private area of bitbaum.orangecat.ch. Opened by the operator's preview code, then a signed expiring token; rate-limited; CORS for the studio origin only; no repo URLs. - Migration 0105: Sink Tattoo agreed to be shown; Wild Spirit (Anushka), Farmacia del Parco and AOZ are client work without consent; Vitareba -> Vita in display text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014d9r6dNr1vW789Q75hPcHF * style: format the 0105 snapshot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014d9r6dNr1vW789Q75hPcHF * test: list /api/fleet/private as code-gated public route Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014d9r6dNr1vW789Q75hPcHF --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
75a5831b43 | Add guided project reviews with shared browser evidence and pause controls (#1211) | ||
|
|
24c21ddf9c |
feat(ops): the cloud builder's liveness is public, deploys print its state, the queue says "offline" (#1158)
* feat(ops): the cloud builder's liveness is public, deploys print its state, the queue says "offline" The shared cloud builder was offline all night on 2026-10-11 → 12 and nothing outside a signed-in page said so: /api/health reported the web app green, the fleet sweep probes only HTTP codes, and the box journal is the one place the restart's outcome is written. The owner found out by trying to work from a second computer. - GET /api/health/builder: 200 while the owner's cloud builder is connected and heartbeating, 503 otherwise, with the last heartbeat and version. Public on purpose (one boolean, one timestamp, about a service the operator runs); registered in scripts/test/api-route-auth.ts. - install-watchdog.sh: the box watchdog now probes it, so a state flip alerts on Telegram like a dead site does. - deploy-hetzner.sh: before scheduling the runner restart, print `systemctl is-active loki-box-runner`, the last runner journal lines and the last drain lines into the CI log — the first place a person without an ssh session can read why the builder is down. Warn-only. - feedback run-step: a job on the cloud queue while the cloud builder is offline reads "Cloud builder offline — nothing starts until it reconnects", not "Watch shows why" (nothing showed why). Tests: feedback-run-step (+2), api-route-auth, watchdog-check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Xssd1hFZCUSxqjACjoVBB * fix(terminal): a private cloud builder reads "private", not "offline" Walking Loki as a brand-new account (2026-10-12): the Terminal's chip said "Cloud builder offline" beside an empty state that said "Cloud builder is private for this account". Presence is per account and a new account has none, so the chip mistook "not yours" for "down". The chip derivation moves into terminalHonesty() (one helper, the component stays under its 510-line ratchet) and names the gate first. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Xssd1hFZCUSxqjACjoVBB --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
8ca728a649 |
feat(studio): the private link comes back — mailed at intake, on a later address, and on request (#1091)
* feat(studio): the private link comes back — mailed at intake, on a later address, and on request A studio request's only credential is its private link; a closed tab was a lost request. Now the link is mailed to the address given at intake, or added later through a `set_contact` guest action; and `/api/studio-recover` hands the address fresh links to every open request under it (the old links die), answering identically whether or not the address is known. Keys are never stored or logged — email.ts records recipient and subject. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(demo): classify /api/studio-recover for the demo sandbox; the rotation rejects a demo owner Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
33eec2a538 |
feat(change): a free consultation before your site is rebuilt (#1076)
Naming your own website on /change used to go straight from an address to "Build a new version". Now the address alone opens a consultation first: Loki reads the live page the way a new visitor and Google do and says, in plain words, what is costing the owner visitors, what is worth fixing and what is already right, with the proof it saw and how Google shows them today. Every finding is a fix they keep or drop, and the build can be nothing more than "fix these" (plus their own words, now optional). - config/site-consult.ts: SSOT for the 19 checks: area, severity, owner copy, business reason, and the agent instruction a chosen fix becomes - lib/site-consult: SSRF-guarded single-page fetch (every redirect hop re-validated, DNS must be public; private-address guard ported from OrangeCat), a regex page reader, and pure rules. No model: the page is anonymous and must not spend the shared AI quota - POST /api/site-consult: public, rate-limited, cached, findings only - the build brief carries the chosen fixes as check ids, so the instruction an agent reads comes from config, never from the browser - typing just an address no longer lands in "what should change" Claude-Session: https://claude.ai/code/session_01X9tyuAD9YxN1gDFFUMAf6n Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
b58f514ef6 |
Add scoped Bitbaum studio portal and keep Loki self-service free (#995)
* feat: start request-scoped Bitbaum portal and studio review * test: prove scoped portal boundaries and restore studio record join * fix: support canonical studio origin and readable partner review * fix: support canonical studio origin and readable partner review |
||
|
|
a1cc13053c |
feat(mcp): message Loki from any AI app; the Telegram agent reads screenshots and videos (#965)
* feat(openclaw): the Telegram agent reads screenshots, photos and videos The Telegram agent is OpenClaw on bitbaum, and OpenClaw already describes inbound media before the chat model reads the turn — but on defaults that cut every description at 500 characters and read one attachment per message. A screenshot lost most of its text; an album was read as its first picture; video had a one-line "Describe the video." prompt. - scripts/openclaw/media-understanding.json: versioned tools.media.image and tools.media.video blocks (Gemini; screenshots transcribed verbatim, albums read whole; videos returned as transcript + visuals + claims + authenticity signs so the agent can argue about whether a clip holds up). tools.media.audio is deliberately untouched — voice notes already work. - scripts/openclaw/install-media-understanding.sh: the only way it reaches the box. Refuses without a Gemini key, writes through OpenClaw's own schema-validating `config set`, restarts the gateway, then proves an image (and, where ffmpeg exists, a video) is actually described. - scripts/test/openclaw-media-config.ts: pins the limits and the audio hands-off rule. Validated against openclaw@2026.4.23's schema locally. Not yet applied to the box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD * refactor(actions): share the decision and the enqueue report; let a turn be read-only Groundwork for the MCP server, so it calls the same code the chat seams do instead of a copy of it: - lib/actions/decide-action.ts: approve/reject one draft, lifted out of POST /api/actions/[id]/decision (which now calls it; wire shape unchanged). - lib/actions/enqueue-report.ts: what an enqueue outcome may truthfully be called (auto-approved / awaiting-approval / deduped), lifted out of POST /api/actions/propose (wire shape unchanged). - config/orangecat.ts: the OrangeCat origin and OAuth issuer in a DB-free module; Auth.js and the identity bridge read the issuer from here instead of each re-deriving it. - askLoki / runLokiTurn take `readOnly`: the tool loop drops its propose tools and the OpenClaw gateway fallback is skipped, so a caller granted conversation but not action cannot get Loki to act by asking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD * feat(mcp): a remote MCP server so AI apps can message Loki and have it act POST /api/mcp speaks MCP Streamable HTTP (stateless JSON-RPC 2.0; protocol 2025-11-25 / 2025-06-18 / 2025-03-26). claude.ai and ChatGPT connectors, Claude Code and Cursor can ask Loki, list the approval queue and projects, dispatch work, book appointments and decide queued actions. Auth: a ck_* agent token (both scopes), or an OrangeCat RS256 access token verified with node:crypto against the issuer's JWKS — iss, aud (must be the Loki resource URL, never a client id), exp. `sub` maps to the Loki user via orangecatActorId; an unlinked actor gets the sign-in step, not a 500. A missing or bad token is a 401 whose WWW-Authenticate points at the RFC 9728 metadata served at /.well-known/oauth-protected-resource(/api/mcp). Scopes loki.chat / loki.act and the tool map are SSOT in src/config/mcp.ts. Act tools go through injectPrompt, enqueueAction and decideAction — the functions the Telegram skill's routes call — so the approval queue gates them exactly as it does there. Both paths are excluded from the session middleware (proxy.ts, with the reason), registered in api-route-auth and the demo sandbox. Docs: docs/development/mcp.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD * fix(openclaw): match the installer's smoke output with a here-string, not a pipe printf | grep -q can report a miss on a match under pipefail (grep exits, the writer takes SIGPIPE). no-grep-q-in-a-pipe caught it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
bd1c6de353 |
feat(feedback): "Watch the fix" walkthrough; failed runs say why (#951)
What the owner hit on 2026-09-28, testing the loop from a phone:
- A shipped Farmhouse fix showed a green "Live · confirm" chip that was
itself a link to the site. It read as "watch it live" and landed on the
homepage with no idea where to look.
- A failed Petvity run printed the bare word "Retry" above a Retry button,
with the reason hidden.
Now:
- The badge is a status, never a link, and says "Shipped · confirm".
- "Check live" becomes "Watch the fix" (plus "What changed" -> the PR). It
opens the live page with a signed, 24h tour token in the fragment. The
widget, which already runs on every fleet site, reads an outline of the
page and plays a walkthrough from /api/widget/tour: a cursor glides to each
element, a caption says why, in-page controls are really clicked (anything
that navigates or submits is only pointed at). The script comes from the
model on the owner's AI budget, with a word-overlap fallback so it never
depends on a vendor.
- A step the tour cannot show says so ("Oops — ... flagged, it will be
investigated") and is filed as an AI-review item on the project, so a fix
that is not really live comes back into the loop.
- Failed rows get one plain sentence from the run error (quota, repository
access, timeout, no session, crash...) instead of "Retry".
Verified in headless Chromium at 390px against live farmhouse.orangecat.ch
with this bundle: scroll to the footer link, click it (page returns to top),
a missing step reports back, no horizontal overflow.
Claude-Session: https://claude.ai/code/session_01NJJp6XiUkeEVzjDaBmWjL3
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
814632e739 |
fix(orangecat): "Connected" meant a row existed, not that the link worked (#842)
Two halves of the same mistake — a stored value read as a state of the world. SETTINGS ASKED THE COLUMN, NOT ORANGECAT. #841 reported a link as broken when its refresh-token column was empty, which sounds like a health check and is not one: the column is only emptied once a refresh has actually been attempted and refused. Measured on prod the day it shipped — the link had been dead five days, the revoked token was still in the column, and the page said "Connected" in green. It now resolves the link the way every publish does; when OrangeCat refuses, that same call retires the credential and raises the alert on its way out. (Being signed INTO Loki with OrangeCat never repaired this: the session cookie and the stored OAuth token set are different things, which is how a person can be looking at a Loki they logged into through OrangeCat while Loki cannot speak to OrangeCat at all.) ORANGECAT OFFERED TO BUILD WHAT IT ALREADY HAD. Its project page shows "Build it with Loki — one click: creates the project and puts an AI agent on it" to owners of projects that have been building here for months, because nothing on that page could tell the difference. The click was always safe — the handoff screen flags an already-linked project rather than creating a second one — but the card was addressing a stranger. `GET /api/orangecat/project-link` answers it, and answers the more valuable question too: a funder on a public project page had no way to reach the build record. Public without a signature, by construction rather than by intention: `linked: true` requires the Loki project to carry listed_publicly, so every field returned is already served at /fleet and /fleet/<slug>, and a project without that consent answers byte-identically to an id nobody has heard of. The consequence is stated rather than hidden: for an unlisted project OrangeCat keeps saying "Build it with Loki" — a worse label, not a broken path. verify: tsc, lint (0 errors), test:unit 246/246 — including api-route-auth, which refused the new route until its public stance was written down. Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
dbd6cbea8e |
refactor: one definition per concern — 12 duplicated helpers and clones consolidated (#729)
* refactor(ai): one reader for a model's JSON answer, not four that disagree
`extractJson` existed four times with three different algorithms, and which
copy a caller reached for decided which model quirks it survived:
digest-producer sliced first `{` to last `}` and never returned null;
frontier/digest handled code fences but not `</think>` leaks; dod-gate handled
`</think>` but not fences (its own comment called itself "a third hand-rolled
copy"); only frontier/propose did both. `parseModelJson` was a fifth and sixth
copy in project-brief and business-plan.
src/lib/ai/model-json.ts is the union of what each knew — strip reasoning,
unwrap a fence (unless the fence holds something else, like a shell snippet),
then scan for the first BALANCED object. The scan is now string-aware, which
fixes a bug every copy shared: a `}` inside a string value closed the object
early, so a DoD verdict whose gap text quoted a brace was silently read as
"met" — the judge's actual answer thrown away by its own reader. A
trailing-comma repair runs only after a strict parse has already failed, so it
can never change the reading of valid JSON.
scripts/test/model-json.ts pins the real shape each of the six callers feeds
it, plus the truncated reply that propose.ts's salvage path depends on
returning null.
Also: `sleep` was defined three times. src/lib/async.ts serves the app and
desktop (which resolves `@/*` to ../src). bridge keeps its own with a comment
saying why — its tsconfig pins `rootDir: "src"`, so nothing outside that
directory can compile into it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(api): one rate limiter and one JSON POST wrapper
The PIN route kept its own attempts Map beside lib/rate-limit — a second
limiter with the unbounded growth limitkit's bounded store exists to prevent,
and untested, which for a limiter is indistinguishable from one that always
returns true. It now calls checkRateLimit; the 5-per-minute-per-user VALUES
stay in the route, which is the part that is its business.
scripts/test/rate-limit.ts pins both halves. The second half is the one that
matters: getClientIp must read the LAST X-Forwarded-For hop. Six sibling repos
shipped the first-hop version, where the client writes the leftmost value — a
fresh invented hop per request is a fresh bucket per request, so no bucket ever
fills and the limiter cannot be tripped. limitkit 0.2.0 already counts from the
right; nothing else in this repo reads the header at all. The test writes the
bypass out so a regression fails loudly instead of silently.
terminal-transport's postJson was a sixth copy of the fetch boilerplate
lib/api/fetch already wraps. It now composes: the shared postJson plus the
swallow that keeps a dropped keystroke from becoming an unhandled rejection.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(agent-execution): one PTY executor, two ways to spawn
LocalPtyExecutor and SandboxExecutor differed in exactly two places — how the
PTY is born, and what terminate() cleans up afterwards. The other 74 lines
(workspace map, ring buffer, sequence numbers, replay on reconnect, the
running→idle timer, listener isolation) were copied between them, and had
already drifted in their comments. The next fix to the event stream would have
landed in one substrate and not the other, which is a bug you can only see by
flipping LOKI_EXECUTOR.
PtyExecutor owns that half. A backend implements `launch` and, if it owns
anything outside the PTY, `afterTerminate` — SandboxExecutor's docker rm -f is
the only instance. "Both backends behave identically" is now a fact about the
code rather than a claim about two files.
Behaviour is unchanged: both existing suites (test:executor, the real PTY
round-trip including the idle flip and replay; test:sandbox-executor, the
docker argv) pass untouched.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(ui): say the repeated things once — attrs routes, repo pickers, today, PIN forms
Four clones, each a case of a file repeating itself rather than two files
repeating each other:
- /api/people/[id]/attrs and /api/robots/[id]/attrs were the same handler
twice. Attributes live in one table keyed by entity id, so the request IS the
same; the only real difference is that robots first proves the id is a robot
the caller owns, so /api/robots/<a person's id>/attrs cannot write through
the wrong door. That check is now a `guard` parameter, run before the body is
read exactly as before, and responses are byte-identical.
- RepoPicker and RepoMultiPicker each carried the language-colour map, the
/api/github/repos fetch and the row markup. The row takes a `lead` slot
rather than a `multi` flag: the multi picker puts a checkbox in front of the
lock, the single picker puts nothing, and neither component learns about the
other. What selecting MEANS is the only thing they still differ in.
- /today wrote `<Suspense fallback={<CardSkeleton />}>` eleven times and the
same two-column grid four times, which buried what the page is actually
saying — which decisions come first — under its loading mechanics.
- PrivacySettings' three PIN forms shared a submit envelope, a validation pair
and a button row. Each form still owns its fields and its own call.
Rendered output is unchanged in all four; tsc, lint and check:design are green.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor: one site-slug list, one account-fields block, one signed-webhook door
Three more single-definition fixes, each where the duplicate was a door:
- lib/site-cd and lib/hosted-runner/new-site each carried a
character-for-character copy of the reserved-label list and the DNS slug
grammar. That is the shape of duplication that quietly stops being identical:
a label added to one is a door left open in the other. lib/site-slug now owns
both, with no imports of its own so the hosted runner does not pull the
GitHub provisioning graph in just to reject a slug.
scripts/hetzner/new-site.sh keeps its own copy and stays the authority.
- /setup and SignUpForm wrote the same name/password/confirm block twice, down
to the placeholders and autocomplete hints — which matter: a password manager
keys off those, so drift between the two forms is drift in whether saved
credentials work. CreateAccountFields renders the email field only when
sign-up passes one.
- The three /api/orangecat receivers each reassembled the same front door:
refuse if unconfigured, verify the HMAC over the RAW body, then parse and
validate. The ORDER is what matters, not the code — the signature covers the
bytes so it must be checked before anything parses them, and the secret
before that, since with no secret a signed and an unsigned request are the
same request. readSignedOrangeCatBody is now that door; a fourth receiver
gets it right by construction. Responses are byte-identical.
site-cd (43), hosted-new-site (39) and the webhook HMAC contract tests pass
unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(lib): single definitions for escapeLike, decodeEntities, formatDate, normalizeName
Four helpers that existed twice each. Two of the pairs were not merely
redundant — they disagreed, and in both cases one side was wrong.
- decodeEntities: the atlas copy decoded `&` FIRST, so "&lt;" became
"<" became "<" — text a site had deliberately escaped turned back into
markup. The frontier copy did it last, correctly, and also handled CDATA and
`'`. One function now, `&` last, with a test that states why.
- escapeLike: identical in people.ts and robots.ts, but it is the LIKE-wildcard
escape — without it a search for "100%" matches every row. It now lives in
lib/sql-escape.ts rather than beside the queries, because it is pure string
work and that lets the unit suite run it without a DATABASE_URL. Tested,
including the backslash case, which is the one a "simplification" breaks.
- formatDate: two pages, one name, different output — worse than two names,
because reading one told you nothing about the other. lib/dates now exports
`longDate(value, { weekday })`, which also pins a bare YYYY-MM-DD to UTC noon
so a date column never renders as the previous day west of Greenwich.
- normalizeName: these two are genuinely different jobs (person-name folding vs
project-name matching), so the fix is honest naming, not a merge. The project
one is `normalizeProjectName`; one name meaning two rule sets is a bug
waiting for whoever imports the wrong one.
scripts/test/text-helpers.ts pins escapeLike and decodeEntities, including the
double-decode the consolidation fixed.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* fix(gates): teach the route-auth gate the new guard doors, and leave desktop/ alone
Two gates caught this branch, both correctly.
api-route-auth requires every route to NAME its auth mechanism. Moving the
OrangeCat HMAC check and the attrs guard behind shared helpers meant four
routes stopped naming one. The mechanisms are registered now — a route that
delegates names the delegate — and the helpers are noted as wrappers over
mechanisms already in the list, not as new ones.
Worse, and invisible: the same file derives "which routes authenticate
themselves" from markers in the source, then checks each one is exempt from the
session middleware. With the marker gone it found ZERO routes and reported
success — a check that silently examined nothing, which is the exact failure it
was written to prevent (a signed receiver behind the middleware 401s every
caller and reads like a wrong secret). It now fails when the marker set matches
nothing; proved by mutation — emptying SELF_AUTH_MARKERS fails the gate.
desktop-release-drift refused the `sleep` consolidation there, and it is right
to: desktop/ ships as a versioned release, so any change under it obliges a
version bump and a published Fleet Runner build. Three lines of helper is not
worth asking every machine to update, so desktop/src/main/dispatch.ts is
restored byte-for-byte and the reasoning is recorded in src/lib/async.ts, where
it costs no release.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
|
||
|
|
c2f001a511 |
feat(fleet): publish the studio map — every project's purpose, layer, state and last movement (#698)
"What do we have, what is each thing for, where does it run, what is happening on it" was answered by the register (facts) plus 24 hand-written briefs, a showcase overrides file and an ecosystem config that all restate the register in prose and drift within days. The assistant could not answer it at all: no chunk in the knowledge index held the shape of the fleet, so "what projects do we have" came back as "Not in your data". - GET /api/fleet/map: the register join, plus per project the purpose line from its profile, a layer (the three pillars, product, client, demo, next), hosting state and owner, public doors (live, repo, OrangeCat, Solon), the dev log's declared next step, and what last moved (open runs, last run outcome, last log headline). Public and cached like the register; prices, paths and tokens stay out (api-route-auth names the reason). - src/lib/register/map.ts is pure and unit-tested; load-map.ts is the I/O half, shared by the route and the nightly reindex so page and assistant read the same map. - reindex-knowledge embeds one fleet_map overview chunk (owner-scoped): one line per project in a fixed order, so the fleet's shape is retrievable. bitbaum renders this map (its own PR) and publishes it as map.json; Cat on OrangeCat reads it into its context. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
95c40a9cd8 |
refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
5d1c1fdb33 |
fix(orangecat): the site door was behind the session middleware (#653)
* fix(orangecat): the site door was behind the session middleware
The door shipped live, reachable, and unusable. A correctly signed
request got 401 — not from the signature check, from the session
middleware, which answered first.
src/proxy.ts exempts the prefix `api/orangecat/` — the receivers that
verify their own HMAC — and exempts nothing else. I put the new route at
`api/integrations/orangecat/site` because it read as tidier, and that
one word took it outside the exemption.
The failure mode is worse than a 404. The endpoint resolves, the deploy
is green, and a 401 from the middleware is indistinguishable from a 401
for a wrong shared secret — so the obvious next move is to suspect the
credential, which is the one thing that was fine.
Caught by replaying a SIGNED request against production: the body came
back {"error":"Unauthorized"} instead of this route's own
{"error":"invalid signature"}, and the difference between those two
strings is the whole diagnosis. The unsigned probe that returned 401
earlier had "passed" and proved nothing — a guard that can never be
satisfied looks identical from outside to one that works.
So the route moves to /api/orangecat/site, beside entitlement and
events, where the other two self-authenticating OrangeCat receivers
already live. The path IS the auth decision; there was never a reason to
invent a second home for the third one.
Closing the class rather than the instance: the gate now reads the real
matcher out of src/proxy.ts and fails if the door's prefix is not exempt
from it. Proved by mutation — delete `api/orangecat/` from the matcher
and the gate refuses to go green, which is the regression that actually
happened, reproduced deliberately.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA
* fix(orangecat): gate the exemption the move depends on
The move in the previous commit is only half the fix. Moving a file
changes where the route answers; it does not stop the next receiver
being put somewhere the session middleware answers first. This is the
half that does.
- The gate reads the real matcher out of src/proxy.ts and fails if the
door's prefix is not exempt from it. Proved by mutation: delete
`api/orangecat/` from the matcher and the gate refuses to go green,
which is exactly the regression that reached production.
- The gate's own paths and the route's doc comment follow the file to
/api/orangecat/site, and the comment now says WHY it lives there —
the path is the auth decision, not a filing preference.
Why this is a separate commit rather than an amend: the previous one
went out with only the rename staged, because the `git add -A` that
should have preceded it was in a compound command that never ran. The
branch is already pushed with a PR open, so a second commit is cheaper
and safer than a force-push over it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA
* fix(api-auth): gate that a self-authenticating route is reachable at all
Third occurrence of one bug class, so per the never-twice rule it gets a
derived check rather than another hand-maintained list.
1. vitareba 2026-08-07 — the `/api` matcher blocked LOGIN itself.
2. fleetcrown 2026-08-13 — `api/solon/` missing from the matcher; the
Solon doorbell was unreachable from the day it shipped.
3. fleetcrown 2026-09-11 — the OrangeCat site door shipped at
`api/integrations/orangecat/site`, outside every exempt prefix.
There was already a pin for this, in solon-message.ts, and it passed all
three times — occurrence 3 included. It checks that a hardcoded list of
PREFIXES appears in the matcher, and `api/orangecat/` was indeed there.
What nothing checked was the other direction: that every route which
authenticates ITSELF actually LIVES under one of those prefixes. A
receiver put somewhere tidier deploys green and 401s every caller,
signed or not.
So this derives the receivers from the source instead. Any route calling
an HMAC or shared-secret verifier is self-authenticating wherever it
sits, and its path must fall inside the matcher's exemption. 22 such
routes today; the failure message names the route, the marker that
identified it, and the two ways to fix it.
Why a gate rather than vigilance: the middleware's 401 is
indistinguishable from the route's own 401 for a bad secret, so the
first instinct is to suspect the credential — the one thing that was
fine. Only a SIGNED replay tells them apart, and nobody signs a replay
for a route they believe they just shipped correctly.
Proved by mutation with a throwaway fixture at an unexempt path: the
gate names it and fails. The first attempt at that proof moved the real
route instead, mis-restored the directory, and the cleanup deleted a
different pre-existing route (`integrations/orangecat/build`, restored
from git). Never move real files to test a check when a fake one proves
the same thing.
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 (1M context) <noreply@anthropic.com>
|
||
|
|
9613cc9fb0 |
feat(fleet): the register answers the business question too (#638)
The page said what exists. It did not say which of it is a business. That answer was already in apps.conf — owner|plan|price per site — and nobody had ever added it up: four live client engagements, none priced above zero, ten sites in the pipeline. The page now says so, in numbers it computes rather than prose someone maintains. Two deliberate boundaries: - Terms are NOT joined onto RegisterRow. That row is served by a public endpoint, and what a client is charged is theirs. commerce() reads apps.conf directly; fleet-register.ts asserts the public payload's exact key set, so a field added 'just for the page' fails the suite instead of leaking. - The band renders only for the studio owner. A prospect who reads 'every engagement is on favour terms' will expect a favour. Per row, the register now says who a site is for and since when. The two number bands are visually ranked: the commercial one carries the accent, coverage stays neutral — six equally loud numbers is no hierarchy. Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
abb00b911c |
feat(register): one register for every project, joined from the owners of each fact (#610)
* feat(register): one register for every project, joined from the owners of each fact
"Which projects do we have, and which one has a site, a FleetCrown profile, an
OrangeCat profile, a Solon organisation?" had no answer. It had seven: apps.conf,
this database, OrangeCat's, Solon's, bitbaum's companies.json, the public footer's
config, and 24 markdown dossiers. Each is right about its own facts and wrong
about the others; joined by hand they disagreed on 5 names, the footer named a
host that had been renamed and missed 12 live ones, the showcase listed hosts
the hosting register did not know, and Caddy served 38 vhosts of which the
register knew 23.
This does not add an eighth list. It adds the JOIN, computed from the owners:
src/lib/register/apps-conf.ts the one parser for apps.conf (hosting SSOT)
src/lib/register/build.ts pure join keyed on the canonical slug
src/lib/register/solon.ts Solon membership via its public org endpoint,
reported UNCHECKED (not "none") when unreachable
GET /api/fleet/register public JSON — consumers derive, never copy
/fleet the same join, rendered
The join key is the repository name. Names have drifted into several spellings
(aoz-housing/aoz-wohnen, datacat/datacat-web, s-ink/sink, sbb-fundbuero/
sbb-lost-found, wild-spirit/annushka); `canonicalSlug` folds every alias that
has actually bitten, and each is pinned by a test. The durable fix is three
nullable columns on user_projects — slug, hosted_app, solon_org_slug — with
scripts/backfill-project-registry.ts to assign them once (drizzle/0065; the
applier is filename-based, matching how 0064 was shipped).
The footer stops being a list anyone edits. src/config/fleet-sites.ts is now
GENERATED from apps.conf by scripts/generate-fleet-sites.ts (the footer is a
client component and cannot read the register at render, and Atlas needs static
anchors), with editorial copy kept in fleet-site-copy.ts keyed by slug. A gate,
scripts/test/fleet-sites-derived.ts, fails the moment the file drifts.
apps.conf itself gets two corrections found by comparing it with the box:
evig (live on 4004 from the main Caddyfile, never registered) and
hirnli.orangecat.ch, which revamp-info's app serves.
Not done here, on purpose: the bitbaum showcase still renders its own
companies.json — it moves to the API once this is live; annushka and bitbaum are
static Caddy roots with no app process and do not fit the register's app shape.
Verified: 145/145 unit files (24 new assertions in fleet-register, drift gate
green), tsc clean, register gates (port-alloc, register-reality, client-ledger)
green with the new rows.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
* fix(register): evig row names its host database, revampit
The deploy-ready gate found drizzle migrations in the evig checkout and a
db of '-', which is the shape that let botsmann serve PGRST205 for months.
evig is not deployed by deploy.sh at all — its own workflow applies its
migrations — but the register should still say which database that is.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
* fix(watchdog): evig left the hand-list the day it entered the register
The hand-list is built to die one row at a time: the test that failed is
the one that forces a duplicate out the moment apps.conf registers it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
|
||
|
|
81bf2041be |
chore(billing): remove the Stripe rail, which was never configured anywhere (#508)
STRIPE_SECRET_KEY and the seven other STRIPE_* vars appear zero times outside
src/ and zero times in .env.example, so isStripeReady() could only ever return
false. Three API routes, a checkout route, a tier grid and a "Manage
subscription" button were all gated on it and permanently unreachable.
Confirmed empty in production before touching the schema:
select count(*) filter (where stripe_customer_id is not null),
count(*) filter (where stripe_subscription_id is not null),
count(*) from users;
→ 0 | 0 | 7
So this removes no data and, more to the point, changes nothing a user sees:
every code path already fell through to the branch below it.
WHAT STAYS. Plans are real and untouched. They are granted through the
OrangeCat/Bitcoin rail (/api/orangecat/entitlement -> recordOcBillingGrant),
with the expiry cron reverting a lapsed pass to free. The pricing CTA cascade
loses only its unreachable middle step: free -> TBA -> [stripe] -> BTC ->
start-free.
WHAT WAS ACTIVELY WRONG. Because isStripeReady() was false, the one part of
Billing that DID render was a notice telling the reader to "add
STRIPE_SECRET_KEY and price IDs" — an environment variable shown to a person
who does not deploy the app and could not act on it. That is the same mistake
NotificationsPill's comment already calls out. Billing now states the plan and
links to /pricing.
Removed: lib/stripe.ts, api/stripe/{checkout,portal,webhook}, api/checkout/
[plan], getUserByStripeCustomerId, two user columns (migration 0063), two
entries from the user-client-view redaction lists, the api/stripe/webhook entry
in proxy.ts's public matcher, the stripe npm dependency, and the smoke/auth
probes for routes that no longer exist.
BillingSettings drops "use client" — with the handlers gone it holds no state,
no effect and no search-param read.
Two mentions deliberately KEPT because they are not the rail: the placeholder
prose describing what a user might build ("Simple dashboard, automated
reminders, Stripe payments…") and the demo project's stack string.
pnpm run verify green. 28 files, 519 deletions.
Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
caa0e41c3b |
chore: add a formatter (#449)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
0d0e91657b |
feat(crew): assign work to humans, and pay them in bitcoin (#391)
* feat(crew): assign work to humans, not just agents FleetCrown dispatches intents to agents. Some work is not an agent's to do — calling twelve suppliers on the company's behalf, signing something, walking into a room. That half of the fleet had nowhere to live, so it lived in the operator's head. This adds it as a surface: /crew, the humans in the loop and the work handed to them. Three laws, each because the alternative is worse: A person is not a queue. `assigned` only ever means you ASKED. The answer is theirs — accept, decline, or deliver — and OPERATOR_MOVES cannot reach `accepted` or `declined`, so FleetCrown can never record consent nobody gave. Declining is a first-class button on the share page, not small print: an ask you cannot refuse is an order. Nothing reaches a human by accident. An assignment is born a DRAFT, and a draft has told nobody anything. Handing it over mints the share link, and that is the only act in the feature that reaches a person — which is what makes it safe to let Loki propose one (propose_human_task writes a draft, exactly as propose_action does). Money is OrangeCat's. A task states its fee so both sides see the terms; a paid one mirrors to OrangeCat as a service and keeps the pointer. FleetCrown decides WHO does the work; OrangeCat settles what it costs. That seam is the missing link between the two products. The roster is not a new table. A crew member is a person already in the operator's book (`entities`, type person) carrying `crew:member`, so enrolling someone you know adds no row, un-enrolling keeps every note and assignment, and the book can never disagree with the roster. The actor kernel gains a DELEGATE capability opposite MARKET: a robot physically cannot join the crew, and a person still cannot be listed, booked or sold — assertAttrAllowed enforces both directions. The assignee never signs in. They open a link and answer; the token is their credential, looked up with revoked links excluded, and it can only ever answer for its own assignment. Revoking an unanswered ask pulls it back to draft, because a board that says "asked" over a dead link lies to you every morning. Verified against real Postgres, not just types: the whole query layer end to end (enrol → draft → hand over → accept → deliver → accept the work → revoke → re-share), and the public surface over HTTP — page renders, accept succeeds, a replayed accept is 409, an invented action is rejected, unknown tokens 404, and /api/crew plus /crew stay gated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKERdritcwNRuPW72zv8c3 * feat(crew): pay in bitcoin, to the person who did the work Three corrections, all of them about the same thing: a fee is a promise to a human, and every part of it has to be true. BTC is now an assignable currency. The list is exactly the enum OrangeCat's services API accepts (USD, EUR, CHF, GBP, BTC) — a currency FleetCrown offers but OrangeCat rejects is a fee that cannot be mirrored. fee_amount becomes NUMERIC(20,8), not real. float4 carries ~7 significant digits, so it cannot represent a satoshi: 0.00050001 BTC would have been silently rounded on the way to disk, and the amount someone is owed is the last field in this system allowed to drift. Verified against Postgres — that exact figure now round-trips to the last satoshi. Two-decimal formatting had the same bug on screen, printing "BTC 0.00" for 50,000 sats, on the page where a person decides whether to say yes. And the payment goes to THEM. `publishTaskToOrangeCat` creates a service under the studio's integration key, so paying that listing pays the studio — the SDK's actor_id is documented as ignored for integration keys, and OrangeCat has no endpoint that creates an actor, because a profile carries a wallet and a wallet belongs to whoever holds its keys. So the roles are split honestly: the listing is the record of the engagement, and `crew:orangecat_profile` — their own OrangeCat page, Lightning wallet and all — is the destination. It rides on the task as `assigneePayUrl`, gives the operator a "Pay Jana BTC 0.0005" button, and tells the assignee where the money lands before they accept. A paid assignment with no destination on file says so out loud on both sides rather than looking complete. Profile links are stored canonical (a handle and a pasted URL are one wallet, not two) and anything that is not a profile is refused rather than half-saved. The migration is regenerated rather than stacked: 0060 was never applied anywhere, so the column is born numeric instead of being altered later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKERdritcwNRuPW72zv8c3 --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
a577014533 |
chore: clear the code-debt audit — gates, auth coverage, deps, CI database (#362)
* perf(gates): stop charging 8 minutes to push and 3 minutes to commit
Measured on main today: `npm run verify` took 490s and `.husky/pre-commit`
took 172s of it on EVERY commit. That is not a safety property, it is a tax on
committing and pushing — the two habits that keep work off a single disk. The
same fleet audit found 206 finished files stranded uncommitted for ten days.
Nothing here weakens a check. Every one still runs, on the same files:
disk-gc /proc scan 110s -> 16s in_use() forked a readlink per PID on
every call. Hundreds of processes times
several candidate dirs is thousands of
forks per run. Now one `ls -l` pass,
cached for the run. This is SHIPPED code,
so bitbaum's hourly GC gets it too — and
caching is the more correct reading
anyway: "in use when the sweep started"
should not flip between tiers.
eslint 132s -> 7s --cache. Cold is 150s (+18s to write it),
paid once by CI; developers pay warm.
test-disk-gc fixture sparse files via truncate instead of
dd-ing ~300MB of zeros nothing reads.
The code under test only calls df, which
the test already stubs, so it cannot tell.
pre-commit 172s -> ~0 lints STAGED files only. tsc cannot be
scoped to a file set and moves to the
push side, where the full bundle already
runs. A commit is local and reversible; a
push is shared. Gate them differently.
verify 490s -> 334s, still green. `npm run verify` remains the single
definition of verified and CI still calls it verbatim.
* fix(deps): clear every high-severity advisory (15 -> 4, 0 high)
`npm audit fix` took 9 of the 15. The two HIGH ones it left were both the same
root cause — ajv's advisory is *via* fast-uri — and the vulnerable range is
3.0.0-3.1.4 with 3.1.6 already published inside the same major. So an override
closes both with no breaking change:
HIGH fast-uri host confusion via literal backslash authority delimiter
HIGH ajv (inherits the above)
before 1 low 7 moderate 7 high
after 0 low 4 moderate 0 high
The remaining 4 moderates are deliberately NOT fixed. They are one chain —
drizzle-kit -> @esbuild-kit/* -> esbuild — and npm's offered remedy is
drizzle-kit@0.18.1, thirteen minor versions back, which would take the schema
tooling with it. The advisory is esbuild's DEV SERVER accepting cross-origin
requests; drizzle-kit is a devDependency, esbuild is not referenced by
next.config.ts, and neither reaches production. Downgrading working migration
tooling to silence a dev-server advisory that does not apply is a worse trade
than carrying it, so it is carried knowingly rather than silently.
verify green at 372s.
* test(api): make auth coverage checkable instead of archaeological
There is no middleware.ts — all 214 routes guard themselves, through ELEVEN
different mechanisms: four session getters, two private-zone wrappers, a cron
secret, a runner bearer, a widget token, an agent token, and signed webhook
secrets. Each is reasonable on its own. They are layers, not duplicates, and
collapsing them would be worse than leaving them.
The defect is that the SET is not knowable by inspection. Auditing it today
took seven passes. The first reported 44 unguarded routes including
/api/people and /api/memory — every one a false alarm from a helper the grep
had not met yet. Each later pass found another mechanism and shrank the list:
44 -> 27 -> 18 -> 25 -> 18
Nothing was actually wrong. That is the problem: a property needing seven
attempts to verify is a property nobody verifies, and its failure mode is
silent — a new route with no guard looks exactly like the 18 that are public
on purpose.
So this asserts the checkable version of the rule: every route either names a
known mechanism, or appears on a PUBLIC list with a reason a human wrote. The
reasons are the real artifact; until now the answer to "why is this endpoint
open?" existed only in whoever wrote it.
The list is self-cleaning — it also fails when an entry names a route that now
guards itself, or one that no longer exists, so it cannot rot into exemptions
nobody re-examined. All three failures verified red before committing.
Current state: 214 routes, 196 guarded, 18 public with a recorded reason.
No unguarded route was found. Runs in verify via the unit glob; no DB, no
network, 1s.
* test(ci): give CI a database, so the billing test stops being skipped forever
Six suites sat on a permanent skip list for want of a Postgres. One of them
is the OrangeCat entitlement end-to-end — signature verification, actor
lookup, grant write, dedupe, expiry sweep. That is the billing boundary, and
it had never run in CI once. "Only passes locally via .env.local" means, in
practice, that nobody runs it.
It turns out it needs a MIGRATED database, not a seeded one, so CI can just
have one. It now runs green there.
Two things this surfaced that are worth writing down:
* drizzle/*.sql does NOT replay from empty. 0001_canonical_project_identity
references `user_projects`, which 0000 never creates; 51 of 56 migrations
fail against a fresh database. The journal is history, not a rebuild
recipe — so CI uses `drizzle-kit push`, and anyone reaching for those
files to rebuild an environment should know they will not work.
* push is only non-interactive because the CI database is EMPTY. Its
truncate prompts fire for tables holding rows, and an empty database has
none. The comment says so at the call site, because pointing this at a
database with data would be a very bad afternoon.
pgvector/pgvector:pg16 rather than stock postgres — knowledge-embeddings
declares a `vector` column and push dies without the extension.
Skips are now conditional rather than permanent: SKIP_UNLESS_ENV keeps a test
out of the run only while its prerequisite is missing, instead of excluding it
on every machine forever because some machines lack a database. Verified both
ways — 103 tests with no DATABASE_URL, 104 with one, full verify green at 191s.
---------
Co-authored-by: t <t@t.t>
|