fullcourtdefense-cli 1.21.5 → 1.21.7

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.
@@ -60,20 +60,23 @@ const discoverPaths_1 = require("./discoverPaths");
60
60
  * closes that blind spot with the SAME on-device deterministic engine used
61
61
  * everywhere else (scanDeterministicPrompt).
62
62
  *
63
- * Reading the composer — MSAA + forced renderer accessibility:
63
+ * Reading the composer — MSAA, passive best-effort:
64
64
  * Claude Desktop is Electron/Chromium. Chromium keeps web-content
65
65
  * accessibility OFF until it detects assistive tech, and on current Claude
66
- * builds NONE of the passive wake signals work from outside the process
66
+ * builds no passive wake signal turns it on from outside the process
67
67
  * (verified against Claude 1.20186: WM_GETOBJECT for OBJID_CLIENT and for the
68
68
  * custom screen-reader object id 1, SPI_SETSCREENREADER, a UIA FindAll walk,
69
69
  * and an NVDA-style IServiceProvider->IAccessible2 handshake all leave the
70
- * web area empty). Chromium documents exactly one reliable switch: launch the
71
- * app with --force-renderer-accessibility. So the guard ensures Claude runs
72
- * with that flag (a one-time, throttled relaunch when the flag is absent),
73
- * after which the composer text is exposed via MSAA: oleacc's
74
- * AccessibleObjectFromWindow on the main Chrome_WidgetWin_1 window, walk the
75
- * IAccessible tree, read accValue of the editable text node (ROLE_SYSTEM_TEXT
76
- * / 0x2A). Once the flag is present the guard never touches Claude again.
70
+ * web area empty). The only reliable switch is launching Claude with
71
+ * --force-renderer-accessibility but force-restarting the user's app is
72
+ * too disruptive for a fleet product, so we deliberately DON'T. The guard
73
+ * reads via MSAA (oleacc's AccessibleObjectFromWindow on the main
74
+ * Chrome_WidgetWin_1 window, accValue of ROLE_SYSTEM_TEXT / 0x2A nodes) and
75
+ * simply works when accessibility happens to be active (screen-reader users,
76
+ * older builds, or the app launched with the flag) and stays silent when not.
77
+ *
78
+ * The SUPPORTED protection surface for Claude Desktop is its MCP tool calls
79
+ * through the FCD gateway — that is where enforcement happens.
77
80
  *
78
81
  * Advisory ONLY: no keyboard hook, no input mutation, no keystroke capture. It
79
82
  * reads only the composer text of Claude Desktop's own window (scoped to the
@@ -89,13 +92,6 @@ const discoverPaths_1 = require("./discoverPaths");
89
92
  */
90
93
  const WATCHER_PS1_PATH = path.join(os.homedir(), '.fullcourtdefense-claude-desktop-watcher.ps1');
91
94
  const STATUS_PATH = path.join(os.homedir(), '.fullcourtdefense', 'claude-desktop-guard.json');
92
- /** Throttle marker for the one-time --force-renderer-accessibility relaunch. */
93
- const A11Y_RELAUNCH_MARKER = path.join(os.homedir(), '.fullcourtdefense', 'claude-a11y-relaunch.json');
94
- /** Never relaunch Claude more than once per this window (a paste-time restart
95
- * is disruptive; once the flag sticks it survives until Claude next updates). */
96
- const A11Y_RELAUNCH_THROTTLE_MS = 6 * 60 * 60_000;
97
- /** How often to re-check that Claude is still running with the a11y flag. */
98
- const A11Y_CHECK_INTERVAL_MS = 5 * 60_000;
99
95
  const STDOUT_PREFIX = 'FCD:';
