superbased 1.6.1 → 1.6.3

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.
@@ -1,41 +1,31 @@
1
- # SuperBased — AI Screenshot Tool for Developers
2
-
3
- SuperBased is a desktop screenshot + AI tool. You can control it via MCP tools to capture screenshots, view them inline, run AI analysis, extract text, redact secrets, dictate (file or live mic), record sessions, run visual regression tests, and compress text — all programmatically from your coding environment.
4
-
5
- ## Setup
6
-
7
- ### 1. Make sure SuperBased is running
8
- The desktop app or headless server must be running. It starts an HTTP API on `http://127.0.0.1:47592` automatically.
9
-
10
- **Desktop**: Launch the app.
11
- **Headless (CLI)**: Run `superbased mcp` — this starts the API server + MCP stdio bridge in one process. Your MCP config only needs:
12
- ```json
13
- {
14
- "mcpServers": {
15
- "superbased": {
16
- "command": "superbased",
17
- "args": ["mcp"]
18
- }
19
- }
20
- }
21
- ```
22
-
23
- ### 2. Add MCP server (alternative: node path)
24
- If `superbased` isn't on PATH, use the full node path:
25
- ```json
26
- {
27
- "mcpServers": {
28
- "superbased": {
29
- "command": "node",
30
- "args": ["/path/to/superbased/mcp-server/dist/index.js"]
31
- }
32
- }
33
- }
34
- ```
35
- Check `~/.superbased/mcp.json` for the correct path after starting SuperBased. Restart your editor after creating the file.
36
-
37
- ### 3. Verify connection
38
- Ask: "Check the SuperBased health status" — the agent should call `superbased_health` and show version, uptime, and features.
1
+ # SuperBased — Screen Capture & AI Tools via MCP
2
+
3
+ SuperBased gives you eyes on the user's screen. Use it to see what's visible, capture screenshots, analyze UI, extract text, record sessions, monitor for errors, and more — all via MCP tools.
4
+
5
+ ## When to Use SuperBased
6
+
7
+ **You SHOULD use SuperBased tools when:**
8
+ - You need to **see what's on the user's screen** → `superbased_capture_image`
9
+ - You need to **list open windows** or find a specific app → `superbased_window_list`
10
+ - You need to **capture a specific window** (even if minimized) → `superbased_capture_image` with `window` param
11
+ - You need to **read text from the screen** → `superbased_ocr` or `superbased_ai` with `/extract`
12
+ - You need to **check what the user is looking at** → `superbased_capture_image` with `resolution=half`
13
+ - You need to **verify a UI change** after code edits → `superbased_capture_image`
14
+ - You need to **record the screen** over time → `superbased_recording` with `mode=smart`
15
+ - You need to **watch the screen for errors** → `superbased_recording` with `mode=monitor`
16
+ - You need to **see an image the user copied** → `superbased_clipboard` with `action=readImage`
17
+ - You need to **dictate or listen to the user** → `superbased_dictate` with `mic=true`
18
+
19
+ **Quick decision guide:**
20
+ | I need to... | Use this tool |
21
+ |---|---|
22
+ | See the screen | `superbased_capture_image` |
23
+ | List windows | `superbased_window_list` |
24
+ | Read text from screen | `superbased_ai instruction="/extract"` |
25
+ | Record screen changes | `superbased_recording action=start mode=smart` |
26
+ | Monitor for errors | `superbased_recording action=start mode=monitor` |
27
+ | See clipboard image | `superbased_clipboard action=readImage` |
28
+ | Listen via mic | `superbased_dictate mic=true` |
39
29
 
40
30
  ---
41
31
 
@@ -641,9 +641,21 @@ function registerRecordingRoutesOnServer() {
641
641
  targetProcessName: body.targetProcessName,
642
642
  targetWindowTitle: body.targetWindowTitle,
643
643
  showInGallery: body.showInGallery !== false,
644
+ mode: body.mode,
645
+ interval: body.interval,
646
+ changeThreshold: body.changeThreshold,
644
647
  };
648
+ // Monitor mode settings
649
+ if (body.mode === 'monitor') {
650
+ options.monitor = {
651
+ analysisPrompt: body.analysisPrompt || 'Describe what changed on screen. Flag any errors, warnings, unexpected states, or UI issues.',
652
+ analyzeEvery: body.analyzeEvery ?? 5,
653
+ analyzeInterval: body.analyzeInterval ?? 30,
654
+ analysisDetail: body.analysisDetail || 'low',
655
+ };
656
+ }
645
657
  const session = await startSession(options);
