viewable-one 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +2 -2
  3. package/SPAWN.md +107 -53
  4. package/glytch.mjs +41 -10
  5. package/lib/acp.mjs +110 -148
  6. package/lib/admission.mjs +25 -5
  7. package/lib/agents.mjs +59 -16
  8. package/lib/answerTag.mjs +47 -0
  9. package/lib/atomic.mjs +1 -16
  10. package/lib/auth.mjs +25 -9
  11. package/lib/boardside.mjs +28 -12
  12. package/lib/child.mjs +89 -116
  13. package/lib/claudeModels.mjs +168 -0
  14. package/lib/codex-rpc.mjs +2 -2
  15. package/lib/codex.mjs +43 -63
  16. package/lib/codexApps.mjs +5 -3
  17. package/lib/codexToolInputs.mjs +98 -22
  18. package/lib/codingChecks.mjs +8 -4
  19. package/lib/conversationRules.mjs +46 -6
  20. package/lib/detect.mjs +14 -23
  21. package/lib/devserver.mjs +6 -6
  22. package/lib/doctor.mjs +4 -2
  23. package/lib/folderReads.mjs +96 -0
  24. package/lib/followUps.mjs +170 -0
  25. package/lib/hosted.mjs +13 -4
  26. package/lib/init-connect.mjs +29 -10
  27. package/lib/lateResume.mjs +135 -0
  28. package/lib/logindaemon.mjs +113 -33
  29. package/lib/mcpjson.mjs +35 -2
  30. package/lib/multiwatch.mjs +25 -38
  31. package/lib/pagePictures.mjs +14 -11
  32. package/lib/paths.mjs +0 -1
  33. package/lib/permissionAsk.mjs +341 -58
  34. package/lib/procs.mjs +73 -2
  35. package/lib/refusal.mjs +0 -2
  36. package/lib/restartPass.mjs +39 -11
  37. package/lib/rowsAnswers.mjs +18 -34
  38. package/lib/rowsEvents.mjs +20 -2
  39. package/lib/runner-health.mjs +26 -2
  40. package/lib/runner.mjs +106 -1363
  41. package/lib/runnerAdmission.mjs +6 -12
  42. package/lib/runnerApi.mjs +20 -11
  43. package/lib/runnerBeat.mjs +384 -0
  44. package/lib/runnerCompletion.mjs +5 -2
  45. package/lib/runnerExecute.mjs +227 -0
  46. package/lib/runnerGates.mjs +338 -0
  47. package/lib/runnerLaunch.mjs +351 -0
  48. package/lib/runnerLease.mjs +31 -9
  49. package/lib/runnerOps.mjs +217 -0
  50. package/lib/runnerPace.mjs +10 -6
  51. package/lib/runnerRecovery.mjs +457 -0
  52. package/lib/runnerRegister.mjs +28 -7
  53. package/lib/runnerSettlement.mjs +29 -9
  54. package/lib/spawn.mjs +0 -5
  55. package/lib/sync.mjs +26 -14
  56. package/lib/viewableFolder.mjs +8 -2
  57. package/lib/worktree.mjs +66 -13
  58. package/lib/writePolicy.mjs +90 -10
  59. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -13,6 +13,53 @@ package.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [0.12.3] - 2026-11-09
