claude-rpc 1.3.1 → 1.4.1

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/README.md CHANGED
@@ -72,7 +72,7 @@ claude-rpc setup
72
72
 
73
73
  That's the whole pitch.
74
74
 
75
- > `setup` registers a Windows startup entry and wires hooks into Claude Code's `settings.json`, and the daemon reports anonymous totals by default. All of it is reversible (`claude-rpc uninstall`, `community off`) and fully documented in [`SECURITY.md`](SECURITY.md) — read it first if you want to know exactly what runs.
75
+ > `setup` registers a Windows startup entry and wires hooks into Claude Code's `settings.json`, and the daemon reports anonymous totals by default. It ends with one optional y/N — *connect GitHub?* — which publishes a verified public [leaderboard](https://claude-rpc.com/leaderboard) profile only if you say yes (asked once; Enter skips). All of it is reversible (`claude-rpc uninstall`, `community off`, `profile off`) and fully documented in [`SECURITY.md`](SECURITY.md) — read it first if you want to know exactly what runs.
76
76
 
77
77
  The Discord *desktop* app must be running. The browser client doesn't expose the local IPC bridge that Rich Presence uses.
78
78
 
package/SECURITY.md CHANGED
@@ -208,6 +208,16 @@ anonymous 3a report, this one carries your chosen public identity. The
208
208
  It sends absolute totals (not deltas) and is idempotent worker-side (a SET, not
209
209
  an add). `profile off` stops it.
210
210
 
211
+ **The setup-time "connect GitHub?" question.** Since v1.4, an interactive
212
+ `claude-rpc setup` ends with one explicit y/N: *connect GitHub?* Answering
213
+ **y** runs the standard opt-in flow above (public profile, handle defaulting
214
+ to your GitHub login, gist verification) — nothing beyond that flow's
215
+ documented payload. Answering **n** (or Enter, the default) sends nothing and
216
+ stores only a local `ghConnectAsked` marker so setup never asks again;
217
+ non-interactive setups are never asked. There is no private identity tier:
218
+ the only way claude-rpc ever learns a GitHub identity is this same public,
219
+ consented profile flow.
220
+
211
221
  **Claude Wrapped (opt-in one-shot, never automatic).** `claude-rpc wrapped
212
222
  --publish` publishes a year-in-review blob under your profile handle to
213
223
  `<endpoint>/wrapped`, rendered at `claude-rpc.com/wrapped/<handle>`. It never
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-rpc",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Discord Rich Presence for Claude Code — live model, project, tokens, and lifetime stats driven by Claude Code's hook system.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.js CHANGED
@@ -2001,28 +2001,26 @@ async function profilePublish() {
2001
2001
  }
2002
2002
  }
2003
2003
 
