viewable-one 0.12.7 → 0.12.9
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 +119 -0
- package/README.md +8 -3
- package/SPAWN.md +24 -3
- package/glytch.mjs +11 -6
- package/lib/acp.mjs +8 -1
- package/lib/agent-selection.mjs +84 -0
- package/lib/agents.mjs +218 -31
- package/lib/auth.mjs +245 -276
- package/lib/authenticatedHttp.mjs +2 -2
- package/lib/boardside.mjs +3 -1
- package/lib/child.mjs +33 -2
- package/lib/codex.mjs +123 -11
- package/lib/codexApps.mjs +100 -25
- package/lib/computerApps.mjs +85 -10
- package/lib/conversationRules.mjs +37 -3
- package/lib/detect.mjs +20 -5
- package/lib/doctor.mjs +18 -2
- package/lib/folderReads.mjs +15 -4
- package/lib/init-connect.mjs +11 -3
- package/lib/lateResume.mjs +4 -1
- package/lib/mcpjson.mjs +99 -1
- package/lib/multiwatch.mjs +37 -6
- package/lib/otherLoginHook.mjs +31 -0
- package/lib/otherLogins.mjs +386 -0
- package/lib/permissionAsk.mjs +69 -7
- package/lib/project-mcp.mjs +7 -27
- package/lib/registry.mjs +46 -2
- package/lib/runnerBeat.mjs +15 -0
- package/lib/runnerCompletion.mjs +28 -22
- package/lib/runnerExecute.mjs +78 -16
- package/lib/runnerGates.mjs +30 -5
- package/lib/runnerLaunch.mjs +33 -6
- package/lib/runnerOps.mjs +2 -2
- package/lib/runnerRegister.mjs +5 -4
- package/lib/runnerWorkspace.mjs +39 -12
- package/lib/selfUninstall.mjs +6 -8
- package/lib/spawn.mjs +9 -0
- package/lib/sync.mjs +10 -4
- package/lib/update.mjs +12 -6
- package/lib/worktree.mjs +75 -31
- package/lib/worktreeSweep.mjs +122 -0
- package/lib/writePolicy.mjs +434 -0
- package/package.json +1 -1
- package/spawn-runner.mjs +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,125 @@ package.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.12.9] - 2026-11-25
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- An ask on Your computer reads the apps you connected in Viewable through
|
|
21
|
+
Viewable (#8261). When its plan reads apps, Claude Code and Codex are told
|
|
22
|
+
to read them with the board's `app_read` instead of a command line such as
|
|
23
|
+
`gh`, to land a table or chart from that read, and to stop and say so when
|
|
24
|
+
a read is refused. An ask that only reads runs in the folder with no copy
|
|
25
|
+
and with tools that only read: no `Write`, `Edit` or commands on Claude
|
|
26
|
+
Code, the read-only sandbox on Codex, and none of the computer's own apps.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- An ask on Your computer that changed no file no longer leaves its own copy
|
|
31
|
+
of the folder (a `.claude/worktrees/glytch-*` folder and its branch) behind.
|
|
32
|
+
Every ended ask removes its copy when nothing in it changed, whether it was
|
|
33
|
+
a one-off or a session; a copy with changes stays until Keep or Throw away,
|
|
34
|
+
as before. A reply to an ask whose empty copy was removed gets the copy back at the
|
|
35
|
+
same place, so the conversation carries on instead of stopping at "its
|
|
36
|
+
separate copy is gone"; an ask you stopped keeps its conversation the same
|
|
37
|
+
way. A copy a preview is running from is kept. When the runner starts
|
|
38
|
+
it also clears the empty copies earlier asks left behind, and finishes
|
|
39
|
+
marking any it removed but could not yet tell the board about (#8266).
|
|
40
|
+
- Signing the computer in again as another account now replaces the old
|
|
41
|
+
sign-in instead of keeping it beside the new one. Before, a browser sign-in
|
|
42
|
+
over a saved personal token kept sending the old token, and a personal token
|
|
43
|
+
over a browser sign-in fell back to the old account once the token was
|
|
44
|
+
refused, so requests could run as the other account. A computer still
|
|
45
|
+
holding both kinds of sign-in asks for `viewable login` once (#8324).
|
|
46
|
+
- Words typed on a permission or an app's approval are always a no plus the
|
|
47
|
+
words, never a grant, even when they spell a button's label ("Allow",
|
|
48
|
+
"Allow for this run" or an Always label). Before, typing exactly "Allow"
|
|
49
|
+
allowed it. The runner reads whether the answer was typed, and also refuses
|
|
50
|
+
the app's "Not this: <words>" answer from a board that does not say so yet.
|
|
51
|
+
Claude and Codex alike (#8224).
|
|
52
|
+
- A computer whose sign-in renewal got no answer (the network dropped while it
|
|
53
|
+
renewed) no longer stays offline for ever without a word. The runner tries
|
|
54
|
+
the renewal again after a short wait (2 minutes, then 4, up to 30), never
|
|
55
|
+
twice inside the window where the board would read it as the same request,
|
|
56
|
+
and stops at the first real refusal. If the board did get the first one, the
|
|
57
|
+
second cancels that sign-in and the app shows "Not connected" with "Connect
|
|
58
|
+
again", not "Offline". The log and `viewable doctor` say "The last renewal
|
|
59
|
+
got no answer. Trying again." instead of "expired and cannot be renewed"
|
|
60
|
+
(#8221).
|
|
61
|
+
- An ask in a folder that is a git repo with no commit yet (a fresh `git init`)
|
|
62
|
+
no longer fails with "chat worktree could not be created". The chat runs in
|
|
63
|
+
the folder itself, as a coding session already did, and nothing is written to
|
|
64
|
+
the repo. The two refusal lines no longer say "worktree".
|
|
65
|
+
- A person's app that is left out of a Claude Code run because it is a Viewable
|
|
66
|
+
board server (one named `board` or `viewable`, say) now shows a line on the
|
|
67
|
+
run's card, as it does for Codex. Codex checks the board address from the
|
|
68
|
+
run's own environment, and refuses a question for another board server's
|
|
69
|
+
tools, as Claude Code does, instead of asking. A launch that fails early no
|
|
70
|
+
longer leaves its `viewable-mcp-*` folder in the temp directory.
|
|
71
|
+
- With "Use my computer's apps" on, a run no longer loads another Viewable
|
|
72
|
+
board server beside its own: the person's own board server, maybe signed in
|
|
73
|
+
to another account, is left out for Claude Code, Codex and opencode,
|
|
74
|
+
whatever its name or where it came from. Before, the agent could pick its
|
|
75
|
+
tools, so a question never reached the run's board, and one Allow on "Use
|
|
76
|
+
report in glytch?" wrote to the other account's boards. Claude Code keeps
|
|
77
|
+
its strict server list with the apps on and gets the person's own servers
|
|
78
|
+
in a private file; its plugins and claude.ai connectors stay off for now. A
|
|
79
|
+
call to another board server's tools is refused without a question (#7550).
|
|
80
|
+
|
|
81
|
+
- On Codex, the first run in a newly set up folder no longer stops with
|
|
82
|
+
"failed to load workspace requirements: invalid data" (apps on) or "Couldn't
|
|
83
|
+
read the apps" (apps off), so there is no need to press Try again. Codex
|
|
84
|
+
trusts a new folder only when the run starts and then loads the folder's own
|
|
85
|
+
apps; the runner now reads the apps again once and starts Codex again with
|
|
86
|
+
them. An app the check turns off keeps its address, which Codex needs to
|
|
87
|
+
accept the change (#7529).
|
|
88
|
+
|
|
89
|
+
- On Codex, a command that uses another login, a token or a saved key (for
|
|
90
|
+
example listing or reading the Supabase CLI's token file, reading the GitHub
|
|
91
|
+
CLI's token file, `gh auth token` or the Supabase CLI) is now refused before
|
|
92
|
+
it runs, and the agent is told to ask on the board. Before, a plain command
|
|
93
|
+
inside Codex's sandbox never reached the computer's check (#7466). If the
|
|
94
|
+
installed Codex cannot take this block, the Codex run does not start and
|
|
95
|
+
says to update Codex. Reading the GitHub CLI's token file is now refused for
|
|
96
|
+
every engine.
|
|
97
|
+
- With Claude Code's config folder moved (`CLAUDE_CONFIG_DIR`), the apps list
|
|
98
|
+
for "Use my computer's apps" now shows that folder's apps, not the ones in
|
|
99
|
+
your real home folder (#7516).
|
|
100
|
+
|
|
101
|
+
## [0.12.8] - 2026-11-19
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
|
|
105
|
+
- A run on the computer whose read or write is refused now stops and asks on
|
|
106
|
+
the board with the reason, and never gets round it with another login on the
|
|
107
|
+
computer: the Supabase CLI, a saved password or a git or GitHub token are
|
|
108
|
+
refused for every engine, whatever the person allowed for the run (#6995).
|
|
109
|
+
- A card automation or a process step set to run on your computer now starts
|
|
110
|
+
the program you chose for that folder in setup, not whichever installed
|
|
111
|
+
program was found first (#6704). The computer now tells the board which
|
|
112
|
+
programs each watched folder chose (`viewable init --agents`), and it reads
|
|
113
|
+
that choice again when a folder is set up or set up again while the
|
|
114
|
+
watcher runs. If none of the chosen programs is installed, the run starts
|
|
115
|
+
nothing and says which one is missing, naming it, with what to do next. A
|
|
116
|
+
choice the computer cannot read is refused in words and never taken for no
|
|
117
|
+
choice. A folder set up before the choice existed keeps the old pick:
|
|
118
|
+
Claude Code, else the first one found.
|
|
119
|
+
|
|
120
|
+
### Changed
|
|
121
|
+
|
|
122
|
+
- An automation's reads of a connected app run on your computer without
|
|
123
|
+
asking (#6896, as on the board in #6628), when the engine reports the
|
|
124
|
+
tool's own read-only label: Codex. Setting the automation counts as the
|
|
125
|
+
yes; a write still asks. A run you start yourself keeps asking. The runner
|
|
126
|
+
marks a run that came from an automation, and the ask lets a Codex call
|
|
127
|
+
through when Codex labels the tool read-only and its words and arguments
|
|
128
|
+
name a read. A call Codex flags as sensitive, or a tool labelled as
|
|
129
|
+
changing things or not labelled at all, asks. Claude Code and ACP agents
|
|
130
|
+
send no tool labels, so the computer cannot tell a read from a write and
|
|
131
|
+
every app call from them asks, in an automation too (#6955). A read the
|
|
132
|
+
automation allowed leaves a line in the run's steps saying so, and Codex's
|
|
133
|
+
tool is read from the approval's own field, never its words (#6955).
|
|
134
|
+
|
|
16
135
|
## [0.12.7] - 2026-11-15
|
|
17
136
|
|
|
18
137
|
### Fixed
|
package/README.md
CHANGED
|
@@ -276,9 +276,14 @@ open](#reading-the-board-with-no-app-open).
|
|
|
276
276
|
`list_sessions` and `send_message` are a PULL, not a push. Nothing holds a
|
|
277
277
|
session's stdin open over the network, so a session is OPEN TO MESSAGES only
|
|
278
278
|
while it keeps calling tools, STALE once it has gone quiet without closing,
|
|
279
|
-
and FINISHED once it has.
|
|
280
|
-
and
|
|
281
|
-
`
|
|
279
|
+
and FINISHED once it has. A message to an OPEN or STALE session waits for it
|
|
280
|
+
and is delivered the next time that session calls `collect_session`; the
|
|
281
|
+
answer says when it was last heard. `list_sessions` shows how many messages
|
|
282
|
+
wait for each session, so a script on your side can tell an idle agent to
|
|
283
|
+
collect them. `send_message` refuses a FINISHED target unless that session
|
|
284
|
+
said something on its side wakes it (`introduce` with `door`). The receiver
|
|
285
|
+
sees the message as from your session's own name; the `from` you pass is not
|
|
286
|
+
used.
|
|
282
287
|
|
|
283
288
|
There is deliberately no way to answer a question or run an idea from these
|
|
284
289
|
tools. Questions are yours to answer. A run uses your own Claude Code or Codex plan.
|
package/SPAWN.md
CHANGED
|
@@ -606,6 +606,19 @@ the same `newOpId` shape the ops channel uses).
|
|
|
606
606
|
Codex thread is started with web search disabled, whatever the computer's
|
|
607
607
|
own Codex config says. It is the agent's Web search setting in Manage
|
|
608
608
|
agent. A value that is not a boolean is refused.
|
|
609
|
+
- `readApps` (optional list of app ids, #8261) names the apps connected in
|
|
610
|
+
Viewable that this ask's plan reads. The session is told to read them with
|
|
611
|
+
the board's `app_read` and nothing else, and to land a table or chart from
|
|
612
|
+
the read it holds with `set_live_card` `{ shape, read_ref, columns }`
|
|
613
|
+
(Claude Code and Codex, the same words, #7581); board-mcp reads only these
|
|
614
|
+
apps for the running ask (#8254). Absent, the run is not told `app_read`
|
|
615
|
+
exists. A value that is not a list of non-empty ids is refused.
|
|
616
|
+
- `readOnly` (optional boolean, #8261) is an ask that only reads: it runs in
|
|
617
|
+
the linked folder with no worktree, Claude Code with only `Read`, `Glob`,
|
|
618
|
+
`Grep`, the Task tools and the board (`--tools` takes the rest away, so no
|
|
619
|
+
`Write`, `Edit`, `Bash` or web tools), Codex in its read-only sandbox with
|
|
620
|
+
its board server kept and no web search. Neither loads the computer's own
|
|
621
|
+
apps (`computerApps` is ignored). A value that is not a boolean is refused.
|
|
609
622
|
|
|
610
623
|
### `<id>.claim` - who owns it
|
|
611
624
|
|
|
@@ -1299,7 +1312,7 @@ new field.**
|
|
|
1299
1312
|
to do on the path a person waits on for every message they type.
|
|
1300
1313
|
3. **No repo primer and no attempts log**, and no runner preamble. All three
|
|
1301
1314
|
exist to save a FRESH session from rediscovery, and every sentence of the
|
|
1302
|
-
preamble is about a
|
|
1315
|
+
preamble is about a card ("end with your closing message...") that a
|
|
1303
1316
|
chat turn does not have. What a chat turn is told is the app's to compose:
|
|
1304
1317
|
persona, the room's context blocks, his message.
|
|
1305
1318
|
4. **A per-ROOM lock instead of the per-prompt one.** OVER ROWS (brief 30
|
|
@@ -1575,7 +1588,11 @@ teammate. The contract tells the session to answer through `propose` with an
|
|
|
1575
1588
|
`addComment` op and no `id` (it lands as its reply on its own idea), to attach
|
|
1576
1589
|
pictures with `images` (up to 6, data URLs) and to ask about what it saw, or
|
|
1577
1590
|
choose between looks, with `ask_user` and `images` as `{image, caption}` (#5534). It also tells the session not to file a closing reply
|
|
1578
|
-
of its own, because the runner files one.
|
|
1591
|
+
of its own, because the runner files one. An ask for a table, chart, list,
|
|
1592
|
+
timeline or kanban goes on the board as a drawn card (`drawnCardRule`,
|
|
1593
|
+
#8102); the hosted board refuses a report line or reply that says one was
|
|
1594
|
+
made when the session made none, and takes the sentence out of the runner's
|
|
1595
|
+
closing reply instead.
|
|
1579
1596
|
|
|
1580
1597
|
The hosted board enforces it (#4153): a run's second reply in its idea's
|
|
1581
1598
|
conversation, with no person's note after its first, is refused and names
|
|
@@ -1653,7 +1670,9 @@ present: `41 turns, 38m, context 212k`.
|
|
|
1653
1670
|
**Where it lands:**
|
|
1654
1671
|
|
|
1655
1672
|
- `reportOutcomeOnBoard` writes the one closing reply on the run's idea, and
|
|
1656
|
-
only for a session that finished (see "The conversation on an idea").
|
|
1673
|
+
only for a session that finished (see "The conversation on an idea"). It
|
|
1674
|
+
goes through the run's hosted transport (`runnerExecute.mjs`), which names
|
|
1675
|
+
the run's board as `X-Glytch-Board` (#7489); a refusal is logged. Its
|
|
1657
1676
|
figures line reads "Finished;" then turns and time, without context or
|
|
1658
1677
|
cost. The words above stay exactly as they are in the row's
|
|
1659
1678
|
`result`: the app parses them (`verdictOf`, `resultTail`).
|
|
@@ -1722,9 +1741,11 @@ unscoped, so the session may write any path the process can reach.
|
|
|
1722
1741
|
| tools | anything not on `CLAUDE_TOOLS` | everything on it |
|
|
1723
1742
|
| interactive prompts | `EnterPlanMode`, `AskUserQuestion` | - |
|
|
1724
1743
|
| 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 |
|
|
1744
|
+
| 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; Codex by its PreToolUse hook (`codexOtherLoginArgs`, otherLoginHook.mjs), which runs `usesAnotherLogin` on every command before it runs, also inside its sandbox, trusted by its hash on the command line; a Codex whose `hooks/list` does not show that hook trusted is not given the run (#7466); every engine is told in words to ask with the reason instead. The token files are `~/.supabase/access-token` and `~/.config/gh/hosts.yml` | the same program started from `node -e`, `npm run <script>` or a script, a token file read some other way, and on Codex text typed into a shell the run already opened (`write_stdin` runs no hook) |
|
|
1725
1745
|
| arbitrary code | - | `node -e`, `npx <anything>` |
|
|
1726
1746
|
| writes | the checkout you are looking at (the **worktree** does this, not the list) | any other path the process can reach |
|
|
1727
1747
|
| money | wall clock, no retry | - |
|
|
1748
|
+
| a run that only reads (`readOnly`, #8261) | Claude Code: every built-in tool but `Read`, `Glob`, `Grep` and the Task tools (`--tools`), so no `Write`, `Edit` or `Bash`; Codex: writes and network, by its read-only sandbox | Codex commands that only read, and what its board tools write on the board |
|
|
1728
1749
|
|
|
1729
1750
|
**The specific hole this opens.** A child gets `PM_BOARD_ROOT` (`childEnv`)
|
|
1730
1751
|
and has `Write`, so it can file its own `.glytch/inbox/spawn/<id>.json`
|
package/glytch.mjs
CHANGED
|
@@ -46,7 +46,7 @@ import { allGreen, doctorRows } from "./lib/doctor.mjs";
|
|
|
46
46
|
import { loginDaemon, noDaemonInstall } from "./lib/logindaemon.mjs";
|
|
47
47
|
import { makeFileLogger } from "./lib/logs.mjs";
|
|
48
48
|
import { watchRegistered } from "./lib/multiwatch.mjs";
|
|
49
|
-
import { readRegistry, registryPath, removeFolder, touchRegistry
|
|
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
52
|
import { SETUP_HEALTH_SLOW_MS, SETUP_HEALTH_WAIT_MS, hasFreshBeat, waitForRunnerHealth, writeRunnerHealth } from "./lib/runner-health.mjs";
|
|
@@ -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
|
|
@@ -400,9 +404,10 @@ async function forget() {
|
|
|
400
404
|
const color = colorEnabled();
|
|
401
405
|
const root = resolve(process.cwd());
|
|
402
406
|
say(heading("Viewable · Forget project", { color }));
|
|
403
|
-
//
|
|
404
|
-
// default folder, so a forget cannot land in the middle of
|
|
405
|
-
|
|
407
|
+
// removeFolder takes the registry lock the daemon's start takes before it
|
|
408
|
+
// registers the default folder, so a forget cannot land in the middle of
|
|
409
|
+
// that (#5290).
|
|
410
|
+
const { removed } = await removeFolder(root);
|
|
406
411
|
say(
|
|
407
412
|
removed
|
|
408
413
|
? ok(`Forgot ${root}. Your computer keeps watching the ${(await readRegistry()).length} folder(s) left in ${registryPath()}.`, { color })
|
package/lib/acp.mjs
CHANGED
|
@@ -857,10 +857,17 @@ export function runAcpChild(opts) {
|
|
|
857
857
|
// The allowlist rides to the adapter's Claude Code as `allowedTools`
|
|
858
858
|
// (the permission door above); without one nothing is auto-allowed.
|
|
859
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
|
+
};
|
|
860
867
|
const params = {
|
|
861
868
|
cwd,
|
|
862
869
|
mcpServers: Array.isArray(acp.mcpServers) ? acp.mcpServers : [],
|
|
863
|
-
...(
|
|
870
|
+
...(Object.keys(options).length > 0 ? { _meta: { claudeCode: { options } } } : {}),
|
|
864
871
|
};
|
|
865
872
|
let created;
|
|
866
873
|
// Explicit crash recovery requires the saved conversation. Ordinary
|
package/lib/agent-selection.mjs
CHANGED
|
@@ -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 });
|