17
+
18
+ ### Fixed
19
+
20
+ - On Windows, signing in opens the browser with the whole link. It used to go
21
+ through `cmd`, which cut the link at the first `&` (so the sign-in page had
22
+ no client id) and could run text after it as commands. The link now goes to
23
+ the browser as one argument with no shell, and only `http` and `https` links
24
+ are opened.
25
+ - Pressing Ctrl-C on `viewable runner watch` stops it at once on a Mac whose
26
+ file-event service has stopped answering. It used to hang forever, waiting
27
+ for that service while closing its watch on the registry folder. The
28
+ registry file is now checked for changes about once a second instead.
29
+
30
+ ### Added
31
+
32
+ - A shell command's ask in the idea offers "Allow for this run": one tap
33
+ allows the command and every later command of the same run without asking.
34
+ Nothing is written to the folder's saved permissions, so the next run asks
35
+ again, and Stop and the wall clock still end the run. A task that drives a
36
+ Mac app step by step sent eleven slightly different commands, and "Always
37
+ allow" (that exact command only) never covered the next one (#4105, #4106).
38
+
39
+ ### Fixed
40
+
41
+ - `viewable init` and `viewable doctor` no longer tell a logged-out Claude
42
+ Code to "run `claude` once and log in", and init's Codex line no longer
43
+ says "from a terminal". They name the verb the pasting agent runs itself
44
+ (`claude auth login`, `codex mcp login viewable`), so a person connecting
45
+ through the setup prompt is never sent to a terminal to type a command
46
+ (#4205).
47
+
48
+ - A run is told to leave progress to its plan and session log, to treat its
49
+ closing message as the one reply, and to put the answer itself on anything
50
+ it adds to the board, never a note saying where it is. This is wording only:
51
+ nothing yet stops a run that ignores it from posting step messages (#4093).
52
+ - A shell command's ask is titled with the agent's own words ("Can I clear
53
+ Calculator with Escape, type 12 x 34, copy the result?"), never the command cut off
54
+ with "...", and its Always button says what it saves: "Always allow this
55
+ command in <folder>" for anything off the short safe list. Version 0.12.2
56
+ still showed "Can I run <command> in <folder>?" and "Always allow in
57
+ <folder>" (#3609, #3683, #3726, #4102, #4103).
58
+ - A Claude Code run for an agent that keeps an OpenRouter model id such as
59
+ `anthropic/claude-haiku-5.5` passes the model's short name (`haiku`) to
60
+ `--model`, because Claude Code refuses the OpenRouter id. Other ids pass
61
+ through unchanged (#3869). The fix reaches people with the next bridge
62
+ release.
16
63
  ## [0.12.2] - 2026-10-30
17
64
 
18
65
  ### Changed
package/README.md CHANGED
@@ -259,7 +259,7 @@ open](#reading-the-board-with-no-app-open).
259
259
  | --- | --- |
260
260
  | `get_board(board_id?, tag?, group?, kind?, since_days?, match?, limit?, view?, geometry?, detail?)` | The board as a readable digest: ids, one line per idea, groups, edges, question state, open flags, ages. Slim by default. The filters narrow it, and the reply always says what it left out. `view:"full"` returns everything, `geometry:true` adds positions and sizes. |
261
261
  | `get_node(id)` | One node in full from the graph mirror, with its incoming and outgoing edges. Images attached to the idea come back as image blocks to look at, each labelled with the node and field it came from. An image the mirror does not hold is named as unavailable rather than quietly left out. |
262
- | `get_library()` | The component library a DRAWN idea is written against, generated from the same registry the app renders with: every tag, its attributes, which are required, a working example, and the rules a drawing must keep. Read it once before passing `snippet` on `addIdea` or `addTextNote`. About 2k tokens, so once per session, not once per drawing. |
262
+ | `get_library()` | The component library a DRAWN idea is written against, generated from the same registry the app renders with: every tag, its attributes, which are required, a working example, and the rules a drawing must keep. Read it once before passing `snippet` on `addIdea`. About 2k tokens, so once per session, not once per drawing. |
263
263
  | `propose(ops[], label?)` | Sends board change requests and returns its op id. Every create, edit and delete lands as a proposal you accept or reject. |
264
264
  | `ask_user(question, why, options?, from_id?)` | Adds a question to an idea's conversation and returns at once; the answer comes back through `check_answer` or `collect_session`. `why` is required: it is shown under the question and is the context that travels with it. With no `from_id` the question goes on the idea the run belongs to. |
265
265
  | `check_answer(question_id, wait_s?)` | Where an earlier question stands: answered with the decision, still open, dismissed, or not yet ingested. With `wait_s` (up to 50) it waits that long for the answer and returns as soon as it lands; an agent that cannot go on without the answer keeps calling it until it is answered or dismissed. |
@@ -621,7 +621,7 @@ Common failures, and what the row says:
621
621
  | `daemon loaded not loaded` | The OS does not have `ai.glytch.runner`. Run `viewable init` from this project folder. |
622
622
  | `daemon loaded no systemd here` | An older WSL with no `systemctl --user`. Run `PM_SPAWN_RUNNER=on viewable runner watch` instead. |
623
623
  | `coding agents none` | "no coding agent on PATH - install Claude Code, opencode or Codex". |
624
- | `Claude Code login logged out` | "run `claude` once and log in, or sessions fail at spawn". |
624
+ | `Claude Code login logged out` | "run `claude auth login` to sign in, or sessions fail at spawn". |
625
625
  | `git missing` (a warning) | "no git - sessions run unisolated in the linked folder, with no worktree of their own". On Windows the row adds that Claude Code's Bash tool needs Git for Windows. |
626
626
  | `.mcp.json unreadable` | The file exists and is not JSON glytch can extend. It is your work, so nothing was written: add the `viewable` server by hand. |
627
627
  | `version unknown` | npm did not answer. Being offline is not a broken install. |
package/SPAWN.md CHANGED
@@ -109,7 +109,9 @@ to rows did not change.
109
109
  the same way every other hosted call in this package resolves one, POST to
110
110
  `supabase/functions/board-runner/`.
111
111
 
112
- `bridge/lib/runner.mjs` reads and writes rows, not files, for every request
112
+ `bridge/lib/runner.mjs` (with the pieces it was split into in #4668:
113
+ `runnerGates.mjs`, `runnerExecute.mjs`, `runnerLaunch.mjs`, `runnerOps.mjs`,
114
+ `runnerBeat.mjs`) reads and writes rows, not files, for every request
113
115
  kind, chat turns included. What replaces each piece that used to be a file
114
116
  under `.glytch/inbox/spawn/`:
115
117
 
@@ -125,7 +127,7 @@ under `.glytch/inbox/spawn/`:
125
127
  | the shared-preview request/receipt pair (`.glytch/inbox/preview/`) | a `run_ops` row of `kind:"preview"` - claimed once (`opTake`), its proofs read from the claimed run row (`runnerApi.runs`) and from `get_node` over `hosted.callTool`, never from `canvas/`; `opResult` ticks through starting/ready/offline/error on the SAME op row, since preview (unlike merge/delete/relaunch) is not one-shot - `bridge/lib/sharedPreview.mjs`'s `createSharedPreviewService` tracks it across beats |
126
128
  | `<id>.reply-*.json` promoted to a new request | the `resume` op - one call, no file, no `createdBy:"runner"` request to write. Carries `images` (a late message's own, same shape a reply file's `images` array used) when the message had any - `runnerApi.mjs`'s own header says why the OP does not declare the field yet on its side |
127
129
  | the `startSession`/`endSession` ops files, and the wait for their receipt | nothing - `claim` moving a row to `status:'running'` IS the start; there is no more window to guard |
128
- | a chat-turn's request FILE, `<id>.stop`, its per-room lock (`activeChatTurnForRoom`, disk-scanned) | the same row contract as an ordinary session, plus `activeChatTurnForRoomRows` (`runner.mjs`) in place of the per-idea lock - a chat turn has no idea behind it, so its lock is per `roomId` instead |
130
+ | a chat-turn's request FILE, `<id>.stop`, its per-room lock (`activeChatTurnForRoom`, disk-scanned) | the same row contract as an ordinary session, plus `activeChatTurnForRoomRows` (`runnerGates.mjs`) in place of the per-idea lock - a chat turn has no idea behind it, so its lock is per `roomId` instead |
129
131
 
130
132
  **Admission, leases and completion recovery (2026-09-26).** Admission refuses
131
133
  unavailable concurrency or spending reads. Each claim carries an instance UUID
@@ -918,36 +920,65 @@ at all - a CLI request or a conversational session has nothing to collect, and
918
920
  Wired only when the run has a bearer to send at all (`viewable login` or
919
921
  `VIEWABLE_BOARD_TOKEN`); with neither, there is nothing on the hosted
920
922
  endpoint for the child to have asked in the first place.
921
- - **After the child exits**, ONE more `collect_session` call
922
- (`promoteLateRows`) catches whatever arrived in the gap between the last
923
- live poll and the exit, called from `completeRequest` right after the
924
- receipt is written. `promoteLateRows`'s `promote` callback is
925
- `runnerApi.resume`, for every request kind, chat turns included: the
926
- runner sends one `resume {runId, message}` call and the board-runner
927
- function inserts the approved child run row server-side.
928
- `acceptsMessages`' one-shot-vs-persistent distinction decides "logged and
929
- dropped" vs "resumed" the same way it always has. A content-addressed id
930
- (`lateRowRequestId`) keeps a duplicate promotion attempt from filing the
931
- same resume twice.
932
- - **The one known gap**, spelled out rather than hidden: a MESSAGE that
933
- arrives in the same poll tick the child happens to exit on is marked
934
- `delivered_at` by that fetch whether or not `sendToChild` actually got to
935
- write it before the pipe closed - `watchAnswers` breaks its delivery loop
936
- the moment the child is settled, before calling `onDelivered`. Such a
937
- message is not "late" (it was already fetched) and will not come back on
938
- a later poll either (the server will not hand it back). An ANSWERED
939
- QUESTION has no such gap - it carries no `delivered_at`, so it is simply
940
- asked for again, here or on the next live poll, until this run's own
941
- delivered-set has actually recorded it.
942
-
943
- The file-based reply path (`<id>.reply-*.json`) stays working alongside this:
944
- a human typing into a running session still goes straight down the same
945
- stdin door, file or row.
946
-
947
- A session collects with the `collect_session` tool, passing `since`. The
948
- watermark is the caller's, not the daemon's, so it survives a restart, and
949
- `since: 0` reads everything. An EXITED session cannot be woken - that is a
950
- new session, which is a spend, which is a click.
923
+ - **After the child exits**, `promoteLateRows` sends the last delivery
924
+ acknowledgements. Messages stay undelivered until the finished run's
925
+ continuation is allowed or declined. The heartbeat's `resumeLateMessages`
926
+ asks the existing `runs` maintenance operation for app runs that ended
927
+ `done`, `error` or `stopped` (the statuses `resume` accepts) with
928
+ undelivered session messages. Active work on the same idea or chat room
929
+ takes priority. The server finds them from the sessions that hold an
930
+ uncollected message, not by reading every run of the folder. Reply events
931
+ for a run this process is not running, and reconnects, wake collection
932
+ at once; otherwise it checks once a minute while a message waits and once
933
+ every five minutes while none does (#5106).
934
+ - **Ask before continuing.** A late review decision (or another session
935
+ message) files the existing permission question on the idea: Allow,
936
+ Not this, Always allow in <folder>. No spend dialog or second confirmation.
937
+ The normal question UI records the answer; only the runner consumes a
938
+ permission answer, even after the original session finished. Chat turns
939
+ use the same board ask without a source idea; their continuation stays a
940
+ chat turn in the original room. (#5103) The app parks a row on that new
941
+ chat turn (`request.continues` names the turn it carries on), so its
942
+ reply shows in the chat or DM like any other; a carried-on turn that
943
+ ended over an hour before the app saw it stays in its log (#5106).
944
+ - **One question per message.** The ask carries the promotion id as
945
+ `ask_key`; `ask_user` returns the question already filed under that key
946
+ in that session, so an ask whose reply was lost, or whose saved receipt
947
+ failed to write, never files a second question. An Always allow given on
948
+ another ask releases a still-open one on the next beat; an answer given on
949
+ the ask itself wins (#5106).
950
+ - **Always allow** uses `permissionAsk.mjs`'s folder memory, with a separate
951
+ continuation key scoped to the account and project. It does not grant any
952
+ tool permission. Pending question ids and decisions survive watcher
953
+ restarts in `VIEWABLE_HOME/resume-asks`; unreadable receipts fail closed.
954
+ A declined or dismissed ask marks its message as not delivered (the run's
955
+ `sidecar.undelivered`, which the app shows with Try again) and then
956
+ acknowledges it without starting work.
957
+ - **Allow** uses `runnerApi.resume`, preserving the session, worktree and
958
+ message images. A message-id-derived `lateRowRequestId` travels as
959
+ `promotionId`; a retry returns the same child, including after an insert
960
+ acknowledgement was lost. Only then is the message acknowledged. An ask or
961
+ resume that could not reach the endpoint, or a resume refused while other
962
+ work on the idea runs, leaves it waiting. A failure on the server's side
963
+ (a crash, or a board write that lost a race) comes back marked as a fault,
964
+ not a refusal, so it waits too instead of declining the message. A stopped
965
+ run whose child was already filed returns that child (#5106).
966
+ - **Never left unread (#5101).** A message that cannot be continued is
967
+ declined the same visible way, with no question: a run whose Stop was asked
968
+ for, an unapproved run, a run with no conversation to resume, an ask the
969
+ endpoint refused, or a resume the server refused. The mark is written before
970
+ the acknowledgement, so a failed mark leaves the message for the next beat. Older messages without ids use their
971
+ content hash. The runner still requires `PM_SPAWN_RUNNER=on`, approval,
972
+ available concurrency and its normal wall clock. Tests use fake agents.
973
+
974
+ A session collects with `collect_session`, passing its own `since` watermark.
975
+ Live delivery remains unchanged. Finished app sessions continue only after
976
+ Allow or a previously saved Always allow choice; external sessions without
977
+ an app run are not started by this pass. A run the person stopped stays
978
+ stopped. The heartbeat's own calls under a finished run's key do not refresh
979
+ that session's `last_seen_at` (`rowStore.touchSession`), so a finished run
980
+ never looks alive to `list_sessions` or `send_message`.
981
+ Installed bridges must be released through the existing release workflow.
951
982
 
952
983
  **Images travel the same doors.** A message's `images` travel into `resume`
953
984
  alongside `message` when the poll has any (`rowsAnswers.mjs`'s
@@ -1127,7 +1158,7 @@ on its own.
1127
1158
  ## Signal files - stop, merge, delete, relaunch
1128
1159
 
1129
1160
  `stop`, `merge`, `delete` and `relaunch` are all rows - `heartbeat`'s `stops`
1130
- array and its `ops` + `opTake`/`opResult` (`bridge/lib/runner.mjs`'s
1161
+ array and its `ops` + `opTake`/`opResult` (`bridge/lib/runnerOps.mjs`'s
1131
1162
  `serviceRowOps`) - for every request kind, chat turns included. `relaunch`'s
1132
1163
  record is the claimed run row's own `server` column (mirrored there by
1133
1164
  `runnerCompletion.mjs` when the child exits), falling back to the op's
@@ -1179,7 +1210,7 @@ put. Then the copy and its branch are deleted. Nothing is pushed.
1179
1210
  Added 2026-08-30. The ruling on `q-mtf2x89x`: "Only one session per idea,
1180
1211
  unless the old session lost its worktree."
1181
1212
 
1182
- `activeWorktreeForPromptRows` in `bridge/lib/runner.mjs` reads this project's
1213
+ `activeWorktreeForPromptRows` in `bridge/lib/runnerGates.mjs` reads this project's
1183
1214
  run rows through `runnerApi.runs`, then checks whether a worktree for the
1184
1215
  given idea still exists on disk AND its branch has not been merged into
1185
1216
  main. Both halves matter: without the merged check, a finished session
@@ -1216,7 +1247,7 @@ talked to it.
1216
1247
  earlier) shipped the ordinary session path over rows and refused a
1217
1248
  chat-turn row outright, naming the per-room lock and the chat worktree mint
1218
1249
  as file-shaped work not migrated in that pass. Both are rows now: the
1219
- per-room lock is `activeChatTurnForRoomRows` (`bridge/lib/runner.mjs`,
1250
+ per-room lock is `activeChatTurnForRoomRows` (`bridge/lib/runnerGates.mjs`,
1220
1251
  `runnerApi.runs({..., status:'running'})` filtered to `isChatTurn(request)`
1221
1252
  and a matching `roomId`) in place of a disk scan for an unreceipted claim;
1222
1253
  the chat worktree mint (`makeChatWorktree`/`resolveChatCwd`,
@@ -1224,7 +1255,7 @@ the chat worktree mint (`makeChatWorktree`/`resolveChatCwd`,
1224
1255
  called from the file-based runner, and is called from the rows one now the
1225
1256
  same way. Every difference below is unchanged in what it means; only the
1226
1257
  DOOR each one reaches through moved (a run row and `runnerApi` calls, not a
1227
- signal file) - marked `chat turn:` at each site in `runner.mjs` exactly as
1258
+ signal file) - marked `chat turn:` at each site in `runnerGates.mjs` and `runnerExecute.mjs` exactly as
1228
1259
  they are marked here.
1229
1260
 
1230
1261
  **The request is the same shape, riding a row's `request` column, with one
@@ -1279,7 +1310,7 @@ new field.**
1279
1310
  chat turn does not have. What a chat turn is told is the app's to compose:
1280
1311
  persona, the room's context blocks, his message.
1281
1312
  4. **A per-ROOM lock instead of the per-prompt one.** OVER ROWS (brief 30
1282
- Move 2b): `activeChatTurnForRoomRows` (`lib/runner.mjs`) asks
1313
+ Move 2b): `activeChatTurnForRoomRows` (`lib/runnerGates.mjs`) asks
1283
1314
  `runnerApi.runs({..., status:'running'})` and filters to
1284
1315
  `isChatTurn(request)` with a matching `roomId`, so two runners sharing a
1285
1316
  project share one answer the same way the file version's disk scan did.
@@ -1553,13 +1584,21 @@ pictures with `images` (up to 6, data URLs) and to choose between looks with
1553
1584
  `ask_user` and `images`. It also tells the session not to file a closing reply
1554
1585
  of its own, because the runner files one.
1555
1586
 
1587
+ The hosted board enforces it (#4153): a run's second reply in its idea's
1588
+ conversation, with no person's note after its first, is refused and names
1589
+ `editComment`, which changes that one reply in place. The closing reply is
1590
+ told apart by its `propose` label, `Session <key> outcome`
1591
+ (`commentOnAnchor`), so renaming that label breaks the rule. It is never
1592
+ refused; it folds into the run's earlier reply. Questions and ideas are not
1593
+ limited.
1594
+
1556
1595
  **One reply at the end, for a session that finished.** When a session
1557
1596
  finishes (the verdict is `finished`, or a Codex run exits 0),
1558
1597
  `reportOutcomeOnBoard` posts exactly one `addComment` on the idea, with
1559
1598
  `agentId`, `runId` (the session's own key), `summary` (first sentence of the
1560
1599
  closing text, at most 200 characters), `images` (at most 6), and
1561
1600
  `branch`, `files`, `preview`, `report` for the links. Its text is the closing
1562
- text of the session (the tail, at most 2000 characters), then a single figures
1601
+ text of the session (preserved in full; the hosted writer splits overflow into linked ideas), then a single figures
1563
1602
  line led by "Finished": "Finished; 12 turns, 4m, branch x, 3 files". It
1564
1603
  never carries a cost (#281). A stop, an error, a stall, a timeout and a binary that would not start
1565
1604
  write NO comment from the bridge: the app writes those endings itself from the
@@ -1689,6 +1728,7 @@ unscoped, so the session may write any path the process can reach.
1689
1728
  | --- | --- | --- |
1690
1729
  | tools | anything not on `CLAUDE_TOOLS` | everything on it |
1691
1730
  | interactive prompts | `EnterPlanMode`, `AskUserQuestion` | - |
1731
+ | clicking or typing in other apps (#4204) | Claude Code: `osascript`, `screencapture`, `cliclick` as a command's first word (`CLAUDE_CLICK_AND_SCREEN_TOOLS`); then on every Claude ask and Codex escalation, any command with one of them as a word, whatever "Allow for this run" or a saved rule says (`drivesAnotherApp`, permissionAsk.mjs); both agents are told in words | the same program started from `node -e` or a script, and a Codex command that runs without asking inside its sandbox |
1692
1732
  | arbitrary code | - | `node -e`, `npx <anything>` |
1693
1733
  | writes | the checkout you are looking at (the **worktree** does this, not the list) | any other path the process can reach |
1694
1734
  | money | wall clock, no retry | - |
@@ -1723,18 +1763,30 @@ silently. `lib/permissionAsk.mjs` owns it; `child.mjs` answers Claude's
1723
1763
  `control_request` and `codex.mjs` answers Codex's approval requests with it.
1724
1764
 
1725
1765
  - One `ask_user` question on the run's idea: "Can I run pip install requests
1726
- in my-app?", with Allow (recommended), Not this and Always allow in
1727
- <folder>, and a line on what it is for.
1766
+ in my-app?", with Allow (recommended), Not this and Always allow, and a line
1767
+ on what it is for. Always covers a family only for a short safe list of
1768
+ read-only or test commands (`ls`, `cat`, `pwd`, `head`, `tail`, `wc`,
1769
+ `git status`, `git diff`, `git log`, `git show`, `npm test`,
1770
+ `npx vitest run`), and its button names the family ("Always allow git status
1771
+ in my-app"). Every other command, and a safe-list one with anything the list
1772
+ cannot vouch for (a redirect, a chain, a substitution, a quote or backslash, a
1773
+ glob, braces, a tilde, a hidden character, a NAME=value prefix, `=rm`, a
1774
+ flag on a test command, git's `--output`, `git diff --no-index`, and for a read
1775
+ command a word that starts with `/`, has a `..` step or leads out of the folder through a link, or a Codex working folder outside the folder, #3737 #3759), offers "Always allow this command
1776
+ in <folder>" and saves exactly that command line, byte for byte (#3726).
1728
1777
  - The asker claims its question on the answer poll and reads the answer with
1729
1778
  `check_answer` itself: an answer resolves the pending request, it is never
1730
1779
  typed into the conversation.
1731
1780
  - No answer means keep waiting. Stop and the wall clock still end the run;
1732
1781
  the stall watchdog does not count time spent waiting for a person.
1733
1782
  - Always allow is remembered per folder in
1734
- `<glytch home>/permissions/<sha256 of the folder path>.json`: a shell
1735
- command by its first word (`Bash(pip:*)`), anything else by its tool name.
1736
- A remembered rule is answered without asking. A chained, piped or
1737
- redirected command is asked every time.
1783
+ `<glytch home>/permissions/<sha256 of the folder path>.json`: a safe-list
1784
+ command by its family (`Bash(git status:*)`), any other shell command by the
1785
+ sha256 of the whole line as typed (`Bash(exact:...)`), anything else by its
1786
+ tool name. A remembered rule is answered without asking; a pipe between
1787
+ safe-list commands is covered when every part's family is saved. Word rules
1788
+ saved before #3726 for `ls`, `cat`, `pwd`, `head`, `tail` and `wc` still match
1789
+ their family; any other (`Bash(npm:*)`) matches nothing any more.
1738
1790
  - A plan draft is read-only and is never given the asker.
1739
1791
 
1740
1792
  ## What a spawned session inherits
@@ -1848,7 +1900,8 @@ completes, both commits land in main).
1848
1900
  ## The ACP engine
1849
1901
 
1850
1902
  Added 2026-09-02 (brief 15 decision 8, on the amendment written by the spike
1851
- in `spikes/acp-2026-09-02/`). Checked against the code in this commit.
1903
+ in `spikes/acp-2026-09-02/`, removed 2026-11-02 and kept in Git history at
1904
+ `e39d057c5`). Checked against the code in this commit.
1852
1905
 
1853
1906
  `acp-claude` is a third engine in `bridge/lib/agents.mjs`, labelled "Claude
1854
1907
  Code via ACP". It runs `@agentclientprotocol/claude-agent-acp` 0.73.0 over
@@ -1950,14 +2003,15 @@ frame draws it.
1950
2003
  local id alone - `tools.mjs`'s `readBoardById` prefixes it with the
1951
2004
  token's own account before matching a row, falling back to the bare value
1952
2005
  when that prefixed id is not this account's.
1953
- - **Permissions.** `session/request_permission` is answered by the client from
1954
- `CLAUDE_TOOLS` - the same list `--allowedTools` gets, one list at a second
1955
- door. Matching is exact name, MCP namespace (`mcp__glytch` covers
1956
- `mcp__glytch__report`; renamed from `mcp__board` 2026-09-12, brief 31,
1957
- Move 3b), or command prefix (`Bash(git:*)` against
1958
- `rawInput.command`). Anything else, including a rule the matcher cannot
1959
- parse, is `reject_once`. **Never `allow_always`**: "always" outlives the
1960
- decision that justified it. Each decision is written into the log as a
2006
+ - **Permissions.** `CLAUDE_TOOLS` goes to the adapter's Claude Code as
2007
+ `allowedTools` (`_meta.claudeCode.options` at `session/new` and
2008
+ `session/load`), the same list `--allowedTools` gets, matched by Claude Code
2009
+ itself. A call off the list arrives as `session/request_permission` and goes
2010
+ to the runner's shared asker (`permissionAsk.mjs`), the one Claude and
2011
+ Codex use: it refuses a command that drives another app and otherwise asks
2012
+ the person in the idea (#4615). With no board to ask on the answer is
2013
+ `reject_once`. **Never `allow_always`**: "always" lives in the asker, per
2014
+ folder. Each decision is written into the log as a
1961
2015
  `{"type":"system","subtype":"permission"}` line.
1962
2016
  - **`CLAUDE_DISALLOWED_TOOLS` has no equivalent and needs none.** Plan mode is
1963
2017
  a session *mode* on this engine, and `acp.mjs` selects `acceptEdits` and
package/glytch.mjs CHANGED
@@ -49,7 +49,7 @@ import { watchRegistered } from "./lib/multiwatch.mjs";
49
49
  import { readRegistry, registryPath, removeFolder, touchRegistry } from "./lib/registry.mjs";
50
50
  import { settingsFromEnv, newRunnerId, registerAndFindProject } from "./lib/runner.mjs";
51
51
  import { syncFolder, syncRegistry } from "./lib/sync.mjs";
52
- import { waitForRunnerHealth, writeRunnerHealth } from "./lib/runner-health.mjs";
52
+ import { SETUP_HEALTH_SLOW_MS, SETUP_HEALTH_WAIT_MS, hasFreshBeat, waitForRunnerHealth, writeRunnerHealth } from "./lib/runner-health.mjs";
53
53
  import { initServiceScript, packageVersion, runUpdate } from "./lib/update.mjs";
54
54
  import { initOptions, chooseAgents, readAgentSelection, saveAgentSelection } from "./lib/agent-selection.mjs";
55
55
  import { projectMcpServerKey } from "./lib/project-mcp.mjs";
@@ -186,6 +186,8 @@ async function init() {
186
186
  const root = resolve(process.cwd());
187
187
  const checkStartedAt = Date.now();
188
188
  const disabled = noDaemonInstall(process.env);
189
+ // The copied prompt's attempt id. The app's card waits for it (#4206).
190
+ const setupId = process.env.VIEWABLE_SETUP_ID ?? process.env.GLYTCH_SETUP_ID ?? "manual";
189
191
  // The service runs the script verification proved, not this process's own
190
192
  // file, which may be a same-version copy about to be deleted (#600). No log:
191
193
  // the PATH diagnostic is noise as init's first line.
@@ -215,8 +217,8 @@ async function init() {
215
217
  say(`Board connections: ${selected.length ? selected.join(", ") : "none"}`);
216
218
  if (selected.includes("claude") && agents.claude?.found && agents.claude.loggedIn === false) {
217
219
  say("");
218
- say("Claude Code is installed but not logged in. Run `claude` once and log in,");
219
- say("or a session will fail the moment it spawns.");
220
+ say("Claude Code is installed but not signed in. Run `claude auth login` yourself,");
221
+ say("which opens a browser sign-in page, or a session will fail the moment it spawns.");
220
222
  }
221
223
 
222
224
  say("");
@@ -242,10 +244,17 @@ async function init() {
242
244
  const token = await personalBoardToken({ env: process.env });
243
245
  // Restore deliberately before publishing a new local registry entry. A
244
246
  // watcher must not see the folder while the server still wants it removed.
247
+ // The attempt id rides this register too, so the card knows this computer
248
+ // answered before the last check ends (#4206).
249
+ const registerSetup = (extra = {}) => registerAndFindProject(root, {
250
+ ...settingsFromEnv(), runnerId: newRunnerId(), markExtra: () => ({ version: packageVersion(), setupId, ...extra }),
251
+ }, { readd: true });
252
+ let setupRegistered = false;
253
+ let setupRunnerId = null;
245
254
  if (machine?.status === "ok" || token) {
246
- const registered = await registerAndFindProject(root, {
247
- ...settingsFromEnv(), runnerId: newRunnerId(), markExtra: () => ({ version: packageVersion() }),
248
- }, { readd: true });
255
+ const registered = await registerSetup();
256
+ setupRegistered = registered.ok;
257
+ setupRunnerId = registered.runnerId ?? null;
249
258
  if (!registered.ok) {
250
259
  say(registered.error);
251
260
  // Keep ordinary setup usable offline, as before. Only a known removal
@@ -315,16 +324,38 @@ async function init() {
315
324
  // a watching runner, and neither is a computer the board cannot reach.
316
325
  let healthy = false;
317
326
  if (allOk && signedIn && !disabled) {
327
+ // THE PROOF BEFORE THE BEAT (#4206). The service puts this file's attempt
328
+ // id on its heartbeat, and the card turns Online on that. Written after
329
+ // the wait, it missed the beat init asked for and waited for the next
330
+ // one, 5 minutes away while push is joined. Written first, the beat that
331
+ // ends this wait carries it, and a computer slower than this wait still
332
+ // turns Online on its own first beat.
333
+ await writeRunnerHealth({ version: packageVersion(), setupId }, process.env, "cli");
318
334
  // A daemon already watching this folder beats on a registry rewrite.
319
335
  await touchRegistry().catch(() => {});
320
336
  const result = await waitForRunnerHealth({
321
337
  version: packageVersion(), after: checkStartedAt, root, requireStartedAfter: false,
338
+ timeoutMs: SETUP_HEALTH_WAIT_MS, slowMs: SETUP_HEALTH_SLOW_MS,
339
+ onSlow: () => say("Your computer is still starting. Waiting a little longer…"),
322
340
  });
323
341
  healthy = result.ok;
324
- if (healthy) {
325
- await writeRunnerHealth({ version: packageVersion(), setupId: process.env.VIEWABLE_SETUP_ID ?? process.env.GLYTCH_SETUP_ID ?? "manual" }, process.env, "cli");
326
- say(RUNNER_WATCHING_LINE);
327
- } else say(result.error);
342
+ if (healthy) say(RUNNER_WATCHING_LINE);
343
+ else say(result.error);
344
+ }
345
+ // A SETUP THAT REALLY FAILED SAYS SO ON THE CARD (#4206). The card cannot
346
+ // see this terminal, so after sign-in a failed end registers once more with
347
+ // the failure on it; a later good beat from the service replaces it.
348
+ // A fresh beat can settle a health-wait timeout only after setup checks
349
+ // passed (#5047). A running daemon cannot prove invalid config was fixed.
350
+ // The failure goes out as a plain register for this folder only, never the
351
+ // re-add one, so a folder the person removed in the meantime stays removed
352
+ // and the other folders' rows keep their agents.
353
+ if (setupRegistered && signedIn && !disabled && !(allOk && healthy) &&
354
+ !(allOk && hasFreshBeat({ version: packageVersion(), root, after: checkStartedAt }))) {
355
+ await registerAndFindProject(root, {
356
+ ...settingsFromEnv(), runnerId: setupRunnerId ?? newRunnerId(),
357
+ markExtra: () => ({ version: packageVersion(), setupId, setupFailed: true }),
358
+ }, { onlyRoot: true }).catch(() => {});
328
359
  }
329
360
  // FIX 1B, THE FALLBACK SENTENCE: an agent step 4 could not connect over
330
361
  // the hosted endpoint (no terminal, and 1a either did not apply to it or