2004
- // GitHub verification: ask the worker for a one-time token, publish it in a
2005
- // public gist (reusing the gist helper), then have the worker confirm it.
2006
- async function profileVerify() {
2007
- const cfg = loadConfig();
2004
+ // The gist-verification dance shared by `profile verify` and setup's optional
2005
+ // GitHub-connect question: worker token → public proof gist → worker check →
2006
+ // persist the verified identity locally. Prints its own progress lines (they
2007
+ // read the same in both contexts) and returns { ok, who } on success. It never
2008
+ // exits: hard failures come back as { ok: false, fatal: {label, hint, code} }
2009
+ // so profileVerify can fail() loudly while setup — where the whole step is
2010
+ // optional — shrugs and finishes the install.
2011
+ async function gistVerifyDance(cfg) {
2008
2012
  const profile = cfg.profile || {};
2009
2013
  const community = cfg.community || {};
2010
- // No --github required up front: the worker treats it as a hint only and
2011
- // takes the authoritative identity from whoever owns the proof gist —
2012
- // and publishing that gist already requires gh auth, so the account is
2013
- // known by the time it matters.
2014
- if (!profile.githubUser) {
2015
- console.log(` ${c.dim}no --github set — your verified identity will be the account that owns the proof gist${c.reset}`);
2016
- }
2017
2014
  if (!community.instanceId) {
2018
- return fail('enable the profile first', { hint: 'claude-rpc profile on', code: EX_BAD_STATE });
2015
+ return { ok: false, fatal: { label: 'enable the profile first', hint: 'claude-rpc profile on', code: EX_BAD_STATE } };
2019
2016
  }
2020
2017
  const endpoint = (community.endpoint || '').replace(/\/+$/, '');
2021
2018
  if (!endpoint) {
2022
- return fail('no community endpoint configured', {
2019
+ return { ok: false, fatal: {
2020
+ label: 'no community endpoint configured',
2023
2021
  hint: 'config.json is missing community.endpoint — re-run `claude-rpc setup` to restore the default',
2024
2022
  code: EX_BAD_STATE,
2025
- });
2023
+ } };
2026
2024
  }
2027
2025
 
2028
2026
  const post = async (path, body) => {
@@ -2043,7 +2041,9 @@ async function profileVerify() {
2043
2041
  }
2044
2042
  console.log(` ${c.dim}requesting a verification token…${c.reset}`);
2045
2043
  const start = await post('/verify/start', { instanceId: community.instanceId, githubUser: profile.githubUser || null });
2046
- if (!start.json?.token) return fail(`verify/start failed: ${start.json?.error || start.status}`, { code: EX_SYS_ERROR });
2044
+ if (!start.json?.token) {
2045
+ return { ok: false, fatal: { label: `verify/start failed: ${start.json?.error || start.status}`, code: EX_SYS_ERROR } };
2046
+ }
2047
2047
  const token = start.json.token;
2048
2048
 
2049
2049
  const { publishGistFile } = await import('./gist.js');
@@ -2071,14 +2071,100 @@ async function profileVerify() {
2071
2071
  if (who && profile.githubUser && who.toLowerCase() !== profile.githubUser.toLowerCase()) {
2072
2072
  console.log(` ${c.dim}(your gist is owned by @${who}, so the profile now uses that account)${c.reset}`);
2073
2073
  }
2074
- } else {
2075
- console.log(` ${c.yellow}!${c.reset} not confirmed: ${check.json?.error || check.status}`);
2076
- console.log(` ${c.dim}↳ make sure the gist is public, then re-run ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
2074
+ return { ok: true, who };
2077
2075
  }
2076
+ // Soft outcome (matches historical behavior): the message tells the user
2077
+ // how to finish, and the process still exits 0.
2078
+ console.log(` ${c.yellow}!${c.reset} not confirmed: ${check.json?.error || check.status}`);
2079
+ console.log(` ${c.dim}↳ make sure the gist is public, then re-run ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
2080
+ return { ok: false };
2078
2081
  } catch (e) {
2079
- return fail(`verification failed: ${e.message}`, {
2082
+ return { ok: false, fatal: {
2083
+ label: `verification failed: ${e.message}`,
2080
2084
  hint: 'needs `gh` logged in or GH_TOKEN with gist scope', code: EX_SYS_ERROR,
2081
- });
2085
+ } };
2086
+ }
2087
+ }
2088
+
2089
+ // GitHub verification: ask the worker for a one-time token, publish it in a
2090
+ // public gist (reusing the gist helper), then have the worker confirm it.
2091
+ async function profileVerify() {
2092
+ const cfg = loadConfig();
2093
+ // No --github required up front: the worker treats it as a hint only and
2094
+ // takes the authoritative identity from whoever owns the proof gist —
2095
+ // and publishing that gist already requires gh auth, so the account is
2096
+ // known by the time it matters.
2097
+ if (!cfg.profile?.githubUser) {
2098
+ console.log(` ${c.dim}no --github set — your verified identity will be the account that owns the proof gist${c.reset}`);
2099
+ }
2100
+ const r = await gistVerifyDance(cfg);
2101
+ if (r.fatal) return fail(r.fatal.label, { hint: r.fatal.hint || '', code: r.fatal.code });
2102
+ }
2103
+
2104
+ // ── Setup-time GitHub connect ────────────────────────────────────────────
2105
+ // One explicit y/N at the end of `setup`, asked at most once ever (the answer
2106
+ // is remembered either way, and `claude-rpc link` / `profile verify` stay
2107
+ // available whenever). Saying y publishes a verified PUBLIC profile — handle
2108
+ // defaulting to the GitHub login — because that is the only "connected" state
2109
+ // the worker has: there is deliberately no silent or private identity tier
2110
+ // (SECURITY.md documents this). Declining changes nothing.
2111
+ async function setupGhConnect() {
2112
+ const cfg = loadConfig();
2113
+ if (cfg.profile?.verified) return; // already connected
2114
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return; // piped/CI setup — never block on a prompt
2115
+ if (!cfg.community?.instanceId) return; // no identity minted (dev tree) — nothing to verify
2116
+ if (readJson(CONFIG_PATH, {}).profile?.ghConnectAsked) return;
2117
+
2118
+ console.log('');
2119
+ console.log(` ${c.bold}connect GitHub?${c.reset} ${c.dim}optional — asked once, everything works without it${c.reset}`);
2120
+ console.log(` ${c.green}·${c.reset} verifies this install as your GitHub account ${c.dim}(public proof gist via the ${c.reset}gh${c.dim} CLI)${c.reset}`);
2121
+ console.log(` ${c.green}·${c.reset} publishes a ${c.bold}public${c.reset} profile at ${c.cyan}claude-rpc.com/u/<your-login>${c.reset} with the verified ✓`);
2122
+ console.log(` ${c.dim}totals only — tokens · sessions · hours · streak; never prompts, paths, or project names${c.reset}`);
2123
+ const answer = (await prompt(` connect? ${c.dim}[y/N]${c.reset} `)).trim();
2124
+
2125
+ // Remember that we asked before acting on the answer — setup never nags.
2126
+ const userCfg = readJson(CONFIG_PATH, {});
2127
+ userCfg.profile = { ...(userCfg.profile || {}), ghConnectAsked: true };
2128
+ writeUserConfig(userCfg);
2129
+
2130
+ if (!/^y(es)?$/i.test(answer)) {
2131
+ console.log(` ${c.dim}skipped — connect later with ${c.reset}${c.cyan}claude-rpc link${c.reset}${c.dim} or ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
2132
+ return;
2133
+ }
2134
+
2135
+ const { ghLogin } = await import('./gist.js');
2136
+ const login = lb.normalizeGithubUser(ghLogin());
2137
+ if (!login) {
2138
+ console.log(` ${c.yellow}!${c.reset} no logged-in ${c.cyan}gh${c.reset} CLI found — two ways to finish:`);
2139
+ console.log(` ${c.dim}browser: log in at${c.reset} ${c.cyan}${LINK_PAGE}${c.reset} ${c.dim}and paste the${c.reset} ${c.cyan}claude-rpc link <code>${c.reset} ${c.dim}it shows${c.reset}`);
2140
+ console.log(` ${c.dim}terminal:${c.reset} ${c.cyan}gh auth login${c.reset} ${c.dim}then${c.reset} ${c.cyan}claude-rpc profile verify${c.reset}`);
2141
+ return;
2142
+ }
2143
+
2144
+ // Seed the local profile: handle defaults to the GitHub login (renameable
2145
+ // any time with `profile set --handle`), publishing on so the daemon keeps
2146
+ // the board row fresh from here out.
2147
+ const handle = lb.isValidHandle(userCfg.profile?.handle) ? userCfg.profile.handle : lb.normalizeHandle(login);
2148
+ if (!handle) {
2149
+ console.log(` ${c.yellow}!${c.reset} couldn't derive a handle from @${login} — run ${c.cyan}claude-rpc profile set --handle <you>${c.reset} then ${c.cyan}claude-rpc profile verify${c.reset}`);
2150
+ return;
2151
+ }
2152
+ userCfg.profile = { ...userCfg.profile, handle, githubUser: login, enabled: true };
2153
+ writeUserConfig(userCfg);
2154
+ console.log(` ${c.dim}connecting as ${c.reset}${c.cyan}@${login}${c.reset}${c.dim} — handle ${c.reset}${c.cyan}${handle}${c.reset}`);
2155
+
2156
+ // A fresh install has no aggregate yet; publish real totals, not zeros.
2157
+ if (!readAggregate()?.sessions) {
2158
+ console.log(` ${c.dim}first scan — counting your history…${c.reset}`);
2159
+ doScan(false);
2160
+ }
2161
+
2162
+ const r = await gistVerifyDance(loadConfig());
2163
+ if (r.ok) {
2164
+ console.log(` ${c.green}✓${c.reset} you're live at ${c.cyan}https://claude-rpc.com/u/${encodeURIComponent(handle)}${c.reset}`);
2165
+ } else {
2166
+ if (r.fatal) console.log(` ${c.yellow}!${c.reset} ${r.fatal.label}`);
2167
+ console.log(` ${c.dim}↳ setup itself is done — retry with ${c.reset}${c.cyan}claude-rpc profile verify${c.reset}`);
2082
2168
  }
2083
2169
  }
2084
2170
 
@@ -2452,6 +2538,9 @@ process.on('unhandledRejection', (e) => {
2452
2538
  } else if (argv.includes('--wrapped')) {
2453
2539
  console.log(` ${c.yellow}!${c.reset} --wrapped needs a profile — pair it with --link <code>, or run \`claude-rpc wrapped --publish\` after setup`);
2454
2540
  }
2541
+ // Optional GitHub connect — one explicit y/N, asked at most once ever.
2542
+ // The --link path above IS a connect, so it never double-asks.
2543
+ if (!linkCode) await setupGhConnect();
2455
2544
  }
2456
2545
  setupOutro(target, changed);
2457
2546
  break;
package/src/daemon.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import './safe-stdio.js';
3
3
  import { existsSync, unlinkSync, watch, appendFileSync, mkdirSync, statSync, renameSync, readdirSync } from 'node:fs';
4
4
  import { basename, dirname, join } from 'node:path';
5
- import { Client } from './discord-ipc.js';
5
+ import { Client, isBridgeUser } from './discord-ipc.js';
6
6
  import { readState, sweepStaleStateTmp, listSessionStates, sweepStaleSessionStates } from './state.js';
7
7
  import { makeRotationCursor, pickFrames, selectFrame, resolveLargeImageKey, shouldShowGithubButton, pickActiveSession, throttleDecision } from './presence.js';
8
8
  import { buildVars, fillTemplate, framePasses, applyIdle, applyShipped, applyTrigger } from './format.js';
@@ -110,6 +110,11 @@ let claudeProcAlive = null;
110
110
  let client = null;
111
111
  let connected = false;
112
112
  let connecting = false; // login() in flight — see the watchdog note in connect()
113
+ // True when the READY handshake identified an arRPC-style bridge (Vesktop/
114
+ // Equibop/web client) rather than the real Discord desktop client — see
115
+ // isBridgeUser in discord-ipc.js. Bridges never replay the current activity
116
+ // after their web client blips, so the keepalive below runs tighter there.
117
+ let bridgeClient = false;
113
118
  // ── Outbound presence throttle ──────────────────────────────────────────────
114
119
  // Discord rate-limits SET_ACTIVITY hard (~5 writes per 20s); a burst past it
115
120
  // makes the client blank the presence until the writes stop — the actual
@@ -491,6 +496,25 @@ function maxActivityWrites() {
491
496
  return Math.max(2, config.maxActivityWrites || 4);
492
497
  }
493
498
 
499
+ // Presence keepalive — after this much wire silence, re-send the current frame
500
+ // even though it hasn't changed. The real Discord client holds an activity
501
+ // until told otherwise, so 60s there is pure insurance; arRPC-style bridges
502
+ // lose the activity whenever their web client blips and never replay it, so
503
+ // the interval tightens once the handshake identifies one (issue #37 — card
504
+ // gone on Vesktop while every write is acked). config.presenceKeepaliveSec
505
+ // overrides (floored at 15s); 0/false disables. Costs one SET_ACTIVITY per
506
+ // interval at most — far under the 4-per-20s window cap.
507
+ const KEEPALIVE_DESKTOP_SEC = 60;
508
+ const KEEPALIVE_BRIDGE_SEC = 20;
509
+ function presenceKeepaliveMs() {
510
+ const v = config.presenceKeepaliveSec;
511
+ if (v === 0 || v === false) return 0;
512
+ const sec = typeof v === 'number' && v > 0
513
+ ? Math.max(15, v)
514
+ : (bridgeClient ? KEEPALIVE_BRIDGE_SEC : KEEPALIVE_DESKTOP_SEC);
515
+ return sec * 1000;
516
+ }
517
+
494
518
  // Sentinel for a clear — can never collide with a real activity hash, since
495
519
  // JSON.stringify of an activity object always begins with '{'.
496
520
  const CLEAR_HASH = 'cleared';
@@ -500,12 +524,18 @@ const CLEAR_HASH = 'cleared';
500
524
  // timer; 'skip' means the wire already shows this exact frame.
501
525
  function transmit(kind, activity, logMsg) {
502
526
  const hash = kind === 'clear' ? CLEAR_HASH : JSON.stringify(activity);
527
+ // Keepalive only re-asserts a VISIBLE frame — re-writing an already-cleared
528
+ // presence would burn rate-limited writes on a no-op, all night, every night.
529
+ const keepaliveMs = kind === 'clear' ? 0 : presenceKeepaliveMs();
530
+ const reassert = hash === lastSentHash; // only possible via keepalive expiry
503
531
  const d = throttleDecision({
504
532
  hash, lastSentHash, lastSentAt,
505
533
  now: Date.now(), gapMs: activityGapMs(), flushPending: !!flushTimer,
506
534
  recentSends, windowMs: activityWindowMs(), maxPerWindow: maxActivityWrites(),
535
+ keepaliveMs,
507
536
  });
508
537
  if (d.action === 'skip') { pendingSend = null; return; }
538
+ if (reassert) logMsg = `${logMsg} · keepalive re-assert`;
509
539
  if (d.action === 'send') { doSend({ kind, activity, hash, logMsg }); return; }
510
540
  // defer — remember the LATEST payload and flush it once when the gap expires.
511
541
  pendingSend = { kind, activity, hash, logMsg };
@@ -593,7 +623,15 @@ async function connect() {
593
623
  connected = true;
594
624
  // Reset backoff so the next outage also starts at RECONNECT_BASE_MS.
595
625
  reconnectDelayMs = RECONNECT_BASE_MS;
596
- log('Discord RPC connected as', client.user?.username);
626
+ bridgeClient = isBridgeUser(client.user);
627
+ if (bridgeClient) {
628
+ // Doctor greps this line: "connected as" feeds ipcStateFromLog, "arrpc"
629
+ // feeds bridgeFromLog — keep both tokens if rewording.
630
+ log(`Discord RPC connected as ${client.user?.username} — arRPC-style bridge (Vesktop/Equibop/web client). ` +
631
+ `Bridges don't replay presence after their web client reconnects; keepalive re-asserts every ${Math.round(presenceKeepaliveMs() / 1000)}s.`);
632
+ } else {
633
+ log('Discord RPC connected as', client.user?.username);
634
+ }
597
635
  resetTransmit();
598
636
  pushPresence();
599
637
  });
@@ -39,6 +39,16 @@ export const DEFAULT_CONFIG = {
39
39
  // headroom under Discord's ~5-per-20s ceiling.
40
40
  maxActivityWrites: 4,
41
41
  activityWindowMs: 20000,
42
+ // Presence keepalive (seconds). A frame that hasn't changed is normally
43
+ // never re-sent — correct against Discord desktop, which holds an activity
44
+ // until told otherwise. arRPC-style bridges (Vesktop/Equibop/web clients)
45
+ // instead LOSE the activity whenever their renderer blips (background
46
+ // throttling of an unfocused window, a reload) and never replay it, leaving
47
+ // the card blank while the daemon's writes are still acked. After this much
48
+ // write silence the daemon re-asserts the current frame. null = auto: 60s
49
+ // against Discord desktop, 20s when the handshake identifies a bridge.
50
+ // Floored at 15; set 0 to disable.
51
+ presenceKeepaliveSec: null,
42
52
  rescanIntervalSec: 300,
43
53
  idleThresholdSec: 60,
44
54
  // Time (minutes) of no hook activity AND no live transcripts on disk before
@@ -73,6 +73,21 @@ export function candidatePaths(platform = process.platform) {
73
73
  return out;
74
74
  }
75
75
 
76
+ // arRPC — the open-source RPC bridge that Vesktop/Equibop bundle and web-client
77
+ // setups run standalone — answers the handshake READY with a mock user instead
78
+ // of the real account: id 1045800378228281345, username "arrpc". Detecting it
79
+ // matters because bridges do NOT replay the current activity when their web
80
+ // client reconnects (arRPC keeps no last-activity state), so presence silently
81
+ // vanishes on any renderer blip — background throttling of an unfocused window,
82
+ // a reload — until the daemon happens to write a *different* frame. The daemon
83
+ // tightens its keepalive re-assert when this returns true.
84
+ export const ARRPC_USER_ID = '1045800378228281345';
85
+ export function isBridgeUser(user) {
86
+ if (!user) return false;
87
+ if (String(user.id || '') === ARRPC_USER_ID) return true;
88
+ return /^arrpc$/i.test(String(user.username || ''));
89
+ }
90
+
76
91
  // Encode one IPC frame: 8-byte little-endian header + JSON body.
77
92
  export function encodeFrame(op, data) {
78
93
  const body = data === undefined ? Buffer.alloc(0) : Buffer.from(JSON.stringify(data));
package/src/doctor.js CHANGED
@@ -134,6 +134,21 @@ export function ipcStateFromLog(logText) {
134
134
  return ipc;
135
135
  }
136
136
 
137
+ // Which client answered the RPC handshake, from the most recent "connected as"
138
+ // line: 'arrpc' for an arRPC-style bridge (Vesktop/Equibop/web client — the
139
+ // bridge's mock user is literally named arrpc), 'discord' for the real desktop
140
+ // client, null when the log has no connect line. Most-recent-wins, like
141
+ // ipcStateFromLog — a user who switches from Vesktop to stock Discord mid-run
142
+ // should not keep the bridge caveat.
143
+ export function bridgeFromLog(logText) {
144
+ let kind = null;
145
+ for (const line of String(logText || '').split('\n').slice(-200)) {
146
+ const m = line.match(/Discord RPC connected as\s+(\S+)/i);
147
+ if (m) kind = /arrpc/i.test(m[1]) ? 'arrpc' : 'discord';
148
+ }
149
+ return kind;
150
+ }
151
+
137
152
  function checkConfig() {
138
153
  if (!existsSync(CONFIG_PATH)) {
139
154
  check('config.json present', 'fail', CONFIG_PATH,
@@ -310,11 +325,25 @@ function checkDaemonLog() {
310
325
  // Ns" / "login failed" / "disconnected" line means it dropped. Whichever
311
326
  // happened most recently wins.
312
327
  let ipc = 'unknown';
313
- try { ipc = ipcStateFromLog(readFileSync(LOG_PATH, 'utf8')); }
314
- catch { /* log unreadable — ipc stays 'unknown', warn renders */ }
328
+ let bridge = null;
329
+ try {
330
+ const logText = readFileSync(LOG_PATH, 'utf8');
331
+ ipc = ipcStateFromLog(logText);
332
+ bridge = bridgeFromLog(logText);
333
+ } catch { /* log unreadable — ipc stays 'unknown', warn renders */ }
315
334
  if (ipc === 'up') {
316
335
  check('discord IPC connection', 'pass',
317
336
  `connected · ${sizeKB} KB log · last write ${ageMin.toFixed(1)} min ago`);
337
+ if (bridge === 'arrpc') {
338
+ // The single most-reported "presence vanished but doctor is green" cause:
339
+ // an arRPC bridge acks every write on the socket, but loses the activity
340
+ // whenever its web client blips (unfocused window throttled, reload) and
341
+ // never replays it. The daemon's keepalive re-asserts within ~20s of the
342
+ // client being able to display again — but while the renderer is down,
343
+ // nothing any RPC app writes will show.
344
+ check('discord client', 'info', 'arRPC bridge (Vesktop/Equibop/web) — not Discord desktop',
345
+ 'bridges drop presence while their window is unfocused/reloading; the daemon re-asserts it every ~20s. if the card stays gone, focus the client window — or use Discord desktop');
346
+ }
318
347
  } else if (ipc === 'down') {
319
348
  check('discord IPC connection', 'warn', 'daemon is reconnecting to Discord',
320
349
  'is the discord desktop client running? rpc only works via desktop, not browser', 'discord');
package/src/gist.js CHANGED
@@ -73,6 +73,16 @@ export function hasGh() {
73
73
  }
74
74
  }
75
75
 
76
+ // The login of the account `gh` is authed as, or null when gh is missing or
77
+ // logged out. `gh api user` needs auth, so a non-zero status covers both.
78
+ export function ghLogin() {
79
+ try {
80
+ const r = gh(['api', 'user', '--jq', '.login'], { encoding: 'utf8' });
81
+ if (r.status === 0) return (r.stdout || '').trim() || null;
82
+ } catch { /* same "not available" signals as hasGh */ }
83
+ return null;
84
+ }
85
+
76
86
  function ghCreate(filePath, description, isPublic) {
77
87
  const args = ['gist', 'create', filePath, '--desc', description];
78
88
  if (isPublic) args.push('--public');
package/src/presence.js CHANGED
@@ -130,8 +130,21 @@ export function shouldShowGithubButton(p, state) {
130
130
  // in the window expires, guaranteeing no more than `maxPerWindow` writes in any
131
131
  // `windowMs` no matter how many triggers fire. Omitting them keeps the old
132
132
  // gap-only behavior (used by tests that predate the cap).
133
- export function throttleDecision({ hash, lastSentHash, lastSentAt, now, gapMs, flushPending, recentSends, windowMs, maxPerWindow }) {
134
- if (hash === lastSentHash) return { action: 'skip', waitMs: 0 };
133
+ //
134
+ // `keepaliveMs` (optional) re-opens the identical-hash skip after that much
135
+ // wire silence. Against the real Discord client an unchanged frame never needs
136
+ // re-sending — the client holds an activity until told otherwise — but arRPC-
137
+ // style bridges (Vesktop/Equibop/web) lose the activity whenever their web
138
+ // client blips and never replay it (arRPC keeps no last-activity state), so a
139
+ // quiet single-frame status would stay invisible forever while every doctor
140
+ // check reads green (#37). Once `now - lastSentAt >= keepaliveMs` the frame is
141
+ // treated as changed and flows through the same gap/window limiting as any
142
+ // other write. Omitted/0 keeps the pure skip.
143
+ export function throttleDecision({ hash, lastSentHash, lastSentAt, now, gapMs, flushPending, recentSends, windowMs, maxPerWindow, keepaliveMs }) {
144
+ if (hash === lastSentHash) {
145
+ const due = keepaliveMs > 0 && lastSentAt > 0 && now - lastSentAt >= keepaliveMs;
146
+ if (!due) return { action: 'skip', waitMs: 0 };
147
+ }
135
148
  let waitMs = Math.max(0, (lastSentAt || 0) + gapMs - now);
136
149
  if (maxPerWindow && windowMs && Array.isArray(recentSends)) {
137
150
  // Strict window (age < windowMs) so a write exactly windowMs old has already
package/src/version.js CHANGED
@@ -11,7 +11,7 @@ import { readFileSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
12
  import { ROOT } from './paths.js';
13
13
 
14
- const BAKED = '1.3.1';
14
+ const BAKED = '1.4.1';
15
15
 
16
16
  function readPkgVersion() {
17
17
  try {