646
- return reply.code(200).send({ sessionId: session.id, status: 'recording' });
658
+ return reply.code(200).send({ sessionId: session.id, status: 'recording', mode: session.mode });
647
659
  }
648
660
  catch (err) {
649
661
  return reply.code(400).send({ error: err instanceof Error ? err.message : String(err) });
@@ -698,6 +710,7 @@ function registerRecordingRoutesOnServer() {
698
710
  sessionId: session.id,
699
711
  frameCount: session.frameCount,
700
712
  duration: Date.now() - session.startedAt,
713
+ mode: session.mode,
701
714
  });
702
715
  });
703
716
  // POST /api/recording/capture
@@ -709,6 +722,87 @@ function registerRecordingRoutesOnServer() {
709
722
  triggerManualCapture();
710
723
  return reply.code(200).send({ success: true, message: 'Manual capture triggered' });
711
724
  });
725
+ // GET /api/recording/analysis — get AI analysis results for a session
726
+ s.get('/api/recording/analysis', async (request, reply) => {
727
+ try {
728
+ const query = request.query;
729
+ if (!query.sessionId) {
730
+ return reply.code(400).send({ error: 'sessionId query param required' });
731
+ }
732
+ const { getDatabase } = await Promise.resolve().then(() => __importStar(require('../db/database')));
733
+ const db = getDatabase();
734
+ const sinceFrame = query.since ? parseInt(query.since, 10) : 0;
735
+ const rows = db.prepare(`SELECT id, frame_number, timestamp, ai_response
736
+ FROM captures
737
+ WHERE session_id = ? AND ai_response IS NOT NULL AND ai_response != '' AND frame_number > ?
738
+ ORDER BY frame_number ASC`).all(query.sessionId, sinceFrame);
739
+ const analyses = rows.map((r) => ({
740
+ frameId: r.id,
741
+ frameNumber: r.frame_number,
742
+ timestamp: r.timestamp,
743
+ analysis: r.ai_response,
744
+ }));
745
+ return reply.code(200).send({ sessionId: query.sessionId, analyses });
746
+ }
747
+ catch (err) {
748
+ return reply.code(500).send({ error: err instanceof Error ? err.message : String(err) });
749
+ }
750
+ });
751
+ // GET /api/recording/monitor/status — monitor mode status
752
+ s.get('/api/recording/monitor/status', async (_request, reply) => {
753
+ const session = getCurrentSession();
754
+ if (!session || session.mode !== 'monitor') {
755
+ return reply.code(200).send({ status: 'inactive' });
756
+ }
757
+ const { getMonitorAnalyzer } = await Promise.resolve().then(() => __importStar(require('./recording/recording-session')));
758
+ const analyzer = getMonitorAnalyzer();
759
+ return reply.code(200).send({
760
+ status: 'monitoring',
761
+ sessionId: session.id,
762
+ mode: session.mode,
763
+ frameCount: session.frameCount,
764
+ alertCount: analyzer?.getAlertCount() || 0,
765
+ lastAnalysis: analyzer?.getLastAnalysis() || null,
766
+ });
767
+ });
768
+ // GET /api/recording/monitor/stream — SSE stream of monitor alerts
769
+ s.get('/api/recording/monitor/stream', async (request, reply) => {
770
+ const session = getCurrentSession();
771
+ if (!session || session.mode !== 'monitor') {
772
+ return reply.code(400).send({ error: 'No active monitor session' });
773
+ }
774
+ // Set up SSE headers
775
+ reply.raw.writeHead(200, {
776
+ 'Content-Type': 'text/event-stream',
777
+ 'Cache-Control': 'no-cache',
778
+ 'Connection': 'keep-alive',
779
+ 'X-Accel-Buffering': 'no',
780
+ });
781
+ reply.raw.write('event: connected\ndata: {"sessionId":"' + session.id + '"}\n\n');
782
+ // Register alert callback
783
+ const { setMonitorAlertCallback } = await Promise.resolve().then(() => __importStar(require('./recording/recording-session')));
784
+ const alertHandler = (alert) => {
785
+ const data = JSON.stringify(alert);
786
+ reply.raw.write(`event: alert\ndata: ${data}\n\n`);
787
+ };
788
+ setMonitorAlertCallback(alertHandler);
789
+ // Send keepalive every 15 seconds
790
+ const keepalive = setInterval(() => {
791
+ try {
792
+ reply.raw.write(':keepalive\n\n');
793
+ }
794
+ catch {
795
+ clearInterval(keepalive);
796
+ }
797
+ }, 15000);
798
+ // Cleanup on client disconnect
799
+ request.raw.on('close', () => {
800
+ clearInterval(keepalive);
801
+ setMonitorAlertCallback(() => { }); // Remove handler
802
+ });
803
+ // Don't send reply body — SSE uses raw stream
804
+ return reply;
805
+ });
712
806
  // GET /api/sessions
