viewable-one 0.12.6 → 0.12.8

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.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,107 @@ package.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [0.12.8] - 2026-11-19
17
+
18
+ ### Fixed
19
+
20
+ - A run on the computer whose read or write is refused now stops and asks on
21
+ the board with the reason, and never gets round it with another login on the
22
+ computer: the Supabase CLI, a saved password or a git or GitHub token are
23
+ refused for every engine, whatever the person allowed for the run (#6995).
24
+ - A card automation or a process step set to run on your computer now starts
25
+ the program you chose for that folder in setup, not whichever installed
26
+ program was found first (#6704). The computer now tells the board which
27
+ programs each watched folder chose (`viewable init --agents`), and it reads
28
+ that choice again when a folder is set up or set up again while the
29
+ watcher runs. If none of the chosen programs is installed, the run starts
30
+ nothing and says which one is missing, naming it, with what to do next. A
31
+ choice the computer cannot read is refused in words and never taken for no
32
+ choice. A folder set up before the choice existed keeps the old pick:
33
+ Claude Code, else the first one found.
34
+
35
+ ### Changed
36
+
37
+ - An automation's reads of a connected app run on your computer without
38
+ asking (#6896, as on the board in #6628), when the engine reports the
39
+ tool's own read-only label: Codex. Setting the automation counts as the
40
+ yes; a write still asks. A run you start yourself keeps asking. The runner
41
+ marks a run that came from an automation, and the ask lets a Codex call
42
+ through when Codex labels the tool read-only and its words and arguments
43
+ name a read. A call Codex flags as sensitive, or a tool labelled as
44
+ changing things or not labelled at all, asks. Claude Code and ACP agents
45
+ send no tool labels, so the computer cannot tell a read from a write and
46
+ every app call from them asks, in an automation too (#6955). A read the
47
+ automation allowed leaves a line in the run's steps saying so, and Codex's
48
+ tool is read from the approval's own field, never its words (#6955).
49
+
50
+ ## [0.12.7] - 2026-11-15
51
+
52
+ ### Fixed
53
+
54
+ - The computer's list of tools now finds Claude Code (and the others) the way
55
+ a run does, not only on the watcher's own PATH. A watcher started by hand
56
+ reported Claude Code as missing, so a card automation on the computer went
57
+ to OpenCode, which was never chosen, and failed (#6646).
58
+ - A scheduled run that could not reach the person's apps (its closing asks
59
+ for Use my computer's apps) now says so on its row (`sidecar.unable`), so
60
+ its automation shows as failed with the reason and a Needs you notice,
61
+ instead of "Ran" (#6552).
62
+ - Merge, delete, clean and new-worktree changes no longer run without the repo
63
+ lock. The lock was a folder under `.git/`, which could not be made in a
64
+ linked worktree, and a failed or timed-out lock was logged and ignored. It
65
+ now lives in Git's shared folder, so a checkout and its linked worktrees take
66
+ the same lock, and a change that cannot get it stops with a message naming
67
+ who holds it, before any stash, merge or reset runs. A run whose repo lock
68
+ cannot be held now does not start at all: it ends with "Nothing was spawned
69
+ and nothing was billed" and asks to run again once the other change has
70
+ finished, instead of falling back to the shared checkout (#6558).
71
+ - Stop, the wall clock and the stall watchdog now end every ordinary
72
+ background command the agent started, not only the agent (#6557). A
73
+ `cmd > log 2>&1 &` used to outlive Stop. The runner ends the agent's private
74
+ group and waits until it is empty, spares the recorded preview server, and
75
+ keeps the run's recovery record when something survives so a later cleanup
76
+ can still find it. Windows is unchanged.
77
+ - A remembered file permission stays inside the project folder (#6556). Always
78
+ allow on a Read, Write, Edit or search used to cover that tool anywhere on
79
+ the computer. Now every file tool must stay inside the run's folder (links
80
+ followed); a path outside or a link pointing out asks again, and so does a
81
+ file tool with no path. Those asks show no Always allow button. Grep and
82
+ Glob with no path are judged against the run's own folder and stay covered.
83
+ The same holds for Claude Code, Codex and ACP agents.
84
+ - Windows uninstall keeps `Path` for both the Viewable and npm removal steps
85
+ (#5414), so a Volta or bundled npm is found and Remove finishes. The two
86
+ spellings of the name no longer both reach the child.
87
+ - The line under an approval question names what a connected app will make
88
+ ("Title" and "Adds"), not a raw argument such as `creation_mode` (#5401). It
89
+ also names the pages a delete acts on and hides the confirmation flags
90
+ `user_confirmed` and `user_confirmation` (#6453); a bare `confirm`, such as
91
+ Stripe's charge-now, still shows. It shows a title or name with a
92
+ number up to 6 digits, such as "Invoice 452199" (#5436). Text with a code or
93
+ credential word, or longer numbers, stays hidden.
94
+ - The reason line under a computer app's approval no longer depends on which
95
+ app it is (#5442). Per-app rules moved into the app catalog, which the
96
+ computer's ask does not have, so it reads each call from its own words:
97
+ money, sending, deleting, publishing, merging and deploying keep their
98
+ lines, but a Stripe tool whose words name no money act (`create_customer`,
99
+ `create_price`) no longer gets "Money moves", and a create or comment tool
100
+ that used to show no line (Linear `create_issue`, Notion `create_pages`,
101
+ GitHub `add_issue_comment`) now reads "Open-ended tools ask every time."
102
+ The ask itself is unchanged.
103
+ - `viewable doctor` says an installed version ahead of npm is "newer than the
104
+ published" one, instead of an update notice, and still passes (#5478).
105
+
106
+ ### Added
107
+
108
+ - A run's question carries the pictures the run saw, with a caption each, into
109
+ Needs you (#5534). The run rules tell the agent to attach what it saw.
110
+
111
+ ### Changed
112
+
113
+ - When `PM_SPAWN_MAX_CONCURRENT` is set, the runner sends it with each claim,
114
+ so the board holds it across every folder on this computer at once. Unset
115
+ is still any number at once (#5732).
116
+
16
117
  ## [0.12.6] - 2026-11-10
17
118
 
18
119
  ### Fixed
package/SPAWN.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # The spawn contract - running a Claude Code session from the board
2
2
 
3
+ Checked against `bridge/lib/runnerApi.mjs`, `supabase/functions/board-runner/` and `src/types.ts` on 2026-11-11.
4
+
3
5
  This is the runner's contract, written for whoever maintains it: every row it
4
6
  reads and writes, every bound it respects, and what happens at each edge. It
5
7
  is not a guide to using Viewable - [README.md](./README.md) is that.
@@ -366,45 +368,36 @@ already has, the one `bridge/lib/ops.mjs` already reads, and the one a session
366
368
  already knows how to look for. Inventing a second shape for the same job would
367
369
  be the drift the sidecar exists to avoid.
368
370
 
369
- ## Two states, and no progress protocol
370
-
371
- The ruling, 2026-08-26 (`q-mt9as5a0`): a run is **running**, then **done**.
372
- There is no third board state, no heartbeat, no liveness channel, and nothing
373
- anywhere infers a session's state from its silence. The record rides the
374
- idea, and its card draws these same two states.
375
-
376
- That ruling deletes a lot, and the deletions are the good part. There is no
377
- `.status.json`, no `STALE_MS`, no reaper, no "waiting on you" state, and no
378
- timeout that guesses whether a quiet session is thinking or dead. A session
379
- that dies without ending leaves its card reading `running`, and he sees that
380
- and presses Rerun or clears the idea. A wrong-looking card he can act on beats a
381
- right-looking state machine he has to trust.
382
-
383
- Since 2026-09-07 (the QA sweep of the runner) the end op says which of the two
384
- endings it was: `endSession` carries `stopped: true` when the run ended because
385
- a stop was asked for, and a `reason` line when it ended without ever starting.
386
- That is not a third state - the board still reads running, then done - it is
387
- the difference between "finished" and "you stopped it", which the card could
388
- not otherwise tell.
389
-
390
- What is NOT a progress protocol, and stays:
391
-
392
- - the **claim file**, which records who owns a request so two runners cannot
393
- both run it. It is written once and never updated, so it says nothing about
394
- liveness and cannot go stale in a way anyone reads.
395
- - the **wall clock**, which kills a child that has run past `maxMs`. That is a
396
- money bound on a process, not a state on the board. When it fires the runner
397
- still calls `endSession`, so the board says `done` like any other ending, and
398
- the reason lives in `inbox/spawn/<id>.result.txt` where a person reads it.
399
- Amended 2026-08-30: for a streaming child whose final result envelope stands,
400
- the firing is the reply window closing, not a timeout - see "A finished
401
- stream is finished" below. The bound itself is unchanged. Amended again
402
- 2026-09-06: there is no reply window any more, so an idle child does not
403
- reach the wall clock at all - the envelope closes its stdin and it exits.
404
- The bound is still unchanged, and it is what a child mid-turn meets.
405
-
406
- The board carries two states. The disk carries the detail. Neither pretends to
407
- carry the other.
371
+ ## Run states and leases
372
+
373
+ Historical reference: the 2026-08-26 ruling `q-mt9as5a0` described the
374
+ file-based runner as running then done, with no heartbeat or timer-based
375
+ reaper. Its local housekeeping constraint still describes
376
+ `bridge/lib/runnerMaintenance.mjs`: sweep orphan processes at lifecycle
377
+ boundaries, not on a timer.
378
+
379
+ The later hosted-row contract supersedes that two-state/no-heartbeat
380
+ description for hosted runs: `20260911170000_runs_as_rows.sql` defines the
381
+ row states, and `20260926093000_runner_leases.sql` adds expiring claims and
382
+ the server reaper. `bridge/lib/runnerLease.mjs` renews those leases. This
383
+ section records that implemented change; it does not change the local
384
+ housekeeping constraint or infer completion from a quiet model.
385
+
386
+ Hosted run rows move from `pending` to `running` when claimed, then to
387
+ `done`, `error` or `stopped`. The idea's `RunStatus` is `idle`, `running`,
388
+ `done` or `error`; stopped outcomes carry the stop detail on the run.
389
+ The row states and the card's display states are different contracts.
390
+
391
+ The runner registers and sends heartbeats. Claims have a five-minute lease,
392
+ renewed every 30 seconds; local execution stops before expiry when renewal
393
+ fails. The server reaps expired claims as errors, never as pending work to
394
+ restart automatically. Completion recovery can reconcile a late durable
395
+ result. See “Admission, leases and completion recovery” above.
396
+
397
+ The wall clock bounds the child process. It is not a progress estimate.
398
+ A quiet model is not assumed finished: completion comes from the child's
399
+ result and the runner's update. The old file-based claim and result receipts
400
+ below describe the earlier transport, not the current hosted lease protocol.
408
401
 
409
402
  ## A finished stream is finished
410
403
 
@@ -1002,7 +995,7 @@ each is enforced in code, not in a comment:
1002
995
  | runner off by default | `PM_SPAWN_RUNNER=on` AND an explicit `watch` command | a runner that starts itself because something imported it |
1003
996
  | per-request approval | `approved: true`, or the request is refused | a row nobody clicked "run" on ever running |
1004
997
  | `claim` is the start | `claim` moving a row to `status:'running'` IS the start - the row exists under RLS the moment `run_request` inserted it, so nothing waits for a receipt | a run that is on the board but not yet accounted for |
1005
- | concurrency | `PM_SPAWN_MAX_CONCURRENT`, **any number by default** since 2026-08-28, counted from `runs {status:'running'}` plus the runner's own in-flight set | ten requests becoming ten sessions |
998
+ | concurrency | `PM_SPAWN_MAX_CONCURRENT`, **any number by default** since 2026-08-28, counted from `runs {status:'running'}` plus the runner's own in-flight set. When set, `claim` also carries it and the database holds it per computer across folders (`guard_run_capacity`, #5732); unset sends nothing and the database counts nothing. Server runs have no cap unless the database setting `glytch.server_run_cap` is set. Two starts that overlap wait for each other; only a full count refuses. A process run's own row is not counted, its steps' runs are; a server process step that meets a full count (waking, moving to running, landing, or filing its run) waits and goes on at a later tick (#6336) | ten requests becoming ten sessions |
1006
999
  | no shared working tree | a session that wanted isolation, could not get a worktree, and finds another session running is refused before it spawns (2026-08-28) | two agents editing one checkout with no branch between them |
1007
1000
  | wall clock | `maxMs`, default 90min (`DEFAULT_WALL_MS`), at most 2h (`MAX_WALL_MS`), both in `spawn.mjs` | a session that hangs billing all night |
1008
1001
  | no retry, ever | a failed request is terminal | paying twice for the same failure |
@@ -1172,7 +1165,7 @@ Kept below: the SHAPE of each signal, named for the file it once travelled as
1172
1165
 
1173
1166
  | signal | shape | what the runner does |
1174
1167
  | --- | --- | --- |
1175
- | stop | `{ worktreePath }` | sends SIGTERM to the child, writes receipt |
1168
+ | stop | `{ worktreePath }` | SIGTERM to the child; a recovery-tracked agent leads its own process group, so everything in it is signalled (except the preview server the session recorded), SIGKILL after the grace, and the receipt waits until the group is empty. A run with no lease generation has no private group and only the child pid is signalled. On Windows `taskkill /t` ends the tree |
1176
1169
  | merge | `{ worktreePath }` | Keep changes: commits the copy's leftovers, merges into the default branch around the person's uncommitted changes, deletes the copy and its branch |
1177
1170
  | delete | `{ worktreePath }` | Throw away: removes the worktree and deletes the branch without merging |
1178
1171
  | relaunch | `{ worktreePath }` (optional, a hint) | re-runs the RECORDED dev server command, detached, in the recorded worktree, or in the linked folder once that worktree is gone |
@@ -1580,8 +1573,8 @@ sits. `bridge/test/runner.test.mjs` has the test.
1580
1573
  `[message from <name>] <text>`, so the session can tell the person from a
1581
1574
  teammate. The contract tells the session to answer through `propose` with an
1582
1575
  `addComment` op and no `id` (it lands as its reply on its own idea), to attach
1583
- pictures with `images` (up to 6, data URLs) and to choose between looks with
1584
- `ask_user` and `images`. It also tells the session not to file a closing reply
1576
+ pictures with `images` (up to 6, data URLs) and to ask about what it saw, or
1577
+ choose between looks, with `ask_user` and `images` as `{image, caption}` (#5534). It also tells the session not to file a closing reply
1585
1578
  of its own, because the runner files one.
1586
1579
 
1587
1580
  The hosted board enforces it (#4153): a run's second reply in its idea's
@@ -1729,6 +1722,7 @@ unscoped, so the session may write any path the process can reach.
1729
1722
  | tools | anything not on `CLAUDE_TOOLS` | everything on it |
1730
1723
  | interactive prompts | `EnterPlanMode`, `AskUserQuestion` | - |
1731
1724
  | 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 |
1725
+ | another login, token or saved key (#6995) | Claude Code (both paths and ACP): the Supabase CLI, also as `npx supabase` and `npm exec supabase`, `git credential` (also after git's own options), and reading `~/.supabase/`, also by a shell command that names its token file (`CLAUDE_OTHER_LOGIN_TOOLS`, otherLogins.mjs); on every Claude or ACP ask and Codex escalation, the Supabase CLI, the keychain, password managers, `gh auth token` and git's credential helpers at any command in the line, also inside `sh -c`, `eval`, `$( )` or a package runner, whatever "Allow for this run" or a saved rule says (`usesAnotherLogin`); opencode by its own `permission.bash` deny patterns; every engine is told in words to ask with the reason instead | the same program started from `node -e`, `npm run <script>` or a script, a token file read some other way, and a command that runs inside Codex's sandbox after the person granted it the network |
1732
1726
  | arbitrary code | - | `node -e`, `npx <anything>` |
1733
1727
  | writes | the checkout you are looking at (the **worktree** does this, not the list) | any other path the process can reach |
1734
1728
  | money | wall clock, no retry | - |
@@ -1783,7 +1777,9 @@ silently. `lib/permissionAsk.mjs` owns it; `child.mjs` answers Claude's
1783
1777
  `<glytch home>/permissions/<sha256 of the folder path>.json`: a safe-list
1784
1778
  command by its family (`Bash(git status:*)`), any other shell command by the
1785
1779
  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
1780
+ tool name. A file tool's rule (Read, Write, Edit, MultiEdit, NotebookEdit, and a Glob or Grep search) applies only when every path
1781
+ the call names lands inside the folder, links followed and relative paths judged from the run's folder; a path outside, through a link that
1782
+ leads out, or missing asks fresh and offers no Always button (#6556). A remembered rule is answered without asking; a pipe between
1787
1783
  safe-list commands is covered when every part's family is saved. Word rules
1788
1784
  saved before #3726 for `ls`, `cat`, `pwd`, `head`, `tail` and `wc` still match
1789
1785
  their family; any other (`Bash(npm:*)`) matches nothing any more.
@@ -1861,21 +1857,37 @@ while a watcher is running. Claim files keep two runners off the same REQUEST;
1861
1857
  they say nothing about two processes running `git checkout main` in the same
1862
1858
  second.
1863
1859
 
1864
- So `withRepoLock` also takes a **lockdir**, `mkdir` being the one atomic
1865
- exclusive create every filesystem agrees on - the same reasoning the claim file
1866
- uses `flag: "wx"`. It lives at `<root>/.git/pm-repo.lock`, and that location is
1867
- load-bearing rather than tidy: a lock `git status` can see would read as the
1868
- person's own change, and Keep sets those aside and puts them back.
1869
- `.git/` is the one directory git never reports, it is exactly per-repo, and it
1870
- is already where git keeps its own locks.
1871
-
1872
- An `owner.json` inside it records pid, host and time, which is how the lock
1873
- survives its holder being killed: a pid that is gone **on this host** frees it
1874
- at once, a lock from another host frees on age (`LOCK_STALE_MS`, 10 minutes).
1875
- Waiting is bounded (`LOCK_WAIT_MS`, 60s) and losing the wait is not fatal - it
1876
- logs loudly and goes ahead, because refusing to clean up a worktree is worse
1877
- than the race that was there all along. A `.git` that is a file (the root is
1878
- itself a linked worktree) or a read-only checkout takes the same path.
1860
+ So `withRepoLock` also takes a **cross-process lock**, the same exclusive
1861
+ hard-link protocol the runner's admission lock uses (`acquireAdmission`,
1862
+ `admission.mjs`). It lives at `<git common dir>/pm-repo-admission/.admission.lock`,
1863
+ where the common dir comes from `git rev-parse --git-common-dir` (#6558). That is
1864
+ the one folder every linked worktree of a repo shares, so a checkout and its
1865
+ linked worktrees contend for the same lock; the old `<root>/.git/pm-repo.lock`
1866
+ could not be made in a linked worktree, where `.git` is a file. The location is
1867
+ still inside `.git/` and that is load-bearing rather than tidy: a lock `git
1868
+ status` can see would read as the person's own change, and Keep sets those aside
1869
+ and puts them back.
1870
+
1871
+ A holder that is gone **on this host** frees the lock at once (the admission
1872
+ protocol checks the pid and its start time). A holder on another host, or one
1873
+ that is alive but wedged, is never stolen from: it needs manual recovery. Once
1874
+ you have confirmed that process is stopped, delete
1875
+ `<git common dir>/pm-repo-admission/.admission.lock` (the refusal prints the full
1876
+ path) and the next change takes the lock.
1877
+ Waiting is bounded (`LOCK_WAIT_MS`, 60s).
1878
+
1879
+ **No lock, no change (#6558).** This section used to say losing the wait was not
1880
+ fatal and the change went ahead. That is the race the lock exists to stop, so it
1881
+ is gone: a lock that cannot be made, or is still held after the wait, throws
1882
+ `RepoLockError` and the callback never runs. Each exported wrapper turns that
1883
+ into its own refusal (`mergeWorktree`/`deleteWorktree` `{ ok: false, detail }`,
1884
+ `cleanWorktree` `{ removed: false, detail }` and the tree is kept,
1885
+ `makeChatWorktree` `{ ok: false, reason }`, `makeWorktree` and `reuseWorktree` a
1886
+ result marked `lockRefused`). The runner turns `lockRefused` into an error that
1887
+ spawns nothing, whether or not another run is on the project: falling back to the
1888
+ linked folder would put the session in the checkout the holder is changing, and
1889
+ "the separate copy is gone" would be untrue of a tree still on disk. The one exception is a folder that is not a git
1890
+ repository: there is nothing to lock.
1879
1891
 
1880
1892
  **No `git pull`.** `mergeWorktreeImpl` used to run `git pull --ff-only` on the
1881
1893
  user's main before merging, best-effort and unexplained. Removed 2026-09-02: it
@@ -1895,7 +1907,9 @@ state and run without the lock.
1895
1907
 
1896
1908
  **Test:** `bridge/test/worktree.test.mjs` proves two concurrent `mergeWorktree`
1897
1909
  calls on the same root serialize (order preserved, second starts after first
1898
- completes, both commits land in main).
1910
+ completes, both commits land in main). `bridge/test/repolock.test.mjs` proves a
1911
+ linked worktree takes the common lock, a held lock blocks a second change, and a
1912
+ lock that cannot be held never runs the callback.
1899
1913
 
1900
1914
  ## The ACP engine
1901
1915
 
package/glytch.mjs CHANGED
@@ -247,8 +247,12 @@ async function init() {
247
247
  // watcher must not see the folder while the server still wants it removed.
248
248
  // The attempt id rides this register too, so the card knows this computer
249
249
  // answered before the last check ends (#4206).
250
+ // The programs chosen in step 1 ride the setup's own register: it replaces
251
+ // the folder's mark, so without them a run filed before the daemon's next
252
+ // beat would take a program the person did not choose (#6704).
253
+ const chosenMark = selected.length ? { chosenAgents: { [root]: selected } } : {};
250
254
  const registerSetup = (extra = {}) => registerAndFindProject(root, {
251
- ...settingsFromEnv(), runnerId: newRunnerId(), markExtra: () => ({ version: packageVersion(), setupId, ...extra }),
255
+ ...settingsFromEnv(), runnerId: newRunnerId(), markExtra: () => ({ version: packageVersion(), setupId, ...chosenMark, ...extra }),
252
256
  }, { readd: true });
253
257
  let setupRegistered = false;
254
258
  let setupRunnerId = null;
@@ -355,7 +359,7 @@ async function init() {
355
359
  !(allOk && hasFreshBeat({ version: packageVersion(), root, after: checkStartedAt }))) {
356
360
  await registerAndFindProject(root, {
357
361
  ...settingsFromEnv(), runnerId: setupRunnerId ?? newRunnerId(),
358
- markExtra: () => ({ version: packageVersion(), setupId, setupFailed: true }),
362
+ markExtra: () => ({ version: packageVersion(), setupId, ...chosenMark, setupFailed: true }),
359
363
  }, { onlyRoot: true }).catch(() => {});
360
364
  }
361
365
  // FIX 1B, THE FALLBACK SENTENCE: an agent step 4 could not connect over
package/lib/acp.mjs CHANGED
@@ -510,6 +510,10 @@ export function runAcpChild(opts) {
510
510
  killGraceMs,
511
511
  onChunk,
512
512
  stopPollMs,
513
+ // The adapter leads its own group when it is recovery-tracked: Stop and
514
+ // the wall clock end the whole group, not just the adapter (#6557).
515
+ keepPids: opts.keepPids,
516
+ killProcessGroup: opts.recoveryGroup === true && (opts.platform ?? process.platform) !== "win32",
513
517
  // THE STOP PATH, and the one place this engine has something better
514
518
  // than SIGTERM. `session/cancel` lets the adapter stop its model
515
519
  // request and flush its pending updates; the kill that attachChild does
@@ -853,10 +857,17 @@ export function runAcpChild(opts) {
853
857
  // The allowlist rides to the adapter's Claude Code as `allowedTools`
854
858
  // (the permission door above); without one nothing is auto-allowed.
855
859
  const allowedTools = Array.isArray(acp.allowTools) ? acp.allowTools : [];
860
+ // Another login, token or saved key is barred (#6995, otherLogins.mjs);
861
+ // the adapter merges its own AskUserQuestion rule into this list.
862
+ const disallowedTools = Array.isArray(acp.disallowTools) ? acp.disallowTools : [];
863
+ const options = {
864
+ ...(allowedTools.length > 0 ? { allowedTools } : {}),
865
+ ...(disallowedTools.length > 0 ? { disallowedTools } : {}),
866
+ };
856
867
  const params = {
857
868
  cwd,
858
869
  mcpServers: Array.isArray(acp.mcpServers) ? acp.mcpServers : [],
859
- ...(allowedTools.length > 0 ? { _meta: { claudeCode: { options: { allowedTools } } } } : {}),
870
+ ...(Object.keys(options).length > 0 ? { _meta: { claudeCode: { options } } } : {}),
860
871
  };
861
872
  let created;
862
873
  // Explicit crash recovery requires the saved conversation. Ordinary
@@ -36,6 +36,90 @@ export async function readAgentSelection(root) {
36
36
  }
37
37
  }
38
38
 
39
+ /** How often the mark re-reads the folders' saved choices on its own. */
40
+ const CHOICE_REFRESH_MS = 30_000;
41
+
42
+ /**
43
+ * WHICH PROGRAMS THE PERSON CHOSE, in the mark the computer sends (#6704).
44
+ *
45
+ * A run the board files for this computer with no coding agent of its own (a
46
+ * card's automation, a process step) must start the program chosen for its
47
+ * folder at setup, never another one that happens to be installed. One mark
48
+ * goes out for every folder on the computer, and each folder keeps its own
49
+ * choice, so the mark carries `chosenAgents: {<folder path>: [names]}`;
50
+ * supabase/functions/_shared/habitRuns.mjs `runnerAgentOnComputer` reads it.
51
+ *
52
+ * `mark()` is SYNCHRONOUS, like the probe's (detect.mjs): it answers from
53
+ * memory and starts a re-read in the background when one is due. `refresh()`
54
+ * is how a caller waits for a fresh answer: the daemon awaits it before the
55
+ * first beat, before a folder that joins is watched, and when the folder list
56
+ * is written again (setup choosing a program rewrites it), so a new choice
57
+ * reaches the next beat. A folder with no saved choice is left out: no choice
58
+ * is recorded for it, and the board keeps its old pick.
59
+ *
60
+ * A CHOICE THAT CANNOT BE READ IS NEVER "NO CHOICE" (#6704 review). A file
61
+ * caught mid-edit or briefly unreadable keeps the last choice read from it;
62
+ * one never read well is named in `chosenUnreadable`, and the board refuses
63
+ * the run in words rather than picking a program the person may not have
64
+ * chosen, the way init and doctor refuse an invalid file.
65
+ */
66
+ export function makeChoiceMark({
67
+ folders,
68
+ read = readAgentSelection,
69
+ intervalMs = CHOICE_REFRESH_MS,
70
+ now = () => Date.now(),
71
+ log = () => {},
72
+ } = {}) {
73
+ let known = {};
74
+ let unreadable = [];
75
+ let checkedAt = null;
76
+ let pending = 0;
77
+ let chain = Promise.resolve();
78
+ const complained = new Set();
79
+ const run = async () => {
80
+ checkedAt = now();
81
+ const next = {};
82
+ const broken = [];
83
+ let paths = [];
84
+ try { paths = [...new Set(folders())]; }
85
+ catch (error) { log(`could not list the folders for the chosen programs: ${error instanceof Error ? error.message : String(error)}`); return; }
86
+ for (const path of paths) {
87
+ try {
88
+ const chosen = await read(path);
89
+ if (Array.isArray(chosen) && chosen.length > 0) next[path] = chosen;
90
+ complained.delete(path);
91
+ } catch (error) {
92
+ if (known[path]) next[path] = known[path];
93
+ else broken.push(path);
94
+ if (!complained.has(path)) {
95
+ complained.add(path);
96
+ log(`[${path}] could not read the chosen programs: ${error instanceof Error ? error.message : String(error)}`);
97
+ }
98
+ }
99
+ }
100
+ known = next;
101
+ unreadable = broken;
102
+ };
103
+ // A refresh asked while one runs reads again after it, so a choice saved
104
+ // mid-read is never answered with the read that started before it.
105
+ const refresh = () => {
106
+ pending += 1;
107
+ const done = chain.then(run).finally(() => { pending -= 1; });
108
+ chain = done.catch(() => {});
109
+ return done;
110
+ };
111
+ return {
112
+ mark() {
113
+ if (pending === 0 && (checkedAt === null || now() - checkedAt >= intervalMs)) void refresh();
114
+ return {
115
+ ...(Object.keys(known).length > 0 ? { chosenAgents: { ...known } } : {}),
116
+ ...(unreadable.length > 0 ? { chosenUnreadable: [...unreadable] } : {}),
117
+ };
118
+ },
119
+ refresh,
120
+ };
121
+ }
122
+
39
123
  export async function saveAgentSelection(root, agents) {
40
124
  const selected = parseAgentSelection(agents);
41
125
  await mkdir(join(root, ".viewable"), { recursive: true });
package/lib/agents.mjs CHANGED
@@ -78,7 +78,8 @@
78
78
  // `acpServersFor` below is where the server is described.
79
79
 
80
80
  import { adapterEntry } from "./acp.mjs";
81
- import { computerAppsOffRule, conversationRules } from "./conversationRules.mjs";
81
+ import { computerAppsOffRule, conversationRules, otherAppsRule, refusalRule } from "./conversationRules.mjs";
82
+ import { CLAUDE_OTHER_LOGIN_TOOLS, OPENCODE_OTHER_LOGIN_RULES } from "./otherLogins.mjs";
82
83
  import { runEngineFor } from "./run-engine.mjs";
83
84
  // ONE LIST, not two: spawn.mjs's checkRequest is the validator a request
84
85
  // meets first, and this file's draft branch is what actually builds the
@@ -197,6 +198,9 @@ export const CLAUDE_CLICK_AND_SCREEN_TOOLS = [
197
198
  export const CLAUDE_DISALLOWED_TOOLS = [
198
199
  "EnterPlanMode", "AskUserQuestion",
199
200
  ...CLAUDE_CLICK_AND_SCREEN_TOOLS,
201
+ // Another login, token or saved key (#6995): `Bash(npx:*)` would run
202
+ // `npx supabase` without a question, and a deny rule is checked first.
203
+ ...CLAUDE_OTHER_LOGIN_TOOLS,
200
204
  ];
201
205
 
202
206
  /** The two tools that reach the web. Allowed up front only when the person
@@ -779,6 +783,9 @@ export function commandFor(agent, env = process.env, wants = {}) {
779
783
  label: spec.label,
780
784
  adapter: spec.adapter,
781
785
  allowTools: CLAUDE_TOOLS,
786
+ // The same Claude Code, so the same bar on other logins (#6995);
787
+ // the adapter adds its own AskUserQuestion rule beside it.
788
+ disallowTools: CLAUDE_OTHER_LOGIN_TOOLS,
782
789
  mode: "acceptEdits",
783
790
  model: typeof wants.model === "string" ? wants.model.trim() : "",
784
791
  mcpServers: acpServersFor(agent, {
@@ -847,6 +854,9 @@ export async function prepareWorkspace(agent, { mcpUrl, token, sessionKey, board
847
854
 
848
855
  const config = {
849
856
  $schema: "https://opencode.ai/config.json",
857
+ // --auto approves every command it does not deny, so another login is
858
+ // denied here by pattern (#6995, otherLogins.mjs).
859
+ permission: { bash: OPENCODE_OTHER_LOGIN_RULES },
850
860
  mcp: {
851
861
  [SERVER_KEY]: {
852
862
  type: "remote",
@@ -896,6 +906,8 @@ export function preambleFor(agent, { workplace, computerApps } = {}) {
896
906
  `call ${report} before you finish, including when you did nothing: the ` +
897
907
  "card on the person's idea just reads finished, and they cannot " +
898
908
  "tell that apart from success.\n\n" +
909
+ // A refusal stops the run and asks; it never sends it to another login (#6995).
910
+ refusalRule(ask) +
899
911
  `Your board tools are named ${spec.boardTool("get_board")}, ` +
900
912
  `${spec.boardTool("get_node")}, ${spec.boardTool("propose")}, ${ask} and ${report}.\n\n` +
901
913
  // brief 23 ruling 4a (2026-09-07): the app derives the run's structure
@@ -928,6 +940,19 @@ export function preambleFor(agent, { workplace, computerApps } = {}) {
928
940
  );
929
941
  }
930
942
 
943
+ /** What a chat turn is told ahead of the app's own words (runnerExecute.mjs).
944
+ * A chat turn gets no idea preamble, so the rules that hold for every run
945
+ * travel here: a refusal stops and asks, for every engine (#6995), and, for
946
+ * Claude Code and Codex, the other-apps rule and the apps-off rule that the
947
+ * reply's Manage agent offer reads (#4204, #481). */
948
+ export function chatRulesFor(agent, { computerApps } = {}) {
949
+ const engine = agentFor(agent);
950
+ const local = ["claude", "codex"].includes(engine)
951
+ ? `${otherAppsRule()}${computerApps === true ? "" : computerAppsOffRule()}`
952
+ : "";
953
+ return `${local}${refusalRule(AGENTS[engine].boardTool("ask_user"))}`;
954
+ }
955
+
931
956
  /** The plan-tool sentence of preambleFor, split out because `todoTool` now
932
957
  * comes in two shapes: a plain tool name (codex's `update_plan`, opencode's
933
958
  * `todowrite`) or, since 2026-09-21, `{write, update, fallback}` for the