ccdeck 3.45.0 → 3.47.0

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 (61) hide show
  1. package/README.md +79 -47
  2. package/bin/cli/startup.js +27 -3
  3. package/bin/deck.js +32 -1
  4. package/dist/web/assets/BrowserWatchModal-Bau0ttnH.js +1 -0
  5. package/dist/web/assets/IntegrationModal-8tTi25gA.js +6 -0
  6. package/dist/web/assets/RadioPanel-DbmJJPsz.js +1 -0
  7. package/dist/web/assets/TrafficRadar-CPjAXd5e.js +8 -0
  8. package/dist/web/assets/{UsageHistoryModal-DAhplVju.js → UsageHistoryModal-qfmvXdWJ.js} +1 -1
  9. package/dist/web/assets/app-BFFG6Wz8.js +321 -0
  10. package/dist/web/assets/app-DfcfHvcX.css +1 -0
  11. package/dist/web/assets/claude-settings-index-1Qg1AUda.js +1 -0
  12. package/dist/web/assets/{index-r8Ymr47Q.js → index-Ca87aJP9.js} +1 -1
  13. package/dist/web/index.html +3 -3
  14. package/package.json +1 -1
  15. package/release-notes.json +60 -0
  16. package/src/server/ccusage-install.mjs +58 -1
  17. package/src/server/ccusage-registry.mjs +289 -0
  18. package/src/server/ccusage-runner.mjs +9 -2
  19. package/src/server/claude-accounts.mjs +56 -19
  20. package/src/server/claude-login.mjs +129 -0
  21. package/src/server/claude-settings-catalog.d.mts +37 -0
  22. package/src/server/claude-settings-catalog.mjs +169 -0
  23. package/src/server/claude-settings-docs.mjs +109 -0
  24. package/src/server/claude-settings-index.json +251 -0
  25. package/src/server/claude-settings-routes.mjs +46 -0
  26. package/src/server/claude-settings.mjs +406 -0
  27. package/src/server/cli-arrival.mjs +64 -0
  28. package/src/server/cswap-admin.mjs +12 -3
  29. package/src/server/index.mjs +18 -2
  30. package/src/server/installer.mjs +24 -7
  31. package/src/server/integrations/proxy.mjs +11 -2
  32. package/src/server/integrations/routes.mjs +6 -4
  33. package/src/server/login-service.mjs +2 -2
  34. package/src/server/quota-close-watch.mjs +81 -0
  35. package/src/server/quota-closes.mjs +181 -0
  36. package/src/server/quota-history.mjs +8 -1
  37. package/src/server/quota-shape.mjs +12 -0
  38. package/src/server/quota.mjs +28 -1
  39. package/src/server/request-gates.mjs +3 -1
  40. package/src/server/skill-hook.mjs +28 -22
  41. package/src/server/system-metrics.mjs +4 -0
  42. package/src/server/tool-audit-operations.mjs +30 -10
  43. package/src/server/tool-audit-report.mjs +79 -7
  44. package/src/server/tool-audit-routes.mjs +5 -1
  45. package/src/server/tool-audit-skills.mjs +8 -3
  46. package/src/server/tool-audit.mjs +55 -5
  47. package/src/server/traffic-radar-capture.mjs +3 -3
  48. package/src/server/traffic-radar-config.mjs +43 -3
  49. package/src/server/traffic-radar-monitor.mjs +8 -5
  50. package/src/server/traffic-radar-permission.mjs +162 -0
  51. package/src/server/traffic-radar-platform.mjs +93 -20
  52. package/src/server/traffic-radar-routes.mjs +8 -18
  53. package/src/server/traffic-radar-service.mjs +81 -94
  54. package/src/server/traffic-radar.mjs +32 -9
  55. package/src/server/usage-routes.mjs +14 -2
  56. package/dist/web/assets/BrowserWatchModal-Cbzf3TWa.js +0 -1
  57. package/dist/web/assets/IntegrationModal-BnnBr0a3.js +0 -5
  58. package/dist/web/assets/RadioPanel-BIqrMLQN.js +0 -1
  59. package/dist/web/assets/TrafficRadar-D1gZCIwX.js +0 -8
  60. package/dist/web/assets/app-BW3NYUYB.js +0 -318
  61. package/dist/web/assets/app-C5RY_wZ4.css +0 -1
package/README.md CHANGED
@@ -98,7 +98,8 @@ The deck opens on these eight pictures the first time it runs — they are the w
98
98
  | **Live DAG** | Nodes are agents and edges are spawns; each agent's latest tool calls sit beside its node and light up while they run. In-flight edges animate, settled ones dim. |
99
99
  | **Both providers, one canvas** | Claude Code through hooks, Codex through its rollout log. The model chip (`Opus 5`, `GPT-5.5`) tells them apart. Codex child sessions are connected when their rollout records an explicit parent. Each thread keeps its own tool calls and token totals. |
100
100
  | **Cost and quota, live** | Spend per model and per session, plus Claude and Codex quota windows as they refill. |
101
- | **Tool activity** | Which tools and commands your Claude Code and Codex agents ran on this machine, over the last day or up to 90 days: how many calls, how long they took, which ones fail — and, on its Skills tab, which skills they used, how often and when last. Kept on this machine and nowhere else. |
101
+ | **Tool activity** | Which tools and commands your Claude Code and Codex agents ran on this machine, over the last day or up to 90 days: how many calls, how long they took, which ones fail. Kept on this machine and nowhere else. |
102
+ | **Skill activity** | Which skills your agents used, whether you typed them or the agent called them, how often and when last — from its own button on the right stripe, below Tool activity. Kept on this machine and nowhere else. |
102
103
  | **Jira beside your agents** | Connect Jira Cloud or Jira Server / Data Center in **Settings › Integrations**, and a Jira control joins the left stripe (`I`). It opens a board's backlog laid out the way Jira's Backlog page lays it out — active sprints first, then the future ones and the backlog, in Jira's rank order, with the board's own quick filters, *Only my issues* and *Hide done* — and an issue's description, comments, attachments and sub-tasks beside the list. Read-only: it never changes anything in Jira. |
103
104
  | **GitHub and GitLab beside your agents** | Connect GitHub, or GitLab.com or your own GitLab, with a personal access token in **Settings › Integrations**, and its control joins the left stripe. It opens the screens you already work through on GitLab — Branches, Merge requests (Pull requests), Pipelines (Actions) and Issues, for one project or across them — with the merge request, branch, pipeline with its jobs and the failed job's last log lines, or issue beside the list. Paste a link to open it. Read-only: it never comments, approves, merges or re-runs anything. |
104
105
  | **Double-click to inspect** | Any node opens its prompt, tool calls, token usage and timing in the side panel. A single click selects it and frames its session. |
@@ -129,11 +130,11 @@ The panels open from the window's edges: the session list and the Claude account
129
130
 
130
131
  Two notes can appear at the bottom of the canvas: **Undo**, for a few seconds after `R` or the re-arrange button lays the canvas out again — `Ctrl+Z` (`⌘Z` on a Mac) does the same — and **Resume**, which turns auto-fit back on after you have panned or zoomed.
131
132
 
