Commit Graph
1472 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 a1b009f26e feat(sessions): a token reads its sessions and what was said in them (#1661)
* feat(sessions): a token reads its sessions and what was said in them

An agent that starts Claude Code in a Loki session (tab-inject) could read
the screen (#1641) but not the conversation: the parsed transcript was only
readable over the cookie-only transcript stream, and since #1644 over
OrangeCat's signed rail.

- lib/session-reads: the list, one run, or one project with the last things
  said in its conversation, moved out of the signed route unchanged, so two
  doors share one copy
- GET /api/control/sessions: the same reads with a session or ck_ token
  (?project=, ?runId=, ?items=), no-store
- every row names its session and carries openUrl, the same session in
  Loki's Terminal on that run (lib/dispatch-card sessionOpenUrl)
- the list says it is cut at 25 and carries total, so a cut list is never
  read as the whole one
- LOOP-WALK's Session walk names the read; tests pin both doors to the one lib

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

* fix(sessions): the conversation read is current, on the session's builder, and never ends a person's view

Traced end to end before merge (2026-11-12):

- a cached conversation was served forever: after the first read sent
  peek_stop the runner stopped streaming, so a later read returned the same
  copy without the agent's answer. The cache now counts only while someone
  is watching; otherwise the read waits for a frame posted after it asked.
- peek_start and peek_stop carried no channel, so the owner's laptop runner
  could take a read meant for the cloud session (transcript null). They now
  name the project's builder (projectPreferredChannel).
- the read counted its viewer under a key of its own, so its peek_stop could
  end a person's live view of the same session on a phone. It now shares the
  Terminal's viewer count (same user, tab and channel).
- a cloud link carried no source, so a phone that last chose 'Your computer'
  opened the laptop's session of the same name. sessionOpenUrl names the
  cloud builder, and each row's link uses the session's builder.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 12:32:25 +01:00
CatoandClaude 6d47eae8a5 feat(studio): the studio site can tell who is signed in (#1672)
bitbaum.orangecat.ch is static files with no accounts of its own; a
person's account there is their Loki account. Until now its header could
not know anybody, and a builder's only way back in was a Loki page that
makes a new private link.

- GET /api/studio-session answers the studio's origin, with the reader's
  own session cookie: a name, a handle, a picture, whether they run the
  studio, and their builder applications by status. No email, no account
  or application id, no access key. Signed out is an answer (200), with
  the addresses to sign in and out at. Public on the proxy's list because
  the proxy's own 401 carries no CORS headers.
- GET /studio/return?to=/builders/ is the studio site's sign-in door:
  behind the proxy, so a signed-out visitor signs in first, then lands on
  that page of the studio site. The destination is a path on the studio's
  own origin and nothing else.
- /sign-out?then=studio ends on the studio site (/studio/left, public).
- One header shape for everything the studio site reads with a session
  (STUDIO_SESSION_HEADERS); /api/fleet/private uses it.

scripts/test/studio-session.ts pins the answer's shape, what it must
never carry, the return-path rule against open redirects, the headers,
and which of the three routes the proxy guards.

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 11:45:22 +01:00
CatoandClaude 6a05433fe0 fix(runs): one status, after the review of #1647: a closed run is over, a held command is Starting (#1671)
An adversarial review of #1647 (an open run's status comes from its track)
found five regressions, all live:

- A finished run whose command was never claimed (queued for an offline
  builder, then stopped or reaped) read Queued, not terminal; callers polled
  it forever. A run that is over now reads its outcome first.
- No run event marks a runner's claim, so a command a runner held read
  Queued, or Needs you: no runner has picked it up. Both status routes now
  hand the track what the command row knows (the claim; for a prompt typed
  straight into a live session, that it was submitted), and a claimed,
  unanswered command is Starting, never below.
- The chat card's offline-builder view, with its one-tap Run it in the
  cloud, was never reached once that status read Needs you. It is again.
- A direct-mode run read Queued, then Needs you, with no runner involved.
- The run sheet had no words for Starting and Needs you; a blocked agent
  read "an agent starts on it in a moment".

scripts/test/one-run-status.ts, scripts/test/dispatch-card.ts.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 11:01:05 +01:00
CatoandClaude 510d8e2a14 fix(runs): whose pull request it is, after the review of #1643 (#1666)
* fix(runs): whose pull request it is, after the review of #1643

A review of the merged attribution change found the remaining ways a run
could claim, or act on, a pull request that is not its own:

- The fix ledger decided "this run's" by time alone, and on that basis
  could merge (auto-ship) or put back into draft a pull request somebody
  opened on another branch, when the handoff named it. auto-ship
  prOwnership: Loki acts only on a pull request on one of the run's own
  branches; it reports one as the run's when it is on them, or, for a runner
  too old to report branches, when the handoff names it.
- Evidence recorded before #1643 was never checked again, so run 70d1a78d
  kept loki#1636. It is checked with GitHub once and removed when foreign;
  Watch no longer falls back to evidence the ledger called foreign, and other
  views do not trust unchecked old evidence.
- The window had no end, so an earlier run sharing a branch with a later one
  claimed the later run's pull request. It ends 15 minutes after the run.
- Only the ten newest pull requests were scanned; a busy repository pushed
  the run's own off the page. Pull requests are asked for by head branch.
- Legal branch names with # or + were dropped. The rules are git's.
- The runner also reports the remote branch a checkout pushes to, skips the
  repository's default branch whatever it is called, and its exit and
  shipped beats carry the branch. Runner 0.8.69.

scripts/test/run-evidence-ownership.ts.

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

* fix(runner): a run closes as shipped only with a pull request opened during it, and only then stops the agent

The runner's idle check took any open or merged pull request on the branch
the agent sat on. A session that carries on from an earlier run sits on that
run's branch, so a read-only probe was closed Done with the earlier run's
pull request, and the runner stopped the shared session whatever the server
answered (also when the run had already been closed another way).

- findShippedPr takes the run's start; a pull request opened before it is
  not this run's.
- The server says closed: true when the beat closed the run; the runner
  stops the agent only then.

Found by a review of the probe path (2026-11-12).

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:59:44 +01:00
Cato 00ac95a8a1 fix(home): a Being built row that needs you says Needs you once, the question, and takes a reply (#1670)
On a phone the owner read "Waiting for you · Waiting for your answer" on a
project's row: the state twice, and nowhere what answer was wanted. The row
titled itself with the project, so the question that control-now put into
the job's title was never drawn.

- The state is the canonical word, CANONICAL_LABEL.needs_you, once — the
  same vocabulary canonicalStatus() gives every other surface.
- Then the question in one line: the session's block reason, else the run's
  handoff block reason, the session's next, the run's next; never empty.
  A permission prompt shows what it asks (the run's blockedQuestion, now
  carried on /api/control and typed on the run payload), a sign-in wait
  says someone has to sign the agent in.
- An agent idle at its prompt waiting for an answer gets a reply field under
  its row; Send goes to that project's agent through the same /api/inject
  as the box at the top of Home. A permission dialog or a sign-in is not a
  typed reply: those rows open the session, as before.

Tests: control-now pins the word, the question's sources and when a reply is
offered; home-being-built-browser checks the row at 390px in light and dark.
2026-11-12 10:46:52 +01:00
CatoandClaude 7dd29e12df fix(one-off): a fresh session stays one-off: nothing of the shared session goes in, nothing of it comes back (#1665)
Found by a review of the merged fresh-session change (2026-11-12):

- A retry (automatic after a refusal, or from Watch) re-sent a one-off as an
  ordinary message, into the shared session. It is retried as a one-off.
- /api/control closed the project's newest run from the SHARED session's
  handoff without checking whether it was a lane run, so a one-off could be
  closed with the shared session's summary, announced to its caller, and
  left running. A lane run closes only from its own session file.
- A one-off's prompt carried the project's escalation note ("diagnose the
  last failure") and, on the local runtime, the shared session's last
  handoff and an instruction to update the shared session file.
- A one-off's close advanced or cleared the project's escalation ladder.
- On the local runtime the shared tab's prompt and handshake files were
  written for a one-off, even when the request was then refused.
- OrangeCat's separateSession asked for a lane, which quietly queued in the
  shared session when no lane was free. It is a fresh session now: a
  session of its own, or a refusal with the reason.

scripts/test/one-off-stays.ts.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:37:12 +01:00
CatoandClaude b824a48686 fix(lanes): a lane starts clean: from main, in a new conversation, without touching the shared checkout (#1662)
* fix(lanes): a lane starts clean: from main, in a new conversation, without touching the shared checkout

A lane is a run beside the project's own session, in a worktree of the same
checkout on the cloud builder. A review of the merged runner fixes
(2026-11-12) found three ways it did not start clean:

- Its worktree was cut from the checkout's HEAD, which on the box is the
  shared session's run branch (loki/run-<id8>). The lane began with another
  run's unmerged commits and its pull request carried them. It now starts
  from the remote default branch (worktree-workspace laneBaseRef).
- Its checkout step ran git pull --ff-only in the folder the shared
  session's agent works in; the run branch tracks origin's default, so the
  live agent's files could move under it. A lane now only fetches
  (ensureBoxWorkspace pull: false).
- A dispatch that carried the project's sessionId kept it in a lane, so the
  lane ran claude --resume of the shared conversation in a new folder.
  A lane resumes nothing.

Also: a live lane reopened after a builder restart is looked for in its own
folder (pty-runtime's record), and traced back to its checkout for pruning,
not to the dispatch's laptop path.

scripts/test/lane-base.ts runs real git for each case. Runner 0.8.68.

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

* fix(lanes): a lane that cannot start says why in words the retry policy reads

A laptop lane for a folder that is not on that machine was refused as a
worktree failure, and a missing box checkout as "nothing was launched".
auto-reimplement-policy reads neither as a workspace problem, so both were
retried on a builder where they cannot work. Both now use its words
("does not exist on this machine", "nothing was launched here").

Found by a review of the merged runner fixes (2026-11-12).

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:33:33 +01:00
CatoandClaude Fable 5.2 7718294354 fix(builder, composer): a silent sealed session no longer holds a runner update; the composer falls back to the cloud runner (#1676)
* fix(builder): a sealed session that has been silent for half an hour no longer holds a runner update

The drain restarts the box runner only when no agent is working. A sealed
session has no status file the drain can read: its agent lives inside
gVisor and the unit's cgroup holds only the `podman run` that relays its
terminal, so it counted as working for as long as it was open, and
sessions stay open for days.

Measured on the box, 2026-11-12 07:56 UTC (Sealed builds run 43178274733,
mode=activity): three open sealed sessions, one of them eighteen hours
old, relayed 0, 40 and 96 bytes in a minute while the drain logged
"3 agent(s) working — deferring restart" on every look. The runner stayed
two releases behind for hours, so the runner fixes merged that morning
were not running, and the commands route held new work for the restart.

- agent_is_busy: a sealed session that has relayed under 512 bytes a look
  for 30 minutes is not working. Shorter than that, or a quiet that
  cannot be told, still is: unknown is not idle.
- quiet_for reads the relay's cumulative byte counters and keeps its note
  under /run/loki-drain/<unit>, outside the drain's own process: every
  deploy starts a new drain, and a clock that restarted with it would
  never reach thirty minutes on a box that deploys several times an hour.
- The rule is the sealed session's alone. An unsealed agent that is not
  Claude still always holds the restart: its output was not measured.

What it can cost: a sealed agent stopped at a permission prompt in the
middle of a task prints nothing, so after thirty minutes of that the
restart goes ahead; the session reopens and its open run is closed.

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

* fix(composer): the project composer falls back to the cloud runner when the project's own builder is off

The chat reroutes a project pinned to an offline computer to the cloud
runner and says so (inject-core). The project composer for an idle project
(/api/control/tab-inject) asked for the routing decision without that
fallback: a project registered from a laptop queued for the laptop while it
was shut, with the laptop's folder as the place to start, and the answer
named no builder. The row sat until the reaper closed it an hour later.

- tab-inject passes the project's offline fallback, starts a rerouted
  dispatch in the folder the cloud runner clones into, and answers with the
  builder that took it and the reroute sentence.
- execution-access test pins the three.

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>
2026-11-12 10:23:40 +01:00
CatoandClaude 29944cfd65 fix(queue): every way a feedback fix starts gets its lane, and a busy project never queues a message it has no run for (#1669)
Found by a review of #1639 (2026-11-12):

- "Implement all", the widget's "Build all" (both batch-dispatch) and the
  automatic retry of a stuck Implement (retry-queued) did not ask for a lane,
  so since #1639 they waited behind the project's open run while a single
  Implement got one. They ask for a lane, as Implement does.
- The claim gate holds a busy project's queued row back by its run. When the
  run could not be recorded (a failed insert), the row had none, was
  claimable at once, and would be typed into the session it was meant to wait
  for. Such a message is refused with a sentence; nothing is sent.

scripts/test/busy-placement.ts.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:09:18 +01:00
CatoandClaude 2784b1d62d feat(loki): the Cat reads what Loki needs from you, with a link; the start knows the day (#1668)
OrangeCat's Cat opened the owner's morning with "Loki is waiting on you to
continue orangecat": no words for what Loki needed, and a link that 404s.

Rail (POST /api/orangecat/actor-status, OrangeCat's Cat home and context):
- lokiUrl used the user_projects id; /projects/[id] is keyed by the entity
  id, so every link the Cat gave opened a 404. Entity id now, or the by-name
  /projects/go/<name> when there is no entity.
- blockReason crosses as its code. Agents write "awaiting_user — no
  high-impact work remains; …", which never equalled "awaiting_user", so
  readers comparing codes missed the most common block.
- needsYou per project: the agent's own next step (session_next) when the
  project waits on its owner; the autopilot's brake becomes "Loki finished the
  work that mattered most. Pick what comes next." instead of "waiting on you".
- needsYou top level: approvals and the owner's alerts, from the same
  composition /today shows (composeNeedsYou over loadNeedsYouExtras), counted
  tiers only, each with an absolute link; linkless lines never cross. The PIN
  rule is upstream: locked, only the approvals count leaves.

Start screen (/loki, the home after sign-in since 2026-11-01): the date and
time under "What are we working on?", read from the reader's clock, and one
row into Today ("Start my day" in the morning). The day stays Today's
(2026-10-21); this is a row, not the card that was removed.

APP_LOCALE moves to src/lib/constants/locale.ts (re-exported from
constants.ts) so a client bundle can import it without os/path.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:06:36 +01:00
CatoandClaude 663661c565 fix(inject): a read-only probe ends Done on the builder it asked for, and a refusal by choice is not a failure (#1667)
* fix(inject): a read-only probe ends Done on the builder it asked for, and a refusal by choice is not a failure

Found by a review of the probe path end to end (2026-11-12):

- Every run's status went through the feedback-fix mapper, which calls a
  run that finished well with no pull request "Needs you, nothing shipped".
  A git status probe ended there. Only a feedback fix owes a change; any
  other run that finished well with nothing pushed is Done, cause
  finished_no_change (canonicalStatus expectsChange, from run-track-load).
- Neither POST /api/inject nor MCP loki_dispatch could ask for the cloud
  builder: zod drops unknown keys, so builderChannel vanished without a word.
  Both take it now (builderChannel / builder).
- A fresh session refused for lack of a free lane was closed as a failing
  run and advanced the escalation ladder; four of them paged the owner with
  no agent ever run. That refusal no longer counts.

scripts/test/probe-path.ts.

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

* test: two text pins follow the new shape of the inject route and the refusal close

busy-placement read the inject route's call on one line; refused-dispatch-
closes-run read closeRunUndelivered with a one-key options object. Both still
assert the same thing: the route passes session on, and a refused dispatch
closes its run quietly before the failure is reported.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:05:53 +01:00
CatoandClaude d128019ab9 fix(one-off): a fresh session ends with its run, on the builder it ran on, and says where it is (#1664)
#1640 closed a one-off's tab only when its own handoff closed the run. One
that never reported (reaped), was refused on its ack, or ended with a runner
restart kept its agent open in its lane, free to go on to something else and
holding a project lane and a builder agent session.

- one-off-close.ts: notifyRunClosed, which every close path calls once,
  queues close_tab for a one-off's lane tab; the handoff close no longer does
  it separately.
- The close goes to the builder the dispatch command names now. A queued
  dispatch moved to the other builder used to be closed on the first one,
  which answered "nothing to close".
- loki_dispatch's result carries the lane tab (sessionTab) and says it.
- A refused fresh session reads the lane count again before it says the
  project is full; a database error used to read as "wait for one to close".
- scripts/test/one-off-close.ts.

Found by a review of the merged runner fixes (2026-11-12).


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:53:47 +01:00
CatoandClaude Fable 5.2 64e2c6b543 fix(builder, runs): a held task waits minutes and says so; a build says when it is live (#1663)
* docs(handoff): checkpoint for building with Loki and with a Cat bot

The objective, the two journeys that count as done, how production can be
reached from an agent session, and the state when the work began.

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

* docs(handoff): what the investigation found, and what it did not reach

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

* fix(builder): a task held for the runner's update waits minutes, not for ever, and says so

While the cloud runner is behind the deploy the commands route hands it no
work-starting command, so the idle moment its restart waits for comes. The
hold had no end, and on 2026-11-12 the restart did not come: two runner
releases landed 35 minutes apart, the drain read "5 agent(s) working" on
every look for an hour, and the builder claimed screen peeks and nothing
else (Sealed builds run 43165605499). Every task a person sent sat queued
while the chat said a runner would claim it shortly.

- runner-update-hold: a held command is handed over once it has waited
  five minutes, and the hold applies only within two hours of the newest
  runner release. Running on last week's runner is recoverable; a task
  that never starts is not.
- claimNextPendingCommand takes the overdue rule. While holding, an empty
  at-once list claims nothing (it used to claim everything).
- The person is told why and for how long: in the chat reply, in the
  /api/inject answer (builderUpdating, message) and as the run track's
  headline while the job is unclaimed.
- loki-loop-check.yml: the end-to-end check of the live site on demand,
  with an optional real no-change task that must come back into its
  thread. loki-e2e-check.sh --report takes the project, the wait and the
  dispatch choice from its caller.
- sealed-builds.yml mode=activity: read-only, what each agent process of
  the runner read and wrote over a minute, so the drain's "working" can be
  measured for sessions it cannot read a status for.
- pre-push: the watchdog's sleep no longer holds the caller's output open
  for fifteen minutes after the push has landed.

Server and box scripts only: no runner code, no runner version.

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

* fix(runs): a build tells the truth after the agent finishes, and says when it is live

A task sent from the chat ended at "done, pull request opened". What it
said next was wrong in several ways, and the one thing a person waits for,
that it went live, was said to nobody.

- The "done" message reads the pull request the runner itself reported
  (payload.prUrl from closeRunShipped, read by nothing until now) and asks
  GitHub with the token that can read the repository. The person's own
  OAuth token is refused on the organisation's repositories, so a run that
  shipped could be posted as "No pull request or push was found". The
  reaper's evidence lookup asks the same way.
- "Live" is read from the site: a merged change is live when the commit in
  the site's /.well-known/fleet-release.json is the merge or comes after
  it (feedback/served-release). Workflow-run labels are wrong on this
  fleet: a Deploy run is labelled with main's tip at its start, a batched
  merge has no Deploy run of its own, and OrangeCat's deploy is named CD.
  It only upgrades; with no receipt the workflow-run verdict stands.
- A chat build is followed to live on the fifteen-minute cron that already
  follows feedback fixes (run-follow-notify): on the change to live, or to
  a failed deploy, one line in the thread the task came from and one push.
  GitHub and the release receipt only, no model. Old news is not announced.
- A task that waits behind the project's earlier run says so in the chat,
  the /api/inject answer (queuedBehind, message) and the track, instead of
  "will claim it shortly".
- Isolated runs ship through a pull request: worktreePromptNote told every
  lane and one-off session to push straight to main.
- The close message no longer prints "Live: <address>" beside a pull
  request that has not merged.

Server only, plus one prompt line the runner reads at its next start. No
file under desktop/, no runner version.

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>
2026-11-12 09:48:29 +01:00
CatoandClaude f7a0b051b7 fix(runner): a dispatch is delivered only once the request is in Claude Code's own conversation (#1660)
A busy CLI looks the same whether it is answering the request or carrying on
with its own plan (probe 9e3658d9, 2026-11-12). The runner verified a Claude
dispatch on the CLI's session status alone.

- prompt-evidence transcriptShowsPrompt: the request must be in the agent's
  log as a person's message written after the inject. Measured how Claude
  Code 2.1.322 logs a pasted prompt by driving it in a pseudo-terminal as the
  runner does: inside <pasted_content> tags, which are unwrapped. An older
  [Pasted text #N] placeholder after the inject also counts.
- The dispatch ack is verified:false with a sentence when the log exists and
  the request is not in it; no log is no evidence either way.
- The ack now sends deliveredAt and workspaceId. Both were built and then
  dropped, so delivery was stamped at ack time.
- Runner 0.8.67 with its release note.
- scripts/test/prompt-in-transcript.ts, with the measured log line as a
  fixture.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:29:02 +01:00
CatoandClaude 220ea00416 fix(runs): the delivery track shows a pull request and commits only from the run's own branches (#1659)
#1643 tied live evidence to the run's branches, but the track's own read of
the repository (lib/repo-progress) still took the newest pull request opened
since the run began, and the newest push. That read is where run 70d1a78d's
"Pushed: <#1636's commit>" and its pull request came from (2026-11-12).

- readRepoProgress takes the run's branches; a pull request's head and a
  pushed ref must be one of them.
- run-track-load passes runBranches(run).
- scripts/test/run-branches.ts replays the incident against repo-progress;
  the three new checks fail on main and pass here.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:28:12 +01:00
CatoandClaude Opus 5.5 b376ead370 feat(orangecat): a bot follows a run to its answer, and asks a one-off in a fresh session (#1658)
* feat(orangecat): a bot follows a run to its answer, and asks a one-off in a fresh session

A bot that sent a task could not reliably read the answer:
- the runner streams a conversation only while someone watches it, so a read
  a minute later found nothing, or an older conversation passed off as current
- a read by project took the project's latest open run, so an answer in a
  separate session could come back as the shared session's conversation
- a one-off session closes when it reports, leaving nothing to ask for after
- /api/orangecat/task could not ask for the fresh one-off session (#1640)

Now, on /api/orangecat/sessions:
- runId + watch (seconds, <= 300): the bot holds that run's session as a
  viewer for that long (lib/integrations/orangecat-watch.ts), so the runner
  streams the conversation while the agent works
- runId + items: the last items of THAT run's own session (its lane or
  one-off tab), on that run's builder
- every row carries the agent's handoff once it reports (lib/run-handoff):
  the answer survives the session being closed
- a read with nobody viewing waits for a snapshot newer than its join; an
  older copy alone comes back marked live: false

On /api/orangecat/task: session "fresh" (and separateSession as its alias)
gives each project a one-off session; a busy project is no reason to refuse it.

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

* fix(orangecat): a signed task outside its window is refused; a run whose track fails is never read as idle

From review of the rail:
- /api/orangecat/task had no freshness window, so a captured signed request
  could be replayed to start agent sessions later. It now takes issuedAt and
  refuses one older than the read doors' window (optional until every
  OrangeCat sends it; OrangeCat sends it from now on)
- a sessions read whose run track failed to load reported the run as Idle
  with no runId, which a follower took for settled. Such a run is now said
  from its own row: working while open, done or failed once closed, with
  its handoff

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

* fix(orangecat): a follower's poll never reaches GitHub; a transcript read waits for the whole snapshot

From review:
- a bot following a run reads it every few seconds, and every runId read
  loaded the owner's full track, which looks at GitHub. poll: true reads the
  run's own facts and cached ledger only
- the runner posts a snapshot in batches of 100; a read returned on the
  first batch, so a long conversation came back without its tail. It now
  waits until the batches stop arriving

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

* fix(orangecat): a session's task says what was asked, not the cross-project preamble

From review: for a task sent to several projects, the row's one-line task
was the first line of the preamble the agent is given ('Cross-project task.
The same request below was sent to ...'). askedOf takes the preamble off;
a prompt without one comes back as it is.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:10:19 +01:00
CatoandClaude Opus 5.5 12e0357d8f feat(sessions): starting a session answers with where a person opens it (#1657)
* feat(sessions): starting a session answers with where a person opens it

An agent that starts Claude Code in a Loki session hands the owner the
session to look at, on a phone or a computer. The Terminal's address was
built only inside the app's own cards, so a caller had to guess it.

- lib/dispatch-card sessionOpenUrl: the full link to the session in Loki's
  Terminal, on that run when there is one, This computer for a local one
- tab-inject (live, dispatch, queued), /api/inject and MCP loki_dispatch
  (through inject-core, a parallel lane included) and agent/launch return
  openUrl
- LOOP-WALK's Session walk says so; scripts/test/session-open-url pins it

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

* fix(sessions): a session's link names its builder

A cloud openUrl carried no source, so the Terminal opened whatever source
that browser last chose: a phone that last picked 'Your computer' opened the
laptop's session of the same name instead of the cloud one the agent drove
(traced 2026-11-12). sessionOpenUrl now says source=cloud for the cloud
builder, and the screen capture's openUrl (POST /api/control/peek-tab) is
the same full link instead of a bare path.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:46:37 +01:00
CatoandClaude 8d2101068a chore(crons): call Solon's Places import hourly (#1656)
The route no longer does the work inside the request: it starts a worker
that drains the queue of sources its run log says are behind, and answers
at once (solon src/lib/places/importer/queue.ts). Called hourly, a publisher
that was down is tried again the same day, and a day with hundreds of
sources due no longer needs one request longer than the runner's 300 s.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:40:50 +01:00
Cato 662b0c9038 test(ai): the chain tests clear every key the chain reads, not a list that missed Gemini (#1655)
ai-budget-gate and chat-chain unset GROQ_API_KEY and OPENROUTER_API_KEY by
hand before checking that an unkeyed provider adds nothing. Gemini joined
the chain later, so on any machine holding GEMINI_API_KEY both failed
("unkeyed providers contributed capacity", "unkeyed provider leaked into
the chain") for a reason that was the environment, not the code.

Both now take the key, model-override and budget-override names from
CHAT_CHAIN itself, so a provider added later is cleared too.
2026-11-12 08:39:27 +01:00
Cato 694961287e test(unit): a machine where node-pty cannot load skips the PTY tests and says why; CI still runs them (#1654)
The terminal tests (executor, sandbox-executor, plain-shell,
terminal-run-view, claude-dialog-not-a-composer) drive a real PTY through
node-pty. Its native binary is built where pnpm install ran; an agent
sandbox that shares the box's node_modules on an older glibc cannot load it
("GLIBC_2.42 not found"). On 2026-11-12 every push from such a sandbox
failed those five in pre-push whatever the change, and the hook's only way
out is --no-verify, which also skips everything that did run.

Off CI only, the runner now probes node-pty once. When it cannot load, a
test that fails with exactly that load error is reported as skipped, with
the reason printed at the top and in the totals; any other failure in the
same file still fails. With CI set the probe never runs, so CI's run stays
the gate.
2026-11-12 08:08:42 +01:00
CatoandClaude 85e8deac30 feat(mcp): a connected agent lists open sessions and reads what a session's terminal shows (#1653)
Over MCP an agent could send a task to a project's agent (loki_dispatch) and
was told not to poll: it had no way to see that the session was up or to
read what the agent answered. The HTTP side got both for a token in #1641.

- loki_sessions: agent sessions open on the owner's builders, each with the
  link that opens the same session in Loki's Terminal. Plain shells are
  never listed.
- loki_session_read: the end of one session's terminal output as plain text
  (escape sequences removed, redrawn and repeated lines collapsed). Queues
  the same peek_tab command as POST /api/control/peek-tab and waits up to
  twenty seconds; a builder that does not answer is an error that says so.
  A plain shell is refused before anything is queued.
- both read only, so both sit under loki.chat, as the scope rule requires.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:05:27 +01:00
Cato 51c6e238dc ops(box): see who holds Postgres connections, reap idle ones on request (#1651)
* ops(box): read who holds Postgres connections, and reap idle ones on request

* ops(box): reap also caps idle loki sessions at 15 minutes
2026-11-12 08:03:07 +01:00
Cato 186679c091 fix(runner): auth and quota failures are judged only on the run's own evidence (#1650)
* fix(runner): the auth canary fails a run only on that run's own evidence

A fresh solon tab on the cloud runner was failed as "claude is not
authenticated" because the newest Claude transcript in its folder was a
two-day-old session ending "Please run /login". A Grok run a minute later
was failed with the same text, telling the operator to set
CLAUDE_CODE_OAUTH_TOKEN, because the canary read Claude's folder for an
agent that never writes there. The runner's sign-ins were fine.

- Claude: a transcript last written before the prompt is not evidence.
- Other agents: read what the agent printed since the prompt, minus the
  prompt's own words; never Claude's transcripts.
- The error names the refused agent and its own fix.

* chore(runner): 0.8.66 with its release note: the auth canary reads only this run

* fix(runner): a quota wall is the agent's own answer, and a provider that answered since is not spent

At 05:41 Zurich a Solon brief about replacing a "rate limiter" whose
memory "resets on deploy" failed its run as "claude cannot generate
because its usage limit is exhausted", and Loki then offered Claude as
spent for an hour. Claude kept working for fourteen more minutes.

- Claude: a wall counts only when Claude's own transcript since the
  prompt holds an API error naming a limit. The screen echoes our brief.
- Other agents: the screen check also ignores an echo of the prompt
  whose spaces a TUI redraw dropped.
- spentProviders: newest run per provider decides; a run that finished
  successfully after the wall clears it. An open run proves nothing.
- Runner 0.8.67 (0.8.66 went to #1643).
2026-11-12 08:02:13 +01:00
CatoandClaude f873c3641c feat(orangecat): a person's bot files a finding into the feedback inbox over the signed rail, and reads it back (#1648)
A QA bot files through POST /api/projects/<id>/feedback with its own seat's
token. A person's OrangeCat bot has no Loki token: it acts over the signed
rail as the Loki account linked to its owner. It had no way to file.

- lib/feedback/agent-filing.ts is now the one body of a machine filing and of
  a report's status read (moved out of the two routes, unchanged in what it
  does: rate limit, idempotent replay, source agent, the owner's opt-in
  build; the two status shapes by seat)
- POST /api/orangecat/feedback: signed, fresh, the linked account, a project
  by name that the account has a seat on. A filing (words only) answers like
  the seat door; { feedbackId } reads the canonical status
- no second inbox and no second contract: both doors call the same body


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:03:57 +01:00
CatoandClaude 9253f40898 fix(runs): an open run has one status, read from the same facts as its track (#1647)
/api/orchestration/runs/<id> and /api/control/commands/<id> answered status
"delivered" / "working" while track.summary in the same response said
"Waiting for a runner" (2026-11-12). The word came from the command row, the
sentence from the run's events, and the run route treated every run as
executed and verified from the moment it was opened.

- RunTrack.live: Queued, Starting, Working or Needs you, decided in the same
  order as the track's summary; null once the run has finished.
- alignLiveViewWithTrack: while a run is open, both routes return status,
  label, detail and tone from the track.
- An open run is never "Delivered to agent" on a runner's ack alone: it is
  Starting until the agent prints after the prompt, then Working.
- The run route reads the run's own command row instead of assuming it.
- scripts/test/one-run-status.ts replays both contradictions.

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:37:29 +01:00
CatoandClaude Fable 5.2 0b6e30ac7a feat(orangecat): a task can name the cloud runner, answers with a status address, and a busy project says so (#1646)
* feat(orangecat): a task can name the cloud runner, answers with a status address, and a busy project says so

The task door already answered with each project's runId. A caller on
OrangeCat still could not ask for the always-on runner, had no address to
follow the run at, and a task for a project that was already at work was
queued behind the open run without a word.

- builderChannel: "cloud" | "local" is passed to the dispatcher as the
  caller's named builder (403 with a sentence when the cloud runner is not
  this account's to use)
- every sent project answers with statusUrl next to runId
- a project with an open run refuses the whole task with 409 and a sentence
  naming it; queueIfBusy: true queues behind the open run as before

/api/inject/multi and the MCP dispatch are unchanged: refuseBusy is opt-in.

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

* feat(orangecat): a task for a busy project can ask for a separate session

Main now queues a message to a busy project first in, first out, and gives a
parallel lane only to a caller that asks (busy-placement). The task door
passes that through: separateSession starts a lane for a one-off that should
neither wait for the open run nor be folded into it. Without it, and without
queueIfBusy, a busy project still answers 409 with a sentence, which now
names both choices.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:34:13 +01:00
CatoandClaude ec0cd635ba feat(inject): session "fresh" starts a one-off session in its own worktree and closes it when it reports (#1640)
* fix(inject): a message to a busy project waits its turn; only a caller that asks gets a parallel lane

With parallel dispatch on, every dispatch to a busy project forked a lane with
a new agent session. A message sent to orangecat while a run was open
(2026-11-12) started a second agent instead of queueing behind the open run,
while the same message to loki queued: the difference was whether a lane was
free, not what the caller meant.

- orchestration/busy-placement.ts: the one rule. Busy means queue, first in,
  first out; a lane only for whenBusy: "lane".
- executeInject plans a lane only through that rule.
- feedback Implement asks for a lane, as before. /api/inject, the MCP
  loki_dispatch and chat dispatches are messages to the session and queue.
- scripts/test/busy-placement.ts pins the rule and those callers.

* feat(inject): session "fresh" starts a one-off session in its own worktree and closes it when it reports

A read-only one-off question typed into a project's shared session does not
stay one-off: "only run git status, then stop" was answered, and then the
session went back to its own plan and edited tests (2026-11-12).

- POST /api/inject and the MCP loki_dispatch take session: "fresh".
- The prompt gets a lane of its own whether or not the project is busy: a new
  agent in its own worktree, no resumed conversation, told it is a one-off.
- When it reports ready the run closes and close_tab is queued for the lane.
- It never falls back to the shared tab: without a lane it is refused with
  fresh-session-unavailable (409) and nothing is sent.
- scripts/test/busy-placement.ts pins the rule, the prompt, the close and the
  two entry points.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:33:10 +01:00
CatoandClaude 03d9415598 fix(registry): loki's own project runs on the cloud builder; an offline pinned builder is said in words (#1645)
* fix(registry): loki's own project runs on the cloud builder; an offline pinned builder is said in words

The loki registration was pinned to the owner's laptop, offline since
2026-11-11 07:19, and its session note still described that laptop's blocked
session. Every dispatch asked for an offline builder and was sent on to the
cloud; an API caller saw only channel: cloud.

- drizzle/0137: that one registration (found by its laptop path) moves to
  builder_pref cloud, and its session note is cleared while it still says
  what was stale. Data only.
- rerouteNotice: the inject response says in a sentence that the project's
  own builder is offline and which builder took the work; the MCP
  loki_dispatch already prints the response's message.
- scripts/test/registry-cloud.ts pins the migration's scope and the sentence.

* refactor(registry): keep the reroute sentence clear of lines other open changes touch

Same behaviour. The sentence's import, its place in the response and its
place in dispatch-status.ts move so this change merges cleanly beside the
open inject and run-status changes.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:20:44 +01:00
CatoandClaude 71cfa45816 feat(orangecat): a signed read of a person's agent sessions and their conversation (#1644)
OrangeCat bots steer Claude Code sessions over the signed rail, but the
conversation was only readable over a cookie-only SSE, so a bot could send a
prompt and never read the answer.

POST /api/orangecat/sessions answers, as the Loki user linked to the actor:
- every project's session in one row: builder, online, canonical state, the
  task in one line, last activity, latest run, its track sentence, PR url
- with runId: that run, with the owner's full track
- with project: the row plus the last N (<= 40) transcript items, clipped

The state is the canonical one from the run-track loader; nothing is
re-derived. The transcript is the copy lib/sse-bus already keeps; with none
cached the route joins as a viewer for a few seconds, as the stream does.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:18:56 +01:00
CatoandClaude 6bb3d7461c fix(runs): a pull request is a run's only when it is on one of the run's own branches (#1643)
* fix(runs): a pull request is a run's only when it is on one of the run's own branches

Run 70d1a78d on loki ran git status and nothing else; its page claimed
loki#1636 as its pull request and "Pushed:" with that pull request's commit.
#1636 was opened by hand on another branch while the run was open. "The
newest pull request since the run started" is a time window, not an
attribution.

- lib/run-branches: a run's branches are loki/run-<id8>, its worktree branch,
  and every branch its runner reported the agent's checkout on. Never main.
- findRepoWorkEvidence takes those branches; a pull request's head or a
  pushed ref must be one of them. Watch, the reaper's correction and the
  outcome post all pass them.
- The runner's progress beat carries the checkout's branch; the server keeps
  the list on the run (payload.branches).
- The two branch names have one source; the builder code re-exports it.
- scripts/test/run-branches.ts replays the incident against the real finder.

* chore(runner): 0.8.66 with its release note

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:16:35 +01:00
CatoandClaude 546d2ce912 test(terminal): the idle composer test waits for its own mount, not the last one's (#1642)
terminal-idle-browser failed three CI runs on 2026-11-11. The failing runs
took about 40s against 8s when green and ended in a Playwright timeout:
one 30s wait near the end of the file. Every late step starts with mount(),
which re-renders under a new key and then waited for 'textarea', a wait the
previous mount's box already satisfied. root.render commits in a later
task, so on a slow runner the next fill or file went into the old tree and
the remount discarded it.

Reproduced by delaying the remount 12ms and 30ms (same 40s, same timeout
at 'No session is running yet' and 'brief.txt'). mount() now waits for
the box inside its own data-mount wrapper; the delayed runs pass.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:56:01 +01:00
CatoandClaude 46ec257ad2 feat(sessions): an agent's token can list open sessions and read a session's screen (#1641)
An agent could start a project's coding agent in a Loki session, type into
it and close it with a ck_ token (tab-inject, tab-inject-raw, close-tab),
and could even ask for a capture of its screen (POST peek-tab), but the
list of open sessions and the capture's answer took a browser session only.
It could not see that the session was up or read what the agent answered.

- GET /api/control/open-tabs takes a session or a token
- GET /api/control/peek-tab/[id] takes a session or a token, no-store
- POST /api/control/peek-tab takes an optional channel and returns
  resultUrl and openUrl (the same session in Loki's Terminal)
- a plain shell's screen stays a signed-in browser's: a token gets 403 on
  asking and 404 on reading (lib/peek-access)
- LOOP-WALK gains the Session walk; scripts/test/agent-session-read pins it


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:54:44 +01:00
CatoandClaude fab5e0513a fix(inject): a message to a busy project waits its turn; only a caller that asks gets a parallel lane (#1639)
With parallel dispatch on, every dispatch to a busy project forked a lane with
a new agent session. A message sent to orangecat while a run was open
(2026-11-12) started a second agent instead of queueing behind the open run,
while the same message to loki queued: the difference was whether a lane was
free, not what the caller meant.

- orchestration/busy-placement.ts: the one rule. Busy means queue, first in,
  first out; a lane only for whenBusy: "lane".
- executeInject plans a lane only through that rule.
- feedback Implement asks for a lane, as before. /api/inject, the MCP
  loki_dispatch and chat dispatches are messages to the session and queue.
- scripts/test/busy-placement.ts pins the rule and those callers.

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:40:26 +01:00
CatoandClaude 1be367df36 fix(builder): a dispatch starts in the builder's own checkout, never the laptop path (#1638)
* fix(builder): a dispatch starts in the builder's own checkout, never the laptop path

A message to a busy project gets a parallel lane, tab <project>~<run>. On the
cloud builder the checkout was looked up under that tab name: no such project,
nothing to clone, and the stored laptop directory went on to the sandbox
("Sandbox cwd does not exist: /home/g/dev/orangecat", 2026-11-12). The run
died before the prompt arrived.

- dispatchLaunchDir: the project's checkout on this builder first, by project
  name, then the run's worktree of it. A lane without its own worktree, or a
  project the builder can neither find nor clone, is refused with the reason.
- launchAgentPty no longer hands on a directory that is not on the builder,
  and asks for the project's repository and token, not the lane's.
- /api/control/workspace-source answers for a lane tab as for its project.
- scripts/test/dispatch-launch-dir.ts pins it against the real checkout and
  worktree steps.

* chore(runner): 0.8.65 with its release note

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:37:08 +01:00
CatoandClaude 96ec923169 fix(feedback): a closed report never tells a seat the owner has to act (#1637)
A Viewer or Reporter seat polling an archived report read 'the project's
owner or an editor has to act on it. Poll again later', and one marked done
without proof read 'needs the project's owner'. Nobody is going to move a
closed report. seatStatus now says so for closed_without_change and
done_unproven: who nobody, kind none, and what the filer can still do
(look at the live page, file a new report). Open reports are unchanged.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:24:12 +01:00
Cato 0d8a06f099 ops(hetzner): check and repair a corrupt grubenv from a workflow, dry run first (#1636) 2026-11-12 05:14:12 +01:00
CatoandClaude f92111d7f5 fix(feedback): a Viewer seat that filed gets a cause, reason and next step, not a bare Needs you (#1635)
GET /api/feedback/[id]/status gave a non-owner seat only {state, label}, so a
machine filer saw "Needs you" with no cause and no reason. seatStatus adds
cause, reason and a non-dispatching next step, still with nothing of the
machine; filing still starts no build.

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 19:08:47 +01:00
CatoandClaude 7c3d4f1a77 docs(feedback): machine filer role and the scripted agent walk (#1624)
* docs(feedback): machine filer role and the scripted agent walk

Adds the machine filer to the LOKI-WORKS roles table and an Agent walk to
LOOP-WALK with the exact filing contract (seat token, idempotency, statusUrl,
canonical states, build opt-in default off). scripts/walk/agent-walk.mjs files
as an agent from the environment, polls statusUrl and never prints the token.

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

* docs(walk): statusUrl must share the LOKI_URL origin or the walk exits 3

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 14:54:32 +01:00
CatoandClaude ddd57fe562 fix(builder): sealed agents start after a reboot; the cloud builder caps open agent sessions (#1634)
* fix(runner): the cloud builder keeps at most eight agent sessions open

On 2026-11-11 the box had 27 agent CLIs open, about 0.4 GB each, beside 21
live sites on 16 GB. Memory ran out and every site went down. Plain shells
were capped at three; agent sessions were not capped at all.

- lib/agent-session-limit: eight by default (LOKI_AGENT_MAX_OPEN changes
  it), cloud builder only, shells not counted, re-opening an open tab is
  never refused
- /api/agent/launch refuses the ninth with a sentence that says to close
  one; Resume and New session already show that error
- launchAgentPty refuses it again: every way in ends there (launch,
  dispatch, switch, tabs restored after a restart) and the server's count
  can be one heartbeat old

Idle sessions are still not closed by themselves.

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

* fix(builder): sealed agents start again after a reboot; runner 0.8.64

After the power reset of 2026-11-11 every sealed agent failed with 'the
container failed to start: it exited before printing anything'. podman keeps
its runtime state under the runner's $HOME/.run, a real directory, so the
state outlived the reboot and podman refused every container ('current
system boot ID differs from cached boot ID').

- the sealed drop-in gets an ExecStartPre that removes that state when it
  was written before this boot, and leaves it alone otherwise
- sealed-builds.yml mode reset-runtime does the same by hand for a runner
  that is already up
- desktop/package.json 0.8.64 with its release note: the session limit
  changed the runner

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 14:39:00 +01:00
CatoandClaude 0a936f0023 fix(ux): Home and the Terminal say plainly whether anything is running (#1633)
* ops(hetzner): the disk cleanup reaches what actually fills the box

Its first complete run (2026-11-11, dry) would have freed nothing: every
app was already at two releases and the 127G in use was elsewhere. Six
tiers written from that day's usage report, each dry-run first:

- container logs over 200M are truncated (one was 2.2G), syslog rotated
- /opt/<app>/app-prev-* copies older than 14 days (kivvi kept seven from
  July), never the live app or the rollback target
- superseded browser downloads under ~/.cache: the newest of each is kept
- superseded agent CLI versions: the two newest are kept
- pnpm store prune
- node_modules and build output inside checkouts and agent worktrees idle
  for 14 days and not in use; source is never touched

The target percentage is an input (default 75). Database dumps and
Solon's 17G of places-snapshots are deliberately not here.

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

* fix(terminal): the empty screen says nothing is running

After a restart ended every session the page read 'Pick up where you left
off' over rows of project names, and the owner could not tell whether
anything was running (2026-11-11). The fact comes first now, as a status
line; the heading over the rows says what pressing one does.

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

* test: a failed test file shows the end of its output, not one line

The runner printed only the last line a failed file wrote. An uncaught
assertion ends in its stack and a closing brace, so CI named
terminal-idle-browser as failed three times on 2026-11-11 with '    }' and
never said why. It now prints the last 40 lines.

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

* fix(home): one sentence says whether anything is running, with a way to watch it

The foot of Home's status card read '0 working · 0 awaiting input · 32 idle'
over 'Counts only agents Loki started'. The owner, on a phone on 2026-11-11,
could not tell from it whether anything was running or where to see it.

- lib/running-now states it: 'Nothing Loki started is running right now',
  'N agents working now', or that something waits for a reply
- working agents get a Watch link to the Terminal; a waiting one gets Reply
- the idle count (every project doing nothing) is gone; the caveat about
  agents Loki did not start is in the sentence, not a second line

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 13:45:05 +01:00
CatoandClaude c403e23fb2 ops(hetzner): the disk cleanup reaches what actually fills the box (#1631)
Its first complete run (2026-11-11, dry) would have freed nothing: every
app was already at two releases and the 127G in use was elsewhere. Six
tiers written from that day's usage report, each dry-run first:

- container logs over 200M are truncated (one was 2.2G), syslog rotated
- /opt/<app>/app-prev-* copies older than 14 days (kivvi kept seven from
  July), never the live app or the rollback target
- superseded browser downloads under ~/.cache: the newest of each is kept
- superseded agent CLI versions: the two newest are kept
- pnpm store prune
- node_modules and build output inside checkouts and agent worktrees idle
  for 14 days and not in use; source is never touched

The target percentage is an input (default 75). Database dumps and
Solon's 17G of places-snapshots are deliberately not here.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 13:07:04 +01:00
CatoandClaude 1d44192e3a ops(hetzner): the usage report looks one level into the large directories (#1630)
* ops(hetzner): the usage report looks one level into the large directories

The first report (2026-11-11) named what was large and not why: /opt/solon
at 18G with two releases, 22G of caches under /home/ubuntu, 16G of
checkouts. The cleanup's dry run then showed it would free nothing, since
none of that is in the places it prunes.

The report now lists the largest entries inside each of those directories,
counts node_modules and build output inside checkouts, and names files
over 500M. Each listing has a time budget. Still read-only.

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

* ops(hetzner): the usage report measures databases and their dumps

Solon keeps place photographs as bytes in Postgres, and every database is
dumped nightly and kept 14 days. Neither shows in a du of /opt or /home,
and the first report did not look at /var/lib/postgresql at all. It now
prints the size of each database, the five largest tables of the three
largest (names and sizes only), and the dumps' total per database.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 12:24:53 +01:00
CatoandClaude cf7b404820 fix(ux): signed in means the app; a task shows what was asked; sessions lead with what needs you; key names for OrangeCat (#1629)
* design: Loki has no orange; the public call to action is the achromatic accent

The app's own buttons went monochrome on 2026-10-19; the public site kept
a warm orange (#ff5c00) on Start a project, Get started, the auth submit,
the focus ring and the essay progress bar. It is not Bitcoin orange and it
means nothing on a product that is not about Bitcoin (owner, 2026-11-11).

- --accent-warm, --accent-warm-hover and --public-accent are removed; every
  class that used them reads --accent-primary / --accent-hover, so one
  filled button exists in Loki and it is theme-aware
- --on-accent is the inverted text. It was a fixed near-black, which on the
  near-black light-theme accent left .ui-btn-xs.ui-btn-primary unreadable
- the focus ring and the public glow are neutral
- token-drift declares the divergence from @bitbaum/design-tokens; the
  widget theme is regenerated from the tokens

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

* fix(workbench): a failed task says why and gives the words back

Sent an OrangeCat task from the workbench on 2026-11-11. Claude was signed
out on the cloud runner; the status API said so with the fix, and the
composer showed the two words 'Dispatch failed' over an emptied box.

- dispatchFailureForPerson: a signed-out agent is named in the sender's
  words; any other reason is passed through instead of dropped
- the composer shows that reason under the label and offers 'Put my words
  back', since the box is cleared on send

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

* fix(nav): the phone's chat screen names Home, Projects and Terminal

The owner, signed in on a phone on 2026-11-11, could not find the terminal.
The chat is the default screen and hides the tab bar; its left button opened
a list of chats and nothing else, and its menu offered 'Projects' (which
only set the chat's project) and 'Everything else'. The page itself was
called Sessions, so no menu contained the word.

- CHAT_PLACES (config/navigation.ts) is one list of Home, Projects, Terminal
- the chat menu lists them by name, then 'All pages'; the item that sets
  the chat's project says so
- the chats panel the left button opens lists the same three, phones only
- the page is called Terminal in the nav, its title and its links

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

* fix(sessions): a signed-out Claude is one button in the chat view

A session opens in its Chat view. When Claude's login had expired, that view
showed the agent's own line, 'Please run /login', and reply chips that would
fail the same way; the 'Sign in /login' button existed only in the Terminal
view. The owner, on a phone, could not find how to sign in (2026-11-11).

The chat view reads the reply through the same detector as the terminal
(screenActions) and offers 'Sign Claude in', which types /login and switches
to the terminal where the link is printed.

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

* fix(ux): signed in means the app, and a retried task shows what was asked

Two more things the owner met on a phone on 2026-11-11.

- Opening loki.orangecat.ch while signed in showed the marketing page and
  its marketing menu; the way in was a button. A signed-in visitor now lands
  in the app (APP_HOME; RUNNER_HOME inside Fleet Runner). ?site still opens
  the homepage on purpose, and signed-out visitors are unchanged.
- A retried dispatch opens with the escalation block, longer than the 200
  characters isOperatorEnvelope read, so the whole packet ('Escalation
  state … rung 3/4', 'Exit contract') was drawn as the person's message. It
  is recognised now; the bubble shows the task, the packet is one tap away.

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

* feat(orangecat): tell OrangeCat which provider keys a person holds here, by name

The owner's xAI key was on Loki and not on OrangeCat: for the same linked
person Loki's chat answered on grok while OrangeCat's Cat sat on an
exhausted free pool, and neither product could say the other had a key.

The signed actor-status reply now carries modelKeys: vendor, model and the
last-characters hint, one per vendor, never a custom endpoint and never a
key. OrangeCat uses it to suggest adding the same key there.

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

* fix(sessions): the phone's session list leads with what needs you

The picker listed every open session in the order it was opened: 27 rows,
'Loki 2' to 'Loki 15', with the three waiting on the owner somewhere among
them (2026-11-11). orderSessions puts waiting, working and finished
sessions first, with the one in use, and folds the merely-open ones behind
one row, 'N more open sessions'.

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

* ops(hetzner): a read-only report of what uses the box's memory and disk

On 2026-11-11 the box sat at 91-95% memory and 91-93% disk; both sites
reset connections and CI could not sign in against production auth, and
nothing could say what was using either. disk-cleanup.sh reclaims disk;
nothing measured memory.

box-usage.yml runs scripts/hetzner/box-usage.sh over the same SSH setup as
box-doctor. It prints memory by program (names only, never a command
line), agent CLI and browser counts, out-of-memory kills, container
memory, and the largest directories, and changes nothing.

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

* fix(ops): the disk cleanup measures within a budget, so it reaches its plan

Its first run (2026-11-11, dry) was cancelled at 30 minutes having printed
four sizes and planned nothing: du on /opt alone took 14 minutes on a disk
full of node_modules, and the script measures every release before it
plans a single tier. Sizes are for the reader; what was freed is read from
df. Each size now gets 45 seconds and prints 'over 45s' instead of waiting.
The inventory also names /home/ubuntu and the agent directories under it,
which the first run never reached. Workflow limit raised to 60 minutes.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 10:38:32 +01:00
CatoandClaude Fable 5.2 9ac77daea4 fix(nav): a phone can find the Terminal and sign Claude in; a failed task says why (#1628)
* design: Loki has no orange; the public call to action is the achromatic accent

The app's own buttons went monochrome on 2026-10-19; the public site kept
a warm orange (#ff5c00) on Start a project, Get started, the auth submit,
the focus ring and the essay progress bar. It is not Bitcoin orange and it
means nothing on a product that is not about Bitcoin (owner, 2026-11-11).

- --accent-warm, --accent-warm-hover and --public-accent are removed; every
  class that used them reads --accent-primary / --accent-hover, so one
  filled button exists in Loki and it is theme-aware
- --on-accent is the inverted text. It was a fixed near-black, which on the
  near-black light-theme accent left .ui-btn-xs.ui-btn-primary unreadable
- the focus ring and the public glow are neutral
- token-drift declares the divergence from @bitbaum/design-tokens; the
  widget theme is regenerated from the tokens

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

* fix(workbench): a failed task says why and gives the words back

Sent an OrangeCat task from the workbench on 2026-11-11. Claude was signed
out on the cloud runner; the status API said so with the fix, and the
composer showed the two words 'Dispatch failed' over an emptied box.

- dispatchFailureForPerson: a signed-out agent is named in the sender's
  words; any other reason is passed through instead of dropped
- the composer shows that reason under the label and offers 'Put my words
  back', since the box is cleared on send

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

* fix(nav): the phone's chat screen names Home, Projects and Terminal

The owner, signed in on a phone on 2026-11-11, could not find the terminal.
The chat is the default screen and hides the tab bar; its left button opened
a list of chats and nothing else, and its menu offered 'Projects' (which
only set the chat's project) and 'Everything else'. The page itself was
called Sessions, so no menu contained the word.

- CHAT_PLACES (config/navigation.ts) is one list of Home, Projects, Terminal
- the chat menu lists them by name, then 'All pages'; the item that sets
  the chat's project says so
- the chats panel the left button opens lists the same three, phones only
- the page is called Terminal in the nav, its title and its links

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

* fix(sessions): a signed-out Claude is one button in the chat view

A session opens in its Chat view. When Claude's login had expired, that view
showed the agent's own line, 'Please run /login', and reply chips that would
fail the same way; the 'Sign in /login' button existed only in the Terminal
view. The owner, on a phone, could not find how to sign in (2026-11-11).

The chat view reads the reply through the same detector as the terminal
(screenActions) and offers 'Sign Claude in', which types /login and switches
to the terminal where the link is printed.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 09:31:18 +01:00
CatoandClaude ff434ac3ec design: Loki has no orange; the public call to action is the achromatic accent (#1627)
The app's own buttons went monochrome on 2026-10-19; the public site kept
a warm orange (#ff5c00) on Start a project, Get started, the auth submit,
the focus ring and the essay progress bar. It is not Bitcoin orange and it
means nothing on a product that is not about Bitcoin (owner, 2026-11-11).

- --accent-warm, --accent-warm-hover and --public-accent are removed; every
  class that used them reads --accent-primary / --accent-hover, so one
  filled button exists in Loki and it is theme-aware
- --on-accent is the inverted text. It was a fixed near-black, which on the
  near-black light-theme accent left .ui-btn-xs.ui-btn-primary unreadable
- the focus ring and the public glow are neutral
- token-drift declares the divergence from @bitbaum/design-tokens; the
  widget theme is regenerated from the tokens


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 08:50:21 +01:00
Cato 7909050674 ops(hetzner): add a dry-run-first box disk cleanup workflow (#1623)
The bitbaum root disk is over 90%. This adds a workflow_dispatch job,
defaulting to dry_run=true, that SSHes with the existing deploy key and
reclaims reconstructible space only: journals, apt and npm caches, release
dirs beyond current+previous, unused Docker images and build cache, old
rotated logs, and Postgres dumps older than 14 days. It never touches
volumes, databases, running containers, shared env, or the live/previous
release. It also reports and, when the unit already exists, re-enables
disk-gc.timer and pg-backup.timer if they were simply disabled.
2026-11-10 12:21:24 +01:00
Cato 34788ad397 feat(feedback): Failed and Done honesty for agent callers (#1622)
Failed and Needs you always carry a reason and an exact next action (with the
dispatch call). Done needs PR, merge, deploy and a live URL, else Needs you
(done_unproven, with what is missing). Closed without a change is Failed, not
a Done with empty evidence. Reporter state now reads the same live URL.

Claude-Session: https://claude.ai/code/session_019MDtmuk1DzMJHBJdsDfRhG
2026-11-10 12:01:33 +01:00
CatoandClaude ec1e7c1ba1 chore(deps): bip-kit, limitkit, ai-forms and threadkit from the @bitbaum scope (#1621)
Owner, 2026-11-06: the fleet's packages belong under the @bitbaum npm
organization (fleet docs/package-scope-migration-plan.md). Only Loki's own
dependency keys and import specifiers move. The register-facing files stay as
they are until fleet's registers name the scoped packages: the generated
fleet-brief snapshot and starter app, the site-template mirror (changed only by
scripts/templates/sync-starter.sh), the kit plan and its tests.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 11:49:48 +01:00
Cato baac8dec3b feat(feedback): owner-only switches for agent auto-build and editor dispatch (#1620)
user_projects.agent_builds_unasked: an agent's report builds on the
owner's builder without a tap. user_projects.editors_may_build: an editor
may use dispatch on the owner's builder. Both nullable, default off, set
by the owner at /api/projects/[id]/build-grants. Filing alone never builds
unless the owner opted in; every other seat still never dispatches.

Claude-Session: https://claude.ai/code/session_019MDtmuk1DzMJHBJdsDfRhG
2026-11-10 11:38:06 +01:00
Cato 57f9cfe467 ci-gate: count only push and pull-request runs as CI, so the sweep cannot hold deploys (#1618)
The auto-merge sweep (event workflow_run) runs on main's SHA every time any
pull request's CI finishes. The gate counted it as CI, so a deploy waited at
PENDING until the sweep went quiet: solon's #484 had CI green at 09:24 UTC on
2026-11-10 and its deploy only passed the gate at 09:36, and every merge in
the queue waited behind that. A chained data job (places-data) failing would
also have blocked a deploy, the same class as the 2026-11-01 data-load bug.

The event test becomes an allowlist (push, pull_request, pull_request_target,
merge_group), matching the rule the comment already states. Four new cases in
test-ci-gate.sh; 22 pass.
2026-11-10 11:26:32 +01:00