713
807
  s.get('/api/sessions', async (_request, reply) => {
714
808
  const sessions = getRecordingSessions(100);
@@ -4,6 +4,8 @@
4
4
  // On macOS, two issues affect capture:
5
5
  // 1. screenshot-desktop shells out to `screencapture` which can silently return blank images
6
6
  // 2. sharp's native binary may not be packaged for darwin — we fall back to Electron's nativeImage
7
+ //
8
+ // Headless mode: Electron APIs are not available. Uses screenshot-desktop + sharp instead.
7
9
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
11
  };
@@ -13,8 +15,20 @@ exports.getPreCapture = getPreCapture;
13
15
  exports.clearPreCapture = clearPreCapture;
14
16
  exports.captureScreen = captureScreen;
15
17
  exports.cropRegion = cropRegion;
16
- const electron_1 = require("electron");
17
18
  const logger_1 = __importDefault(require("../logger"));
19
+ // Lazy Electron imports — not available in headless mode
20
+ let desktopCapturer = null;
21
+ let nativeImage = null;
22
+ let electronScreen = null;
23
+ try {
24
+ const electron = require('electron');
25
+ desktopCapturer = electron.desktopCapturer;
26
+ nativeImage = electron.nativeImage;
27
+ electronScreen = electron.screen;
28
+ }
29
+ catch {
30
+ // Headless mode — Electron not available
31
+ }
18
32
  const isMac = process.platform === 'darwin';
19
33
  /**
20
34
  * Module-level storage for the pre-capture buffer taken before the selection window
@@ -37,7 +51,7 @@ function clearPreCapture() {
37
51
  * or screenshot-desktop (Windows/Linux, macOS fallback).
38
52
  */
39
53
  async function captureScreen() {
40
- if (isMac) {
54
+ if (isMac && desktopCapturer) {
41
55
  try {
42
56
  const buf = await captureScreenElectron();
43
57
  if (buf)
@@ -57,10 +71,12 @@ async function captureScreen() {
57
71
  * Returns null if the capture is empty (e.g., Screen Recording permission denied).
58
72
  */
59
73
  async function captureScreenElectron() {
60
- const primaryDisplay = electron_1.screen.getPrimaryDisplay();
74
+ if (!electronScreen || !desktopCapturer)
75
+ return null;
76
+ const primaryDisplay = electronScreen.getPrimaryDisplay();
61
77
  const { width, height } = primaryDisplay.size;
62
78
  const scaleFactor = primaryDisplay.scaleFactor || 1;
63
- const sources = await electron_1.desktopCapturer.getSources({
79
+ const sources = await desktopCapturer.getSources({
64
80
  types: ['screen'],
65
81
  thumbnailSize: {
66
82
  width: Math.round(width * scaleFactor),
@@ -90,9 +106,9 @@ async function captureScreenElectron() {
90
106
  * doesn't depend on any native module packaging).
91
107
  */
92
108
  async function cropRegion(fullScreenBuffer, region) {
93
- const primaryDisplay = electron_1.screen.getPrimaryDisplay();
94
- const scaleFactor = primaryDisplay.scaleFactor || 1;
95
- const displayBounds = primaryDisplay.bounds;
109
+ const primaryDisplay = electronScreen?.getPrimaryDisplay();
110
+ const scaleFactor = primaryDisplay?.scaleFactor || 1;
111
+ const displayBounds = primaryDisplay?.bounds || { x: 0, y: 0 };
96
112
  const left = Math.max(0, Math.round((region.x - displayBounds.x) * scaleFactor));
97
113
  const top = Math.max(0, Math.round((region.y - displayBounds.y) * scaleFactor));
98
114
  // Try sharp first (better quality, more format support)
@@ -123,7 +139,10 @@ async function cropRegion(fullScreenBuffer, region) {
123
139
  }
124
140
  }
125
141
  // Fallback: Electron's built-in nativeImage (no native module dependency)
126
- const img = electron_1.nativeImage.createFromBuffer(fullScreenBuffer);
142
+ if (!nativeImage) {
143
+ throw new Error('Cannot crop region: neither sharp nor Electron nativeImage available');
144
+ }
145
+ const img = nativeImage.createFromBuffer(fullScreenBuffer);
127
146
  if (img.isEmpty()) {
128
147
  throw new Error('Failed to create nativeImage from capture buffer');
129
148
  }
@@ -68,7 +68,6 @@ const constants_1 = require("../../shared/constants");
68
68
  let state = 'idle';
69
69
  let indicatorWindow = null;
70
70
  let uiohookModule = null;
71
- let hookStartedByDictation = false;
72
71
  let shortcutModifiers = ['ctrl', 'alt'];
73
72
  let aiCleanup = false;
74
73
  let soundFeedback = true;
@@ -731,7 +730,17 @@ function startDictation() {
731
730
  activeAppAtStart = { appName: null, windowTitle: null };
732
731
  });
733
732
  if (indicatorWindow && !indicatorWindow.isDestroyed()) {
733
+ // Refresh position + layer to ensure visibility (window may have been
734
+ // displaced by other always-on-top windows like the recording bar)
735
+ try {
736
+ const { screen } = require('electron');
737
+ const { width: screenW } = screen.getPrimaryDisplay().size;
738
+ indicatorWindow.setPosition(Math.round(screenW / 2 - 210), 8);
739
+ indicatorWindow.setAlwaysOnTop(true, 'screen-saver');
740
+ }
741
+ catch { /* ignore */ }
734
742
  indicatorWindow.showInactive();
743
+ logger_1.default.info('[Dictation] Indicator window shown, bounds:', JSON.stringify(indicatorWindow.getBounds()));
735
744
  if (transcriptionMode === 'realtime') {
736
745
  // Start PCM capture immediately so no speech is lost.
737
746
  // Audio is pre-buffered until the RT engine is ready, then flushed.
@@ -744,6 +753,9 @@ function startDictation() {
744
753
  indicatorWindow.webContents.send('dictation:start-recording');
745
754
  }
746
755
  }
756
+ else {
757
+ logger_1.default.warn('[Dictation] Indicator window unavailable:', indicatorWindow ? 'destroyed' : 'null');
758
+ }
747
759
  // Play start sound
748
760
  if (soundFeedback && indicatorWindow && !indicatorWindow.isDestroyed()) {
749
761
  indicatorWindow.webContents.send('dictation:play-sound', 'start');
@@ -1088,22 +1100,14 @@ async function initializeDictation(window) {
1088
1100
  Promise.resolve().then(() => __importStar(require('./azure-speech-realtime'))).then((rt) => rt.preloadSdk()).catch(() => { });
1089
1101
  }
1090
1102
  }).catch(() => { });
1091
- // Dynamically import uiohook-napi
1103
+ // Acquire uiohook via shared manager (reference-counted start/stop)
1092
1104
  try {
1093
- uiohookModule = await Promise.resolve().then(() => __importStar(require('uiohook-napi')));
1105
+ const { acquire } = await Promise.resolve().then(() => __importStar(require('./uiohook-manager')));
1106
+ uiohookModule = await acquire('dictation');
1094
1107
  const { uIOhook } = uiohookModule;
1095
1108
  // Register our listeners on the singleton
1096
1109
  uIOhook.on('keydown', onKeyDown);
1097
1110
  uIOhook.on('keyup', onKeyUp);
1098
- // Start hook if not already running (recording module may have started it)
1099
- try {
1100
- uIOhook.start();
1101
- hookStartedByDictation = true;
1102
- }
1103
- catch {
1104
- // Already running — that's fine
1105
- hookStartedByDictation = false;
1106
- }
1107
1111
  logger_1.default.info('[Dictation] Initialized, shortcut:', shortcutModifiers.join('+'), 'timeout:', maxDurationSeconds + 's');
1108
1112
  }
1109
1113
  catch (err) {
@@ -1116,14 +1120,13 @@ async function teardownDictation() {
1116
1120
  const { uIOhook } = uiohookModule;
1117
1121
  uIOhook.off('keydown', onKeyDown);
1118
1122
  uIOhook.off('keyup', onKeyUp);
1119
- // Only stop hook if we started it and recording module isn't using it
1120
- if (hookStartedByDictation) {
1121
- try {
1122
- uIOhook.stop();
1123
- }
1124
- catch {
1125
- // ignore
1126
- }
1123
+ // Release our reference — hook only stops if no other consumer needs it
1124
+ try {
1125
+ const { release } = await Promise.resolve().then(() => __importStar(require('./uiohook-manager')));
1126
+ release('dictation');
1127
+ }
1128
+ catch {
1129
+ // ignore
1127
1130
  }
1128
1131
  }
1129
1132
  pressedKeys.clear();
@@ -38,7 +38,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.performOCR = performOCR;
39
39
  exports.showOCRResult = showOCRResult;
40
40
  const path = __importStar(require("path"));
41
- const electron_1 = require("electron");
41
+ // Lazy Electron imports — not available in headless mode
42
+ let BrowserWindow = null;
43
+ let electronScreen = null;
44
+ try {
45
+ const electron = require('electron');
46
+ BrowserWindow = electron.BrowserWindow;
47
+ electronScreen = electron.screen;
48
+ }
49
+ catch {
50
+ // Headless mode
51
+ }
42
52
  let ocrWindow = null;
43
53
  async function performOCR(imageBuffer) {
44
54
  const Tesseract = require('tesseract.js');
@@ -51,9 +61,11 @@ function showOCRResult(text) {
51
61
  if (ocrWindow && !ocrWindow.isDestroyed()) {
52
62
  ocrWindow.close();
53
63
  }
54
- const primaryDisplay = electron_1.screen.getPrimaryDisplay();
64
+ if (!BrowserWindow || !electronScreen)
65
+ return; // Not available in headless
66
+ const primaryDisplay = electronScreen.getPrimaryDisplay();
55
67
  const { width: screenW } = primaryDisplay.size;
56
- ocrWindow = new electron_1.BrowserWindow({
68
+ ocrWindow = new BrowserWindow({
57
69
  x: Math.round(screenW / 2 - 250),
58
70
  y: 60,
59
71
  width: 500,
@@ -45,12 +45,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.CaptureQueue = void 0;
46
46
  const path = __importStar(require("path"));
47
47
  const fs = __importStar(require("fs"));
48
- const electron_1 = require("electron");
49
48
  const logger_1 = __importDefault(require("../../logger"));
50
49
  const active_window_1 = require("../active-window");
51
- const capture_1 = require("../capture");
50
+ const platform_1 = require("../../core/platform");
52
51
  const redact_1 = require("../redact");
53
- const store_1 = require("../store");
52
+ // Lazy Electron nativeImage — only available in desktop mode
53
+ let nativeImage = null;
54
+ try {
55
+ nativeImage = require('electron').nativeImage;
56
+ }
57
+ catch {
58
+ // Headless mode — nativeImage not available, sharp required
59
+ }
60
+ // Platform-aware getSetting
61
+ function getSetting(key) {
62
+ if ((0, platform_1.getPlatform)().isElectron()) {
63
+ const { getSetting: s } = require('../store');
64
+ return s(key);
65
+ }
66
+ const { getSetting: s } = require('../../core/json-store');
67
+ return s(key);
68
+ }
69
+ // Platform-aware captureScreen
70
+ async function captureScreenPlatform() {
71
+ if ((0, platform_1.getPlatform)().isElectron()) {
72
+ const { captureScreen } = require('../capture');
73
+ return captureScreen();
74
+ }
75
+ const screenshot = require('screenshot-desktop');
76
+ return screenshot({ format: 'png' });
77
+ }
54
78
  // Session limits
55
79
  const MAX_FRAMES_DEFAULT = 2000;
56
80
  const MAX_DURATION_DEFAULT = 60 * 60 * 1000; // 1 hour
@@ -159,7 +183,7 @@ class CaptureQueue {
159
183
  try {
160
184
  // Take screenshot — the expensive part (~800-1200ms)
161
185
  const t0 = Date.now();
162
- const fullBuffer = await (0, capture_1.captureScreen)();
186
+ const fullBuffer = await captureScreenPlatform();
163
187
  logger_1.default.info(`[CaptureQueue] captureScreen took ${Date.now() - t0}ms (inFlight=${this.inFlightCaptures})`);
164
188
  // Get active window info (while screenshot was being taken, window may have changed — grab it now)
165
189
  let windowTitle = null;
@@ -226,8 +250,8 @@ class CaptureQueue {
226
250
  const frameNum = this.frameCounter;
227
251
  const paddedNum = String(frameNum).padStart(4, '0');
228
252
  // Auto-redact sensitive content if enabled (runs inline before encode)
229
- const redactSecrets = !!(0, store_1.getSetting)('autoRedactSecrets');
230
- const redactPII = !!(0, store_1.getSetting)('autoRedactPII');
253
+ const redactSecrets = !!getSetting('autoRedactSecrets');
254
+ const redactPII = !!getSetting('autoRedactPII');
231
255
  if (redactSecrets || redactPII) {
232
256
  const redactResult = await (0, redact_1.autoRedact)(frame.buffer, { secrets: redactSecrets, pii: redactPII });
233
257
  if (redactResult.regionsFound > 0) {
@@ -255,9 +279,9 @@ class CaptureQueue {
255
279
  .toBuffer();
256
280
  thumbExt = 'webp';
257
281
  }
258
- else {
282
+ else if (nativeImage) {
259
283
  // nativeImage fallback: resize to 256px wide, use JPEG
260
- const img = electron_1.nativeImage.createFromBuffer(frame.buffer);
284
+ const img = nativeImage.createFromBuffer(frame.buffer);
261
285
  const size = img.getSize();
262
286
  const scale = 256 / Math.max(size.width, size.height);
263
287
  const resized = img.resize({
@@ -267,6 +291,11 @@ class CaptureQueue {
267
291
  thumbBuffer = resized.toJPEG(60);
268
292
  thumbExt = 'jpg';
269
293
  }
294
+ else {
295
+ // No sharp and no nativeImage — save raw PNG as thumbnail
296
+ thumbBuffer = frame.buffer;
297
+ thumbExt = 'png';
298
+ }
270
299
  const thumbName = `frame_${paddedNum}_thumb.${thumbExt}`;
271
300
  const thumbnailPath = path.join(this.sessionDir, 'thumbnails', thumbName);
272
301
  fs.writeFileSync(thumbnailPath, thumbBuffer);
@@ -297,7 +326,9 @@ class CaptureQueue {
297
326
  }
298
327
  /** Resize using nativeImage and return raw BGRA bitmap for comparison */
299
328
  resizeWithNativeImage(buffer, width, height) {
300
- const img = electron_1.nativeImage.createFromBuffer(buffer);
329
+ if (!nativeImage)
330
+ throw new Error('nativeImage not available in headless mode');
331
+ const img = nativeImage.createFromBuffer(buffer);
301
332
  const resized = img.resize({ width, height });
302
333
  return resized.toBitmap();
303
334
  }
@@ -321,7 +352,9 @@ class CaptureQueue {
321
352
  }
322
353
  /** Encode frame using nativeImage (JPEG/PNG only — no webp support) */
323
354
  encodeFrameNative(buffer) {
324
- const img = electron_1.nativeImage.createFromBuffer(buffer);
355
+ if (!nativeImage)
356
+ throw new Error('nativeImage not available in headless mode — sharp is required');
357
+ const img = nativeImage.createFromBuffer(buffer);
325
358
  switch (this.config.captureFormat) {
326
359
  case 'webp':
327
360
  case 'jpeg': {
@@ -47,7 +47,7 @@ exports.getCaptureQueue = getCaptureQueue;
47
47
  exports.getSessionModule = getSessionModule;
48
48
  exports.getMcpToolModule = getMcpToolModule;
49
49
  const provider_factory_1 = require("./providers/provider-factory");
50
- const electron_1 = require("electron");
50
+ const platform_1 = require("../../core/platform");
51
51
  const logger_1 = __importDefault(require("../../logger"));
52
52
  let hookProvider = null;
53
53
  let providerInfo = null;
@@ -57,11 +57,17 @@ let captureQueueModule = null;
57
57
  let sessionModule = null;
58
58
  let mcpToolModule = null;
59
59
  async function initialize() {
60
- // On macOS, request Accessibility permission
61
- if (process.platform === 'darwin') {
62
- const trusted = electron_1.systemPreferences.isTrustedAccessibilityClient(true);
63
- if (!trusted) {
64
- return { success: false, providerType: 'none', fallbackReason: 'Accessibility permission denied on macOS' };
60
+ // On macOS in Electron, request Accessibility permission
61
+ if (process.platform === 'darwin' && (0, platform_1.getPlatform)().isElectron()) {
62
+ try {
63
+ const { systemPreferences } = require('electron');
64
+ const trusted = systemPreferences.isTrustedAccessibilityClient(true);
65
+ if (!trusted) {
66
+ return { success: false, providerType: 'none', fallbackReason: 'Accessibility permission denied on macOS' };
67
+ }
68
+ }
69
+ catch {
70
+ // Headless — skip accessibility check
65
71
  }
66
72
  }
67
73
  // Create the input hook provider (uiohook → periodic fallback)