132
- Everything the page lets you set apart from the music — the theme, the text size and spacing, the character on the canvas, the single-key shortcuts, the sounds and notifications, how long Tool activity keeps its history — is in **Settings**, behind the gear at the right of the topbar, or `Cmd+,` (`Ctrl+,` on Windows and Linux); the music is in **Radio**, below. Changes apply immediately except startup recovery, which applies at the next server start. **Settings › Appearance** holds twelve color themes, Gruvbox Dark, Gruvbox Light and Gruvbox Material the newest — a fresh install starts in Rider Black rather than following your system's light or dark setting, a theme you picked stays, `T` steps through all twelve, and the deck fades from one theme to the next over 180 ms, or switches at once when your system asks for reduced motion — and the character: Deck companion, Fox or Penguin, with a switch to hide it. **Settings › Text & density** has five text sizes — Smallest, Smaller, Default, Larger and Largest, 11, 12, 13, 15 and 17 px for body text — and five densities for the spacing in lists, panels and controls: Tightest, Tighter, Compact, Default and Comfortable, at 30%, 50%, 70%, 100% and 140% of the designed spacing. Both are kept in this browser, and neither is a zoom: your browser's zoom and the canvas's stay where they were, the panels widen for larger text, and the cards on the canvas follow it. **Reset to defaults** puts both back. The sounds and how loud each tone is are in **Settings › Sounds**, which `V` opens straight away; `M` turns sounds off or on from anywhere. `?` lists every key. If you use voice control or press letters by accident, turn off **Single-key shortcuts** in **Settings › Keyboard**, which also lists every shortcut: letters, `?` and Space then do nothing, while `Cmd+,`, `Esc`, `Enter`, `Tab`, `Delete` and the arrows keep working.
133
+ Everything the page lets you set apart from the music — the theme, the text size and spacing, the character on the canvas, the single-key shortcuts, the sounds and notifications, how long Tool activity keeps its history — is in **Settings**, behind the gear at the right of the topbar, or `Cmd+,` (`Ctrl+,` on Windows and Linux); the music is in **Radio**, below. Changes apply immediately except startup recovery, which applies at the next server start. **Settings › Appearance** holds twelve color themes, Gruvbox Dark, Gruvbox Light and Gruvbox Material the newest — a fresh install starts in Rider Black rather than following your system's light or dark setting, a theme you picked stays, `T` steps through all twelve, from inside any dialog too unless you are typing in a field, and the deck fades from one theme to the next over 180 ms, or switches at once when your system asks for reduced motion — and the character: Deck companion, Fox or Penguin, with a switch to hide it. **Settings › Text & density** has five text sizes — Smallest, Smaller, Default, Larger and Largest, 11, 12, 13, 15 and 17 px for body text — and five densities for the spacing in lists, panels and controls: Tightest, Tighter, Compact, Default and Comfortable, at 30%, 50%, 70%, 100% and 140% of the designed spacing. Both are kept in this browser, and neither is a zoom: your browser's zoom and the canvas's stay where they were, the panels widen for larger text, and the cards on the canvas follow it. **Reset to defaults** puts both back. The sounds and how loud each tone is are in **Settings › Sounds**, which `V` opens straight away; `M` turns sounds off or on from anywhere. `?` lists every key. If you use voice control or press letters by accident, turn off **Single-key shortcuts** in **Settings › Keyboard**, which also lists every shortcut: letters, `?` and Space then do nothing, while `Cmd+,`, `Esc`, `Enter`, `Tab`, `Delete` and the arrows keep working. **Settings › Claude Code**, there when Claude Code is, changes twelve of Claude Code's own settings in your `settings.json` — whether your sessions take messages from and can find each other, auto memory, automatic compaction, how long conversations are kept, checkpoints for rewind, the Co-Authored-By credit, the terminal's tips, turn duration and motion, and the update channel. It shows only what it read: a value that comes from somewhere else, such as an environment variable or your organization, is said under its row, and a `settings.json` it cannot read shows no values, only why. Below them it lists every setting Claude Code documents, the ones your file sets first, each with a link to Claude Code's reference (see [What it touches](#what-it-touches)).
133
134
 
134
135
  **Radio**, on the right sidebar beside the character (in **More** on a phone), opens a responsive Radio Explorer with a large interactive map, station discovery and a persistent player. Filter by country, sound or language, save favorites, return to recent stations, or choose **Surprise me**. Your existing Claude FM, Lofi Girl and custom streams are under **Your streams**. Select a station to inspect it, then press Play to listen; closing Radio or hiding the character keeps it playing. Favorites, history and the last catalogue are saved in this browser. Control music directly in Radio Explorer; character settings are in **Settings › Appearance**.
135
136
 
136
- **Tool activity**, on the stripe on the right below Usage history (in **More** on a phone), is a page of which tools and commands the Claude Code and Codex agents on this machine used. For the last 24 hours, 7, 30 or 90 days, and both CLIs or one, it lists each tool's calls, its total and usual time and its failures, sortable by any of them and searchable, under up to three findings worth a look: the tool that takes the most time, one that fails often, the slowest. A row opens that tool's details beside the list: who used it, its calls per day, its latest and slowest calls. A shell command counts per operation — `git status`, `git push` and `npm run build` are rows of their own — and an MCP tool under its own name. A call's time runs from the agent starting the tool to its result, so it includes any wait for your approval, and Claude Code and Codex time their tools differently. Its **Skills** tab, beside **Tools** at the top, lists the skills those agents used, ranked by uses, with when each last ran: a skill Claude calls, a slash command you type (only when the deck is started with `AGENTS_DECK_SKILL_HOOK=1` and every Claude Code on the machine is 2.1.116 or newer — see [How it works](#how-it-works)), a skill you pick in Codex, and one Codex picks itself, detected when it reads that skill's instructions. The same command run again in a session with the same arguments, such as a `/loop` tick, is a repeat and is left out of the count. A skill opens its details: its uses per day, the projects it ran in, and its latest uses, each linking to its session while that is still on the canvas. It counts what the deck captures from the first time it runs at 3.42.0 or later — earlier sessions are not read back — and it is kept apart from the canvas: Clear empties the canvas and leaves the tool history. What it keeps, and where, is in [What it touches](#what-it-touches).
137
+ **Tool activity**, on the stripe on the right below Usage history (in **More** on a phone), is a page of which tools and commands the Claude Code and Codex agents on this machine used. For the last 24 hours, 7, 30 or 90 days, and both CLIs or one, it lists each tool's calls, its total and usual time and its failures, sortable by any of them and searchable, under up to three findings worth a look: the tool that takes the most time, one that fails often, the slowest. A row opens that tool's details beside the list: who used it, its calls per day, its latest and slowest calls. A shell command counts per operation — `git status`, `git push` and `npm run build` are rows of their own — and an MCP tool under its own name. A call's time runs from the agent starting the tool to its result, so it includes any wait for your approval, and Claude Code and Codex time their tools differently. Its **Skills** tab, beside **Tools** at the top, lists the skills those agents used, ranked by uses, with when each last ran: a skill Claude calls, a slash command you type (when every Claude Code on the machine is 2.1.116 or newer — see [How it works](#how-it-works)), a skill you pick in Codex, and one Codex picks itself, detected when it reads that skill's instructions. The same command run again in a session with the same arguments, such as a `/loop` tick, is a repeat and is left out of the count. A skill opens its details: its uses per day, the projects it ran in, and its latest uses, each linking to its session while that is still on the canvas. It counts what the deck captures from the first time it runs at 3.42.0 or later — earlier sessions are not read back — and it is kept apart from the canvas: Clear empties the canvas and leaves the tool history. What it keeps, and where, is in [What it touches](#what-it-touches).
137
138
 
138
139
  No config file. No account. What your sessions contain — your prompts, the replies, the files they touch — is never reported anywhere. The deck does send usage reports, on by default: its version, your system, your IP address and a device fingerprint, rough counts such as how many sessions ran in a day, and the errors it hits. It has no switch for them; `AGENTS_DECK_NO_REPORTS=1` keeps them off from the first start.
139
140
 
@@ -207,25 +208,43 @@ phone. Three views keep configuration, observed traffic and saved files separate
207
208
  lines; the first 200 matching rows are displayed. File contents alone do not
208
209
  prove that a record was sent.
209
210
 
210
- Choose all configured IPv4 destinations, one destination or a custom IPv4
211
- address and port, then press **Start monitoring** once. ccdeck runs the capture
212
- itself, as the user running ccdeck: there is no command to paste into a
213
- Terminal or PowerShell tab, and no repeated ten-minute activation. It retries
214
- after a capture-process failure or network interface change, and remembers the
215
- enabled destinations across server restarts. What that user needs:
216
-
217
- - **macOS** — the `tcpdump` macOS includes, and permission to capture, which
218
- Wireshark’s official
219
- [ChmodBPF permission helper](https://www.wireshark.org/docs/wsug_html_chunked/ChBuildInstallOSXInstall.html)
220
- grants.
221
- - **Linux** — `tcpdump`, and packet capture permission for the user running
222
- ccdeck.
211
+ Radar monitors by itself, always: there is no Start, no Stop and no
212
+ destination to pick. ccdeck finds Claude Code's collector — from Claude's
213
+ settings, a running session's environment (a collector named by host is looked
214
+ up), the collectors it found before, or an active IPv4 OTLP/gRPC connection on
215
+ port 4317 — and runs the capture itself, as the user running ccdeck, with no
216
+ command to paste into a Terminal or PowerShell tab. It looks every five seconds
217
+ while Radar is open and about once a minute while it is closed, retries after a
218
+ capture-process failure or network interface change, and remembers the
219
+ collectors it found across server restarts.
220
+
221
+ Packet capture needs an administrator once. When it is missing, Monitor shows
222
+ **Allow packet capture once**, says what will change, and **Allow capture…**
223
+ opens the system's own password prompt:
224
+
225
+ - **macOS** — ccdeck adds a small helper of its own,
226
+ `/Library/LaunchDaemons/dev.ccdeck.chmodbpf.plist`, which does at every
227
+ startup what Wireshark's
228
+ [ChmodBPF](https://www.wireshark.org/docs/wsug_html_chunked/ChBuildInstallOSXInstall.html)
229
+ does: it lets the `access_bpf` group read the packet-capture devices, and
230
+ your user joins that group. This startup's devices are handed to you
231
+ directly, so capture starts without logging in again. A Mac with Wireshark's
232
+ ChmodBPF already set up needs nothing.
233
+ - **Linux** — ccdeck installs `tcpdump` with your package manager (apt, dnf,
234
+ zypper or pacman) when it is missing, then lets it capture
235
+ (`cap_net_raw,cap_net_admin`) and limits running it to your own group. A
236
+ `tcpdump` update replaces the file and drops this; Radar then asks again. The
237
+ desktop app's `.deb` recommends `tcpdump`, so apt installs it with the app.
223
238
  - **Windows** — [Wireshark with Npcap](https://www.wireshark.org/download.html)
224
- (ccdeck runs its `dumpcap`), with capture access for that user.
239
+ (ccdeck runs its `dumpcap`), which you install yourself: Npcap's free edition
240
+ may not be installed by another program.
225
241
 
226
- ccdeck stays unprivileged: it does not install drivers or change permissions. A
227
- blocked capture shows its permission or reconnecting state rather than claiming
228
- to be listening, and capture starts by itself once access is granted.
242
+ Where no password prompt can open — a deck reached over SSH, a Linux desktop
243
+ with no polkit agent — Radar writes the same setup script to
244
+ `~/.agents-deck/radar-capture-setup.sh` and shows the one `sudo` command that
245
+ runs it. Nothing else is changed without that password. A blocked capture shows
246
+ its permission or reconnecting state rather than claiming to be listening, and
247
+ capture starts by itself as soon as access is granted.
229
248
 
230
249
  Each destination gets its own decoder, up to eight destinations per capture.
231
250
  Linux captures routed and loopback traffic through `any`; macOS resolves the
@@ -245,27 +264,21 @@ success and rejection. Acceptance does not prove final backend storage. Contents
245
264
  come from captured traffic, not local conversation transcripts. Messages remain
246
265
  in local server memory for 24 hours, up to 2,000 exports and a 32 MiB encoded
247
266
  payload budget; unreadable observations are capped at 2,000 for 24 hours. The
248
- oldest entries are removed when a limit is reached. Stop/Start and closing the
249
- modal preserve history; restarting ccdeck removes it.
267
+ oldest entries are removed when a limit is reached. Closing the modal preserves
268
+ history; restarting ccdeck removes it.
250
269
  No capture file is written. **Pause list** pauses display, not capture or retention;
251
270
  **Clear messages** clears exports and unreadable observations.
252
271
 
253
- Monitoring continues until **Stop monitoring** or until ccdeck exits. An enabled
254
- monitor resumes when ccdeck next starts on the same port; Stop is remembered too.
255
- Closing the modal or browser does not stop capture. Only the opt-in and collector
256
- destinations are saved, never packet contents, tokens or decoded messages.
257
- Capture contents are available through the local loopback UI, not LAN endpoints.
258
- Local clients of the same server share its capture.
259
-
260
- **Automatic monitoring** is off unless you turn it on in **Settings → Radar →
261
- Monitor automatically**. On, ccdeck finds the collector itself — from Claude's
262
- settings, a monitor you started, or an active IPv4 OTLP/gRPC connection on port
263
- 4317 — monitors it without Radar open, and retries every five seconds while
264
- none is available; Monitor then hides Start and the destination picker. Off
265
- stops it, and nothing is looked for or retried.
266
-
267
- Configuration and connection sampling runs only while Radar is open and the
268
- browser page is visible. A connection does not prove an upload, and absence of
272
+ Monitoring continues while ccdeck runs and starts again with it;
273
+ `AGENTS_DECK_NO_RADAR=1` keeps a deck from looking for a collector or capturing
274
+ at all. Closing the modal or browser does not stop capture. Only the collector destinations are
275
+ saved, never packet contents, tokens or decoded messages. Capture contents are
276
+ available through the local loopback UI, not LAN endpoints. Local clients of
277
+ the same server share its capture.
278
+
279
+ Configuration and connection sampling runs every five seconds while Radar is
280
+ open and the browser page is visible, and about once a minute in the
281
+ background, to find the collector. A connection does not prove an upload, and absence of
269
282
  observed traffic does not mean telemetry is disabled. Native-process sampling
270
283
  can miss short-lived connections and Node wrappers. Windows samples native
271
284
  Claude processes with PowerShell; Linux uses process names and owned `/proc`
@@ -330,7 +343,7 @@ SubagentStart · SubagentStop · Stop · StopFailure · SessionEnd · Notificati
330
343
 
331
344
  `StopFailure`, which Claude Code sends instead of `Stop` when a turn ends on an API error, is added only when every Claude Code the deck finds on disk is 2.1.78 or newer, read from its install rather than by running it. Older ones did not know the event, and before 2.1.101 an event name Claude Code did not know made it ignore the whole `settings.json`. When the deck cannot tell which version is installed, it leaves the entry out.
332
345
 
333
- `UserPromptExpansion`, which lets Tool activity's Skills tab count the slash commands you type, is off by default, and there is no switch for it in Settings. The deck adds it only when you start it with `AGENTS_DECK_SKILL_HOOK=1` (any other value is off), and then only when every Claude Code the deck finds is 2.1.116 or newer, the first that knows the event. An install that does not say its version is asked `claude --version`; one that still does not say counts as too old. Until 2.1.101 a hook event Claude Code did not know made it ignore the whole `settings.json` without saying so, so the deck would rather count no typed commands than risk that. Turned on, it writes that one entry, and the first time it does, it keeps the `settings.json` it replaced as `agent-dag/settings.before-skill-hook.json` beside the hook, readable only by you. Off, it changes nothing in `settings.json`, with one exception: start the deck without the variable, or with an older Claude Code, after a start that added the entry, and that entry is taken back out. Nothing else is touched, and a `UserPromptExpansion` hook of your own stays. What the Skills tab records — the skill's name, the session it ran in and its project folder's name — stays on this machine (see [What it touches](#what-it-touches)).
346
+ `UserPromptExpansion`, which lets Skill activity count the slash commands you type, is added only when every Claude Code the deck finds is 2.1.116 or newer, the first that knows the event. An install that does not say its version is asked `claude --version`; one that still does not say counts as too old. Until 2.1.101 a hook event Claude Code did not know made it ignore the whole `settings.json` without saying so, so the deck would rather count no typed commands than risk that; when it leaves the entry out for that reason, the start-up report says why and Skill activity says typed commands are not counted. The first time it writes the entry, it keeps the `settings.json` it replaced as `agent-dag/settings.before-skill-hook.json` beside the hook, readable only by you. There is no switch for it in Settings: start the deck with `AGENTS_DECK_SKILL_HOOK=0` to leave it out, and a start like that, or one with an older Claude Code, after a start that added the entry takes that entry back out. Nothing else is touched, and a `UserPromptExpansion` hook of your own stays. What Skill activity records — the skill's name, the session it ran in and its project folder's name — stays on this machine (see [What it touches](#what-it-touches)).
334
347
 
335
348
  Each one fires the bundled `hook.js`, which POSTs the event JSON to the running server. The hook is fire-and-forget with a 1-second timeout: if the deck is not running, your session is not slowed down and nothing fails.
336
349
 
@@ -344,7 +357,9 @@ Opening Radio asks the public [Radio Browser](https://www.radio-browser.info/) d
344
357
 
345
358
  It never steers an agent or edits your code, but it is not read-only either — besides the hook entry and its own event log, it manages the two tools it leans on, and it refreshes the Codex token it reads quota with, rewriting `~/.codex/auth.json` the way `codex` itself does. It also reads your browser's history, because Browser Watch is on unless you switch it off; that is its own section below, because it is the one thing here that is about you rather than about an agent.
346
359
 
347
- Telemetry Radar's flag switches write to `~/.claude/settings.json` too: each puts the flag you set — `CLAUDE_CODE_ENABLE_TELEMETRY`, `OTEL_LOG_USER_PROMPTS` and the other telemetry and content flags Radar lists — in that file's `env` block, as `"1"` or `"0"`. Switching a flag off writes `"0"` rather than removing it, and `--uninstall`, which removes ccdeck's hook entries, leaves these values as you set them. Starting Radar's monitoring writes `~/.agents-deck/radar-monitor-<port>.json`: the opt-in and the destinations a deck on that port resumes, never packets or decoded messages; turning on automatic monitoring writes `radar-settings-<port>.json` beside it, the switch and the collectors it found. And the quota readings the deck takes are kept in `quota-history.json`, in its data directory (see [Uninstall](#uninstall)), for 35 days and up to 2 MB, under a hash of the account rather than its address, for the Usage panel's quota history. What each Claude organization's settings turn on for telemetry is kept in `org-telemetry.json`, in the same data directory: per organization, its name, the level, the content flags that are on, the collector's scheme, host and port, and when the deck read them, never a path, a header or a credential.
360
+ Telemetry Radar's flag switches write to `~/.claude/settings.json` too: each puts the flag you set — `CLAUDE_CODE_ENABLE_TELEMETRY`, `OTEL_LOG_USER_PROMPTS` and the other telemetry and content flags Radar lists — in that file's `env` block, as `"1"` or `"0"`. Switching a flag off writes `"0"` rather than removing it, and `--uninstall`, which removes ccdeck's hook entries, leaves these values as you set them. Radar's monitoring writes `~/.agents-deck/radar-monitor-<port>.json`, the destinations a deck on that port resumes, never packets or decoded messages, and `radar-settings-<port>.json` beside it, the collectors it found. And the quota readings the deck takes are kept in `quota-history.json`, in its data directory (see [Uninstall](#uninstall)), for 35 days and up to 2 MB, under a hash of the account rather than its address, for the Usage panel's quota history. What each Claude organization's settings turn on for telemetry is kept in `org-telemetry.json`, in the same data directory: per organization, its name, the level, the content flags that are on, the collector's scheme, host and port, and when the deck read them, never a path, a header or a credential.
361
+
362
+ **Settings › Claude Code** writes `~/.claude/settings.json` only when you change one of its rows, and only that row's key: going back to Claude Code's default removes the key, and **Let sessions find each other** adds or removes the bare `ListAgents` entry in `permissions.deny` and nothing else in that list. Before each change it keeps the file as it was as `claude-settings.before-change.json` in its data directory, readable only by you. It never writes managed, organization or project settings, nor `~/.claude.json`. A row your organization decides, or one that needs a newer Claude Code than the one it finds, cannot be changed there. The page sees only on/off values, numbers and documented choices from the file; `env` blocks, helper commands and tokens show as "set". `--uninstall` leaves what you set there.
348
363
 
349
364
  Tool activity keeps its history in `tool-audit/`, in the same data directory: a file a day with a line per tool call — Claude Code or Codex, when it started and ended, whether it failed, and the tool's name or, for a shell command, its operation (`git push`, `npm run build`) — with a line per skill used, holding the skill's name, the session it ran in and the name of its project folder, and a `settings.json` holding how long to keep it, when it started counting, and a random id for this device that nothing sends anywhere. The rest of a command line, the tool's or the skill's arguments and output, and paths are not saved, nor a tool call's session id, and nothing in the folder leaves the machine. It keeps 90 days unless you pick 30 or 60 under **Keep history** in **Settings › Data › Tool history**, which also shows the space it takes and has **Clear history…**; older days are deleted as they fall out. `--no-persist` does not stop it — that flag is about the events log — and `--uninstall` leaves it, `--purge` too (see [Uninstall](#uninstall)).
350
365
 
@@ -376,6 +391,8 @@ The Accounts panel reads the store [claude-swap](https://github.com/realiti4/cla
376
391
 
377
392
  The deck installs that package itself, so it installs it **bounded**: `claude-swap~=0.26`, which is `>= 0.26, == 0.*`, and when PyPI can be reached the exact version it resolved rather than the range. What `cswap --version` reports afterwards has to be that version, or the deck says so and leaves the panel dark rather than driving a copy it cannot account for — this is the tool that holds your Claude logins. The daily upgrade is bounded by the same specifier, and what it left behind is written to `~/.agents-deck/cswap-upgrade.json`.
378
393
 
394
+ The active account is the one Claude Code is signed in to, as `cswap list` shows it, even after a `/login` made outside the deck; when that login is not one of your accounts, the panel says so above the list, with **Add account**.
395
+
379
396
  **Switch** on an account's row makes it the active one. New sessions start on it; sessions already running are not restarted, and pick it up on their next message — up to about 30 seconds later on macOS. Because every session on the machine shares that one login, the deck will not switch to an account whose saved login claude-swap has already seen refused: it asks claude-swap to read the account first when a read is due, and if the login has expired the row says so, with **Sign in again**, and nothing moves. When it cannot tell — offline, or claude-swap does not answer in time — the switch goes ahead. **Auto-switch**, off until you turn it on, does the same without a press: about once a minute the deck runs claude-swap's own engine, which, once the active account passes your threshold (90% unless you choose another) of its 5-hour or 7-day window, moves Claude Code to the account with the most room left. Every account keeps its own limits; when no other account is under the threshold, nothing switches. Auto-switch also moves Claude Code off an account whose login has expired, once Claude Code has signed it out and claude-swap's stored copy of it no longer works either, to the account with the most room under the threshold that claude-swap has not set aside and no local `cswap run` session is using; the expired one stays in the list, waiting for you to sign it in again. When Claude Code sessions stop on an expired login or a usage limit, Auto-switch runs once right away instead of waiting for its next minute, and the cards say `Stopped · login expired` or `Stopped · usage limit` until the session does something again: type `continue` in each one once a working login is active. A session running in the background (`claude --bg`, agent view) gets **Continue** on its card instead, enabled once the active account's usage reading shows a working login with room since the stop: it runs Claude Code's own [`claude stop` and `claude --resume <session> --bg`](https://code.claude.com/docs/en/sessions) in the session's folder, and the card says how that went. **Continue stopped background sessions**, in **Settings › General**, off until you turn it on, presses it for you, once per stop; a session that stops again right after is left for you. **Custom…**, last in the threshold picker, takes any whole percent from 50 to 99 and refuses anything else under the field without saving it; the threshold is claude-swap's own setting, kept on this machine.
380
397
 
381
398
  Two choices change where Auto-switch goes, and do nothing while it is off. **Next account**, under the switch, is **Most room left** — claude-swap's own pick, and the default — or **Soonest weekly reset**: the account whose 7-day window resets soonest, as long as that is within 95 hours, so quota that is about to reset is used first. With it, the deck also moves below the threshold, to an account that resets at least an hour sooner than the one in use, and never sooner than half an hour after the last move. **Set as home**, in an account's **⋯**, marks the row with ⌂: Auto-switch takes you there, does not move you off it before the threshold, and comes back once its 5-hour window has reset. Only an account comfortably under the threshold, read in the last 15 minutes, signed in, in rotation, not set aside by claude-swap and not in use in a local `cswap run` session is moved to. An account reported as active on another paired device remains eligible for Home and Soonest weekly reset. If Home has stale readings, Auto-switch asks claude-swap to collect before choosing a weekly alternative; if Home is still unavailable afterward, it uses the alternative. A switch you make yourself is left alone until that account reaches the threshold, or until you set a home or pick a rule again. When no account fits either rule, claude-swap decides, as before. Both choices are kept on this machine.
@@ -593,7 +610,9 @@ installers put it), or when its config dir carries traces of having been used;
593
610
  Codex counts as present when `~/.codex/` exists. On a machine with only one of
594
611
  them, the other one's hooks, installs and panels are skipped rather than shown
595
612
  empty — the boot banner says which way it went, and `--claude` / `--codex`
596
- override it if the guess is wrong.
613
+ override it if the guess is wrong. A CLI installed while the deck is running is
614
+ noticed within about fifteen seconds, and the deck restarts itself to serve it
615
+ (unless you started it with `--no-claude` / `--no-codex`).
597
616
 
598
617
  `--workspace` is a filter this deck applies to itself, not a claim on the sessions it matches: **every** running deck whose workspace contains a session's directory draws that session. That is not a way to keep a machine-wide deck and one scoped to `~/proj` side by side: in one Claude config directory the second start stops the first and takes its place, as above. The filter reads the same way on all three paths a session can reach the canvas by — Claude Code's hook, Codex's rollout files, and the boot replay of the events log — and the events log still gets exactly one copy of each event, whichever decks are up. A relative path is resolved against the directory you start the deck in, and once, so every path scopes to the same tree. The log is machine-wide by default and shared by every deck on the box, so a scoped deck replays only the part of it that is inside its own workspace: it comes up showing what it will go on to capture, and nothing else.
599
618
 
@@ -618,7 +637,7 @@ Environment:
618
637
  | `AGENTS_DECK_CSWAP` | Full path to `cswap`, when it lives somewhere unusual |
619
638
  | `AGENTS_DECK_CLAUDE` | Full path to the `claude` CLI |
620
639
  | `AGENTS_DECK_CCUSAGE` | Full path to your own `ccusage`, used ahead of everything else |
621
- | `AGENTS_DECK_SKILL_HOOK=1` | Add the `UserPromptExpansion` hook, so Tool activity's Skills tab counts the slash commands you type — only where every Claude Code found is 2.1.116 or newer. Off by default, and only `1` turns it on |
640
+ | `AGENTS_DECK_SKILL_HOOK` | Set to `0` to leave out the `UserPromptExpansion` hook, which lets Skill activity count the slash commands you type. On by default, and added only where every Claude Code found is 2.1.116 or newer; any value but `1` turns it off |
622
641
  | `CLAUDE_SWAP_BACKUP` | Override the claude-swap store root the Accounts panel reads |
623
642
  | `CCDECK_HOME` | Put everything the deck writes — its state and its log — under this directory instead of the platform default. Wins over every rule below it |
624
643
  | `CLAUDE_CONFIG_DIR` | Override `~/.claude` — the hook entry, the event log and everything else the deck writes move with it |
@@ -626,7 +645,7 @@ Environment:
626
645
 
627
646
  `AGENTS_DECK_NO_MUSIC=1` turns Radio off: no station directory requests, no play reports and no playback. It is not in the table because, unlike the variables above, the login item does not carry it and the desktop app does not take it from your login shell: it holds for a deck started where it is set.
628
647
 
629
- Usage history is read with `ccusage`, and the deck takes the first of these that answers: `AGENTS_DECK_CCUSAGE` if you set it, then the copy it installed for itself under `~/.agents-deck/ccusage`, then a `ccusage` on your PATH, then `npx -y ccusage@latest`. So installing ccusage yourself is enough — the deck will not fetch a second copy, and it works under `AGENTS_DECK_NO_INSTALL=1`, which is the combination that variable is for. When something fails, the modal names which of those four it was.
648
+ Usage history is read with `ccusage`, and the deck takes the first of these that answers: `AGENTS_DECK_CCUSAGE` if you set it, then the copy it installed for itself under `~/.agents-deck/ccusage`, then a `ccusage` on your PATH, then `npx -y ccusage@latest`. On a machine with no npm at all, such as the desktop app on a computer without Node, the deck downloads its copy from the npm registry itself, checked against the sha512 the registry publishes, and there is no npx step. So installing ccusage yourself is enough — the deck will not fetch a second copy, and it works under `AGENTS_DECK_NO_INSTALL=1`, which is the combination that variable is for. When something fails, the modal names which of those four it was.
630
649
 
631
650
  Open **Usage → By session** and select a Claude Code or Codex row to inspect its whole-session cost estimate, input/output and cache tokens, model breakdown and activity dates. This also works for historical sessions no longer on the canvas. The whole session may extend beyond the period selected in Usage; logs missing from this machine cannot be recovered by the inspector. Its token breakdown also shows **Cached input reuse**, the share of the session's measured input that was read from cache.
632
651
 
@@ -664,10 +683,23 @@ platform's **data** directory, and the platform's **log** directory.
664
683
  `prefs.json` is the one to delete deliberately: it holds this deck's **Local
665
684
  network private key**, the one every deck you paired with has pinned. Leaving it
666
685
  behind leaves that identity on the machine. (`~/.agents-deck/` holds the managed
667
- tools and the deck's records about them, `radar-monitor-<port>.json` once
668
- Telemetry Radar has monitored — the destinations it resumes — and
669
- `radar-settings-<port>.json` once its automatic monitoring has been switched,
670
- but no key.)
686
+ tools and the deck's records about them, `radar-monitor-<port>.json` and
687
+ `radar-settings-<port>.json` once Telemetry Radar has monitored — the
688
+ destinations it resumes and the collectors it found — but no key.)
689
+
690
+ **Allow capture** changed the system, so undoing it takes an administrator too.
691
+ On macOS:
692
+
693
+ ```bash
694
+ sudo launchctl bootout system/dev.ccdeck.chmodbpf
695
+ sudo rm /Library/LaunchDaemons/dev.ccdeck.chmodbpf.plist "/Library/Application Support/ccdeck/ccdeck-chmodbpf"
696
+ ```
697
+
698
+ On Linux, give `tcpdump` back its packaged state:
699
+
700
+ ```bash
701
+ t=$(readlink -f "$(command -v tcpdump)"); sudo setcap -r "$t"; sudo chgrp root "$t"; sudo chmod 0755 "$t"
702
+ ```
671
703
 
672
704
  The data directory also holds Tool activity's `tool-audit/` folder — up to 90
673
705
  days of which tools and commands your agents ran, and how long they took — and
@@ -178,6 +178,29 @@ export async function respawnHooks({ wantClaude, installHooks, bootVersion }) {
178
178
  }
179
179
  }
180
180
 
181
+ /**
182
+ * What a respawn that found Claude Code says about the setup it then ran.
183
+ *
184
+ * That respawn is the restart src/server/cli-arrival.mjs asks for when Claude
185
+ * Code is installed while the deck runs, and it does the first boot's
186
+ * startupWork, which the first boot skipped for want of a Claude Code. It is
187
+ * reported here rather than by reportStartup because the deck is already in
188
+ * use: reportStartup ends the process over hooks it cannot install, which on a
189
+ * first boot is a deck that never started, and here would be a deck that went
190
+ * away from under an open window. A failure is said, and the deck keeps
191
+ * serving everything else, as a respawn that cannot update the hooks does.
192
+ */
193
+ export async function reportClaudeArrived(jobs) {
194
+ write(row({ mark: G.ok, label: "Claude Code", detail: `found ${G.dash} setting it up` }));
195
+ const hooks = await step(`installing Claude hooks${G.ellipsis}`, jobs.hooks);
196
+ if (hooks?.ok) {
197
+ write(row({ mark: G.ok, label: "Claude hooks", detail: fileLink(hooks.v.hookPath) }));
198
+ return;
199
+ }
200
+ write(row({ mark: G.fail, tone: P.err, label: "Claude hooks", detail: "not installed" }));
201
+ console.error(`\n ${PRODUCT}: ${String(hooks?.err?.message ?? hooks?.err ?? "the hooks could not be installed")}\n`);
202
+ }
203
+
181
204
  /** The same work, said out loud, in a fixed order — a boot whose rows arrive in
182
205
  * whatever order the network settled is a boot nobody can scan twice. */
183
206
  export async function reportStartup(jobs, { workspace, wantClaude, wantCodex, CODEX_SESSIONS_DIR }) {
@@ -216,9 +239,10 @@ export async function reportStartup(jobs, { workspace, wantClaude, wantCodex, CO
216
239
  process.exit(1);
217
240
  } else {
218
241
  write(row({ mark: G.ok, label: "Claude hooks", detail: fileLink(hooks.v.hookPath) }));
219
- // Skill activity's typed-command entry, said only when it was asked for
220
- // (AGENTS_DECK_SKILL_HOOK=1): installed, or why not. Not asked for, the
221
- // boot prints what it always printed. See skill-hook.mjs.
242
+ // Skill activity's typed-command entry, said only when the gate or the file
243
+ // kept it out, since then no typed command is counted. Installed, or turned
244
+ // off with AGENTS_DECK_SKILL_HOOK=0, the boot prints nothing more. See
245
+ // skill-hook.mjs.
222
246
  const skill = hooks.v.skillHook;
223
247
  if (skill && skill.state !== "off") {
224
248
  const { skillHookStatus } = await import(pathToFileURL(join(PKG_ROOT, "src/server/skill-hook.mjs")).href);
package/bin/deck.js CHANGED
@@ -15,6 +15,7 @@ import { pathToFileURL } from "node:url";
15
15
  import { existsSync } from "node:fs";
16
16
  import { RESTART_CODE, UPGRADE_CODE, dieWithParent, signalExitAction } from "../src/server/supervisor.mjs";
17
17
  import { parseArgs, startPort, wantsCli } from "../src/server/args.mjs";
18
+ import { watchForClis } from "../src/server/cli-arrival.mjs";
18
19
  import { unregisteredDetail } from "../src/server/pulse-line.mjs";
19
20
  import { PRODUCT } from "../src/server/brand.mjs";
20
21
  // A leaf — fs, path and claude-dir.mjs, nothing else — so it is imported here
@@ -36,7 +37,9 @@ import {
36
37
  G, P, fileLink, onHangup, printBanner, showCursor, step, takeCursor, tty, write,
37
38
  } from "./cli/screen.js";
38
39
  // The once-per-session work and the rows that report it.
39
- import { reportReady, reportRestarted, reportStartup, respawnHooks, startupWork } from "./cli/startup.js";
40
+ import {
41
+ reportClaudeArrived, reportReady, reportRestarted, reportStartup, respawnHooks, startupWork,
42
+ } from "./cli/startup.js";
40
43
  import { restartLatch } from "./cli/restart.js";
41
44
  import { startPulse } from "./cli/pulse.js";
42
45
  import { settleSecondStart } from "./cli/second-start.js";
@@ -252,6 +255,13 @@ const wantCodex = wantsCli({ off: flags.noCodex, on: flags.codex, installed: has
252
255
  // with a settings.json the installer refuses to rewrite needs, since that
253
256
  // refusal is fatal at boot on a component they do not use.
254
257
  const wantClaude = wantsCli({ off: flags.noClaude, on: flags.claude, installed: hasClaudeInstalled });
258
+ // A respawn that finds Claude Code where the session's first boot did not:
259
+ // installed while the deck ran, which is the restart src/server/cli-arrival.mjs
260
+ // asks for. The supervisor hands down how the first boot's hooks went, and
261
+ // "off" is "not attempted, no Claude Code". Such a respawn owes everything the
262
+ // first boot skipped for it — the hooks, claude-swap, the ccusage prime — so it
263
+ // runs the first boot's work rather than a respawn's. See reportClaudeArrived.
264
+ const claudeArrived = RESPAWN && wantClaude && process.env.AGENTS_DECK_BOOT_HOOKS === "off";
255
265
  // The Codex tree this deck would tail, spelled the way its discovery record will
256
266
  // spell it — the one field of a start's shape that is not a flag. Resolved here,
257
267
  // with the other three, because the second-start question below is asked of
@@ -429,6 +439,11 @@ if (!RESPAWN) {
429
439
  jobs.cswapQuiet.then(settleCswap);
430
440
  await printBanner();
431
441
  await reportStartup(jobs, { workspace, wantClaude, wantCodex, CODEX_SESSIONS_DIR });
442
+ } else if (claudeArrived) {
443
+ const jobs = startupWork({ wantClaude, installHooks, leftoverCodexHooks });
444
+ handDownSetup(noteSetup({ claude: jobs.hooks, codex: wantCodex }));
445
+ jobs.cswapQuiet.then(settleCswap);
446
+ await reportClaudeArrived(jobs);
432
447
  } else {
433
448
  settleCswap();
434
449
  // What a respawn says about the hooks is what it saw: its own re-install when
@@ -599,6 +614,22 @@ markDeckReady();
599
614
  try { process.send?.({ type: "booted" }); } catch { /* no channel; nothing waiting */ }
600
615
  runHeldRestart();
601
616
 
617
+ // A CLI installed while this deck runs is served from the restart this asks for
618
+ // — see src/server/cli-arrival.mjs. Only under a supervisor, which is the only
619
+ // thing that can bring the deck back.
620
+ if (SUPERVISED) {
621
+ watchForClis({
622
+ clis: [
623
+ { name: "Claude Code", want: wantClaude, off: flags.noClaude, installed: hasClaudeInstalled },
624
+ { name: "Codex", want: wantCodex, off: flags.noCodex, installed: hasCodexInstalled },
625
+ ],
626
+ onArrive: (name) => {
627
+ write(`\n ${P.ok}${G.ok}${P.reset} ${P.muted}${name} found ${G.dash} restarting to serve it${P.reset}\n`);
628
+ requestRestart();
629
+ },
630
+ });
631
+ }
632
+
602
633
  /**
603
634
  * A declaration, not the `const` arrow this was for eight months.
604
635
  *
@@ -0,0 +1 @@
1
+ import{j as e,b as r,U as J,V as Q,W as Y,X as V,Y as X,Z,_ as z,g as ee,s as se,l as te,n as ne,$ as ae,a0 as ie,R as re,d as oe}from"./app-BFFG6Wz8.js";function le({snap:s}){return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",e.jsxs("span",{className:"bw-feed-count",children:[s.log.length," ",s.log.length===1?"event":"events"]})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):s.log.map(a=>e.jsxs("div",{className:`bw-log-line ${a.level}${a.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(a.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),a.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:a.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:a.parts.profile,children:a.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[a.parts.value,a.parts.flagged>0&&e.jsxs("span",{className:"bw-log-flag",children:[" · ",a.parts.flagged," flagged"]})]})]}):e.jsx("span",{className:"bw-log-sys",children:a.text})]},`${a.atMs}-${a.level}-${a.text}`))})]})}const E=s=>`${s.host}-${s.startMs}`;function ce(s){const a=h=>new Date(h).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?a(s.startMs):`${a(s.startMs)} → ${a(s.endMs)}`}function de(s){return new Date(s).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function G(s){const a=Math.round((s.endMs-s.startMs)/6e4);return a<1?"":`${a} min`}function he({snap:s,dismiss:a,refreshRef:h}){const[c,d]=r.useState(null),u=r.useRef(new Map),t=r.useRef(null);r.useEffect(()=>{var i,w;const o=t.current;!o||s.episodes.some(b=>E(b)===o.id)||(t.current=null,J(((i=document.activeElement)==null?void 0:i.tagName)??null)&&((w=(o.next?u.current.get(o.next):void 0)??h.current)==null||w.focus()))},[s]);const n=o=>{t.current={id:E(o),next:Q(s.episodes.map(E),E(o))},a(o)},l=r.useMemo(()=>{const o=[];for(const i of s.episodes){const w=de(i.startMs),b=o[o.length-1];b&&b.label===w?b.episodes.push(i):o.push({label:w,episodes:[i]})}return o},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",s.episodes.length>0&&e.jsxs("span",{className:"bw-feed-count",children:[s.episodes.length," ",s.episodes.length===1?"episode":"episodes"]})]}),e.jsx("div",{className:"bw-eps",children:l.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),e.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",s.settings.quietMinutes," ",s.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):l.map(o=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:o.label}),o.episodes.map(i=>{const w=E(i),b=c===w;return e.jsxs("div",{className:`bw-ep${b?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:p=>{p?u.current.set(w,p):u.current.delete(w)},onClick:()=>d(b?null:w),"aria-expanded":b,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:b?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:i.host}),e.jsxs("span",{className:"bw-ep-meta",children:[ce(i),G(i)&&e.jsxs(e.Fragment,{children:[" · ",G(i)]}),i.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:"Its quiet window has not closed yet. If somebody used the browser in the minutes after it, it is withdrawn; until then it is not written down and no reaction runs.",children:"provisional"})]})]}),e.jsxs("span",{className:"bw-ep-count",children:[i.count," ",i.count===1?"page":"pages"]})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>n(i),"aria-label":`Dismiss ${i.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),b&&e.jsx("ul",{className:"bw-urls",children:i.urls.map((p,y)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(p.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:p.url})]},`${p.url}-${p.timeMs}-${y}`))})]},w)})]},o.label))})]})}function ue(s){const a=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!a)return!1;const h=parseInt(a[1],16),c=[h>>16&255,h>>8&255,h&255].map(d=>{const u=d/255;return u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)});return .2126*c[0]+.7152*c[1]+.0722*c[2]>.5}const K=1e4,we=12e3;function me({browsers:s,findings:a,watching:h,palette:c}){const d=r.useRef(null),u=r.useRef(null);return u.current={browsers:s,findings:a,watching:h},r.useEffect(()=>{var b;const t=d.current;if(!t)return;const n=t.getContext("2d");if(!n)return;const l=((b=window.matchMedia)==null?void 0:b.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let o=0,i=!1;const w=()=>{var q;if(i)return;const p=u.current;if(!p)return;const{browsers:y,findings:j,watching:P}=p,S=c["--accent"]||"#7dd3fc",g=c["--line"]||"#1f2229",v=c["--text-dim"]||"#6e727c",$=ue(c["--bg"]),N=$?42:26,k=$?.85:.65,A=Date.now(),R=Math.min(window.devicePixelRatio||1,2),C=t.clientWidth,W=t.clientHeight;(t.width!==C*R||t.height!==W*R)&&(t.width=C*R,t.height=W*R),n.setTransform(R,0,0,R,0,0),n.clearRect(0,0,C,W);const m=C/2,x=W/2,M=Math.min(C,W)/2-6;n.strokeStyle=g,n.lineWidth=1,n.globalAlpha=$?1:.9;for(const f of[.4,.7,1])n.beginPath(),n.arc(m,x,M*f,0,Math.PI*2),n.stroke();n.beginPath(),n.moveTo(m-M,x),n.lineTo(m+M,x),n.moveTo(m,x-M),n.lineTo(m,x+M),n.stroke(),n.globalAlpha=1;const I=(P&&!l?A%K/K:0)*Math.PI*2-Math.PI/2;if(P){const f=(q=n.createConicGradient)==null?void 0:q.call(n,I-.85,m,x);f&&(f.addColorStop(0,"transparent"),f.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${S} ${N}%, transparent)`),f.addColorStop(1,"transparent"),n.fillStyle=f,n.beginPath(),n.moveTo(m,x),n.arc(m,x,M,I-.85,I),n.closePath(),n.fill()),n.strokeStyle=S,n.globalAlpha=k,n.beginPath(),n.moveTo(m,x),n.lineTo(m+Math.cos(I)*M,x+Math.sin(I)*M),n.stroke(),n.globalAlpha=1}y.forEach((f,T)=>{const B=T/Math.max(y.length,1)*Math.PI*2-Math.PI/2,D=f.lastReadMs===null?1:Math.min(1,(A-f.lastReadMs)/12e4),O=M*(.42+D*.5),F=m+Math.cos(B)*O,L=x+Math.sin(B)*O,_=Math.abs((I-B+Math.PI*3)%(Math.PI*2)-Math.PI),U=P?Math.max(0,1-_/.55):0;n.beginPath(),n.arc(F,L,3+U*1.6,0,Math.PI*2),n.fillStyle=f.running?S:v,n.globalAlpha=f.running?.55+U*.45:.35,n.fill(),n.globalAlpha=1});for(const f of j){const T=(A-f.atMs)/we;if(T<0||T>1)continue;const D=Math.max(0,y.findIndex(L=>L.key===f.browser))/Math.max(y.length,1)*Math.PI*2-Math.PI/2,O=m+Math.cos(D)*M*.6,F=x+Math.sin(D)*M*.6;n.beginPath(),n.arc(O,F,4+T*22,0,Math.PI*2),n.strokeStyle=S,n.globalAlpha=(1-T)*.8,n.lineWidth=1.5,n.stroke(),n.globalAlpha=1}o=requestAnimationFrame(w)};return w(),()=>{i=!0,cancelAnimationFrame(o)}},[c]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":h?`Watching ${s.length} browser${s.length===1?"":"s"}`:"Not watching"})}function be({snap:s,watching:a,palette:h}){const[c,d]=r.useState(!1),[u,t]=r.useState(()=>Date.now());r.useEffect(()=>{const l=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(l)},[]);const n=Y(s.coverage.lastHumanMs,s.coverage.quietMs,u);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",e.jsx("button",{className:"bw-help",onClick:()=>d(l=>!l),"aria-expanded":c,"aria-label":"What the sweep and the dots mean",children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(me,{browsers:a.map(l=>{var o;return{key:l.key,name:l.name,running:l.running,lastReadMs:((o=s.profiles.find(i=>i.browser===l.key))==null?void 0:o.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(l=>({browser:l.browser??null,atMs:l.endMs})),watching:s.settings.enabled,palette:h}),e.jsx("ul",{className:"bw-counts",children:V(a,s.profiles).map(l=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:l.visits.toLocaleString("en-US")}),e.jsx("span",{className:"bw-count-of",children:l.name})]},l.key))})]}),e.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:["Last checked ",X(s.coverage.checkedMs,u),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",s.coverage.checks.toLocaleString("en-US")," ",s.coverage.checks===1?"check":"checks"]})]}),n!==null&&e.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",Z(n)]}),c&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Sweep"}),e.jsx("dd",{children:"one poll of every watched profile"}),e.jsx("dt",{children:"Dot"}),e.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),e.jsx("dt",{children:"Ring"}),e.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]})}function pe({watching:s,rest:a}){const[h,c]=r.useState(!1),[d,u]=r.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",e.jsx("button",{className:"bw-help",onClick:()=>c(t=>!t),"aria-expanded":h,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),h&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:"Running"}),e.jsx("dd",{children:"the browser has a process on this machine right now"}),e.jsx("dt",{children:"Connected"}),e.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(t=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${t.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:t.name}),e.jsx("span",{className:"bw-prof-state",children:t.running?"running":"idle"}),t.running&&t.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},t.key))}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>u(t=>!t),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",a.length," not watched"]}),d&&e.jsxs("p",{className:"bw-rest",children:[a.map(t=>t.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]})}function ge({snap:s,quiet:a,setQuiet:h,save:c,access:d,setAccess:u}){return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[e.jsx("span",{children:"Nobody browsing for"}),e.jsxs("select",{value:a??s.settings.quietMinutes,onChange:t=>{h(Number(t.target.value)),c({quietMinutes:Number(t.target.value)})},children:[e.jsx("option",{value:1,children:"1 min"}),e.jsx("option",{value:5,children:"5 min"}),e.jsx("option",{value:15,children:"15 min"}),e.jsx("option",{value:30,children:"30 min"}),e.jsx("option",{value:60,children:"60 min"})]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"When it finds one"}),e.jsx("select",{value:s.settings.reaction,onChange:t=>void c({reaction:t.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(s.reactions??["notify"]).map(t=>e.jsx("option",{value:t,children:t==="notify"?"notify me":t==="close-tab"?"close the tab":"quit the browser"},t))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",e.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),e.jsxs("button",{className:"bw-why",onClick:()=>u(t=>!t),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," What Browser Watch can access"]}),d&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:"Reads"}),e.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(s.coverage.startedMs).toLocaleString(),"."]}),e.jsx("dt",{children:"Keeps"}),e.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",e.jsx("code",{className:"bw-path",children:s.coverage.logPath}),typeof s.coverage.logBytes=="number"?` (${z(s.coverage.logBytes)})`:"",", with every address written in full so you can check it yourself."]}),e.jsx("dt",{children:"Sends"}),e.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),e.jsx("dt",{children:"Never reads"}),e.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]})}function H(s,a){return a?{kind:"saving",word:"Saving"}:s.settings.enabled?{kind:"on",word:"Watching"}:{kind:"off",word:"Paused"}}function fe({snap:s,saving:a,save:h,why:c,setWhy:d}){return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:H(s,a).word},H(s,a).kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${s.coverage.archived} ${s.coverage.archived===1?"episode":"episodes"} on disk`}),e.jsx("button",{className:`glyph-btn bw-gear${c?" on":""}`,onClick:()=>d(u=>!u),"aria-expanded":c,"aria-label":"Settings",title:"Settings",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void h({enabled:!s.settings.enabled}),title:s.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:e.jsx("span",{className:"switch-knob"})})]})]})}function xe({relay:s}){const[a,h]=r.useState(!1),[c,d]=r.useState(!1),u=s.killswitch.blocked?"unblock":"block",t=s.command[u],n=r.useCallback(async()=>{await ee(t.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[t.command]),l=s.profiles.filter(i=>{var w;return(w=i.report)==null?void 0:w.present}),o=s.profiles.filter(i=>i.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":s.verdict==="protected"?`The relay is black-holed in ${s.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",s.hostsPath,", and ccdeck will not touch it:",s.killswitch.foreign.map(i=>e.jsx("code",{className:"bw-path",children:i},i))]}),e.jsxs("button",{className:"bw-why",onClick:()=>h(i=>!i),"aria-expanded":a,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:a?"▾":"▸"})," ",s.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),a&&e.jsxs("div",{className:"bw-rc-body",children:[l.length>0&&e.jsx("dl",{className:"bw-key",children:l.map(i=>e.jsxs(r.Fragment,{children:[e.jsxs("dt",{children:[i.name,i.profile==="Default"?"":` · ${i.profile}`]}),e.jsxs("dd",{children:[i.report.enabled?"enabled":"installed but switched off",i.report.allUrls?", can act on every site":", limited to the sites it was granted",i.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",i.report.sensitiveApis.join(", ")]})]})]},`${i.browser}/${i.profile}`))}),o.length>0&&e.jsxs("p",{className:"bw-rc-note",children:[o.map(i=>i.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!s.hostsRead&&e.jsxs("p",{className:"bw-rc-note",children:[s.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),l.some(i=>i.report.allUrls)&&e.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",e.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:t.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:n,children:c?"Copied":"Copy"})]}),e.jsx("p",{className:"bw-rc-note",children:t.note})]})]})}function je(s){const[a,h]=r.useState(null),[c,d]=r.useState(null),[u,t]=r.useState(null),[n,l]=r.useState(!1),o=r.useRef(!1),[i,w]=r.useState(null),[b,p]=r.useState(!1),y=r.useRef(!1),j=r.useCallback(async g=>{var v,$;if(!(g&&!se(o.current))){g&&(o.current=!0,l(!0));try{const N=await fetch(`/api/browser-watch${g?"?refresh=1":""}`);if(!N.ok)throw new Error(`the deck answered ${N.status}`);const k=await N.json();h(k),y.current||w(((v=k==null?void 0:k.settings)==null?void 0:v.quietMinutes)??15),s((($=k==null?void 0:k.settings)==null?void 0:$.enabled)===!0),d(null)}catch(N){d(N instanceof Error?N.message:String(N))}finally{g&&(o.current=!1,l(!1))}}},[s]);r.useEffect(()=>{j(!1)},[j]),r.useEffect(()=>{const g=setInterval(()=>{j(!1)},1e4);return()=>clearInterval(g)},[j]);const P=r.useCallback(async g=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:g.host,startMs:g.startMs})})}finally{await j(!1)}},[j]),S=r.useCallback(async g=>{y.current=!0,p(!0);try{const v=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)});if(!v.ok)throw new Error(`the deck answered ${v.status}`);await j(!1),t(null)}catch(v){t(v instanceof Error?v.message:String(v))}finally{y.current=!1,p(!1)}},[j]);return{snap:a,error:c,writeError:u,setWriteError:t,busy:n,quiet:i,setQuiet:w,saving:b,load:j,dismiss:P,save:S}}function Ne({onClose:s,onSeen:a,onWatching:h,palette:c}){const d=te(s),u=ne(s),{snap:t,error:n,writeError:l,setWriteError:o,busy:i,quiet:w,setQuiet:b,saving:p,load:y,dismiss:j,save:P}=je(h),[S,g]=r.useState(!1),[v,$]=r.useState(!1),N=r.useRef(null),k=r.useRef(a);k.current=a,r.useEffect(()=>()=>k.current(Date.now()),[]);const A=ae(t==null?void 0:t.browsers),R=((t==null?void 0:t.browsers)??[]).filter(m=>!(m.installed&&m.profiles>0)),C=t?ie(t):null,W=A.reduce((m,x)=>m+x.profiles,0);return e.jsx("div",{className:"modal-backdrop",...u,role:"presentation",children:e.jsxs("div",{ref:d,className:"modal bw-modal",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),e.jsx("span",{className:"modal-tool-id",children:t?`${W} ${W===1?"profile":"profiles"} · local only`:"local only"})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:N,className:"glyph-btn",onClick:()=>void y(!0),...oe(i),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:i?"…":e.jsx(re,{})}),e.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!t&&!n&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),n&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not read"}),e.jsx("span",{className:"bw-row-detail",children:n})]})}),t&&C&&e.jsx("p",{className:`bw-trouble ${C.kind}`,role:"status",children:C.text}),t&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(be,{snap:t,watching:A,palette:c}),e.jsx(pe,{watching:A,rest:R}),t.relay&&e.jsx(xe,{relay:t.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(he,{snap:t,dismiss:j,refreshRef:N}),e.jsx(le,{snap:t})]})]}),t&&S&&e.jsx(ge,{snap:t,quiet:w,setQuiet:b,save:P,access:v,setAccess:$}),l&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),e.jsxs("span",{className:"bw-row-detail",children:[l," — the switches below show what is stored, not what you pressed."]}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>o(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),t&&e.jsx(fe,{snap:t,saving:p,save:P,why:S,setWhy:g})]})]})})}export{Ne as default};