100
96
  /** Poll cadence for the composer read (ms). 800ms lost the race against a
101
97
  * fast paste+Enter (the composer clears before the next read); 250ms is still
@@ -279,129 +275,6 @@ function ensureWatcherScript() {
279
275
  fs.writeFileSync(WATCHER_PS1_PATH, desktopChatWatcherScript(), { encoding: 'utf8' });
280
276
  return WATCHER_PS1_PATH;
281
277
  }
282
- function relaunchThrottleOk(currentClaudeCreated) {
283
- try {
284
- const marker = JSON.parse(fs.readFileSync(A11Y_RELAUNCH_MARKER, 'utf8'));
285
- const last = marker.lastAttemptAt || 0;
286
- // Claude was restarted (update, crash, user quit/reopen) since our last
287
- // relaunch attempt — the old throttle must not leave the composer blind.
288
- if (currentClaudeCreated && marker.claudeCreated && currentClaudeCreated !== marker.claudeCreated) {
289
- return true;
290
- }
291
- return Date.now() - last > A11Y_RELAUNCH_THROTTLE_MS;
292
- }
293
- catch {
294
- return true;
295
- }
296
- }
297
- function stampRelaunch(claudeCreated) {
298
- try {
299
- fs.mkdirSync(path.dirname(A11Y_RELAUNCH_MARKER), { recursive: true });
300
- fs.writeFileSync(A11Y_RELAUNCH_MARKER, JSON.stringify({
301
- lastAttemptAt: Date.now(),
302
- ...(claudeCreated ? { claudeCreated } : {}),
303
- }), { encoding: 'utf8', mode: 0o600 });
304
- }
305
- catch { /* best-effort */ }
306
- }
307
- /**
308
- * PowerShell that inspects the running Claude Desktop browser process and, when
309
- * allowed, relaunches it with --force-renderer-accessibility. Chromium exposes
310
- * web-content (the chat composer) to MSAA only when that switch is present, and
311
- * no external/passive signal turns it on for current Claude builds. Emits a
312
- * single `STATE:<...>` line so the caller can log/throttle honestly.
313
- *
314
- * STATE:not-running — nothing to do
315
- * STATE:has-flag — already accessible, no action
316
- * STATE:relaunched — was missing the flag; we restarted it with the flag
317
- * STATE:needs-flag — missing the flag but relaunch not allowed (throttled)
318
- * STATE:error:<msg>
319
- *
320
- * Only ever targets processes named exactly 'claude.exe' from their own install
321
- * root, and only restarts a process the user already had open.
322
- */
323
- function ensureAccessibilityScript(allowRelaunch) {
324
- return [
325
- "$ErrorActionPreference = 'SilentlyContinue'",
326
- "$procs = Get-CimInstance Win32_Process -Filter \"Name = 'claude.exe'\"",
327
- 'if (-not $procs) { Write-Output \'STATE:not-running\'; exit 0 }',
328
- // The browser (main) process is the claude.exe with no --type= child switch.
329
- "$main = $procs | Where-Object { $_.CommandLine -and ($_.CommandLine -notmatch '--type=') } | Select-Object -First 1",
330
- "if (-not $main) { Write-Output 'STATE:not-running'; exit 0 }",
331
- "$created = $main.CreationDate",
332
- "if ($main.CommandLine -match '--force-renderer-accessibility') { Write-Output ('STATE:has-flag:' + $created); exit 0 }",
333
- allowRelaunch ? '' : "Write-Output ('STATE:needs-flag:' + $created); exit 0",
334
- "$exe = $main.ExecutablePath",
335
- "if (-not $exe -or -not (Test-Path $exe)) { Write-Output 'STATE:error:no-exe'; exit 0 }",
336
- 'try {',
337
- " $procs | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }",
338
- ' Start-Sleep -Milliseconds 1500',
339
- " Start-Process -FilePath $exe -ArgumentList '--force-renderer-accessibility'",
340
- " Write-Output ('STATE:relaunched:' + $created)",
341
- "} catch { Write-Output ('STATE:error:' + $_.Exception.Message) }",
342
- ].filter(Boolean).join('\n');
343
- }
344
- function parseAccessibilityState(out) {
345
- const match = out.match(/STATE:([^:\r\n]+)(?::(.+))?/);
346
- if (!match)
347
- return { state: '' };
348
- return { state: match[1].trim(), claudeCreated: match[2]?.trim() };
349
- }
350
- /**
351
- * Ensure Claude Desktop is running with renderer accessibility so the composer
352
- * is readable. Non-blocking best-effort; throttled to at most one relaunch per
353
- * A11Y_RELAUNCH_THROTTLE_MS for the SAME Claude process instance. A fresh
354
- * Claude restart (update, MSI, user reopen) bypasses the throttle.
355
- */
356
- function ensureClaudeForceAccessibility(log) {
357
- if (process.platform !== 'win32')
358
- return;
359
- // Probe first without committing to relaunch so we can compare process age
360
- // against the throttle marker before deciding.
361
- const probe = (0, child_process_1.spawn)('powershell', [
362
- '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden',
363
- '-Command', ensureAccessibilityScript(false),
364
- ], { windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] });
365
- let probeOut = '';
366
- probe.stdout?.on('data', (d) => { probeOut += d.toString(); });
367
- probe.on('error', () => { });
368
- probe.on('exit', () => {
369
- const { state, claudeCreated } = parseAccessibilityState(probeOut);
370
- if (!state || state === 'not-running' || state.startsWith('has-flag'))
371
- return;
372
- if (!state.startsWith('needs-flag')) {
373
- if (state.startsWith('error'))
374
- log(`Claude Desktop guard: accessibility probe failed (${state}).`);
375
- return;
376
- }
377
- const allow = relaunchThrottleOk(claudeCreated);
378
- if (!allow) {
379
- log('Claude Desktop guard: Claude is running without accessibility; relaunch throttled — composer stays unreadable until the next allowed relaunch.');
380
- return;
381
- }
382
- const child = (0, child_process_1.spawn)('powershell', [
383
- '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden',
384
- '-Command', ensureAccessibilityScript(true),
385
- ], { windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] });
386
- let out = '';
387
- child.stdout?.on('data', (d) => { out += d.toString(); });
388
- child.on('error', () => { });
389
- child.on('exit', () => {
390
- const result = parseAccessibilityState(out);
391
- if (result.state === 'relaunched') {
392
- stampRelaunch(result.claudeCreated || claudeCreated);
393
- log('Claude Desktop guard: relaunched Claude with --force-renderer-accessibility so the chat composer is readable.');
394
- }
395
- else if (result.state.startsWith('error')) {
396
- // An error can surface AFTER we already force-stopped Claude (Start-Process
397
- // threw). Stamp the throttle regardless so a half-failed restart can never
398
- // loop the kill every 5 minutes — wait the full window before retrying.
399
- stampRelaunch(result.claudeCreated || claudeCreated);
400
- log(`Claude Desktop guard: could not enable accessibility (${result.state}); backing off before retry.`);
401
- }
402
- });
403
- });
404
- }
405
278
  /**
406
279
  * Start the advisory guard. Returns a handle whose stop() tears down the
407
280
  * watcher and timers. Safe no-op (returns undefined) on unsupported platforms.
@@ -526,10 +399,8 @@ function startDesktopChatGuard(runtime) {
526
399
  restartDelay = Math.min(RESTART_MAX_MS, restartDelay * 2);
527
400
  };
528
401
  void refreshSnapshot();
529
- ensureClaudeForceAccessibility(runtime.log);
530
402
  const snapshotTimer = setInterval(() => { void refreshSnapshot(); }, SNAPSHOT_REFRESH_MS);
531
403
  const heartbeatTimer = setInterval(heartbeat, 60_000);
532
- const a11yTimer = setInterval(() => ensureClaudeForceAccessibility(runtime.log), A11Y_CHECK_INTERVAL_MS);
533
404
  spawnWatcher();
534
405
  return {
535
406
  stop() {
@@ -538,7 +409,6 @@ function startDesktopChatGuard(runtime) {
538
409
  stopped = true;
539
410
  clearInterval(snapshotTimer);
540
411
  clearInterval(heartbeatTimer);
541
- clearInterval(a11yTimer);
542
412
  if (restartTimer) {
543
413
  clearTimeout(restartTimer);
544
414
  restartTimer = undefined;
package/dist/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.21.5"
2
+ "version": "1.21.7"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullcourtdefense-cli",
3
- "version": "1.21.5",
3
+ "version": "1.21.7",
4
4
  "description": "Full Court Defense CLI — security scanning for AI agents from your terminal",
5
5
  "main": "dist/index.js",
6
6
  "bin": {