superbased 1.4.0 → 1.6.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.
Files changed (79) hide show
  1. package/SUPERBASED_SKILL.md +129 -34
  2. package/dist/electron/core/platform.d.ts +2 -0
  3. package/dist/electron/core/platform.d.ts.map +1 -1
  4. package/dist/electron/main.js +95 -13
  5. package/dist/electron/modules/active-window.d.ts.map +1 -1
  6. package/dist/electron/modules/active-window.js +8 -0
  7. package/dist/electron/modules/active-window.js.map +1 -1
  8. package/dist/electron/modules/api-server.d.ts.map +1 -1
  9. package/dist/electron/modules/api-server.js +232 -4
  10. package/dist/electron/modules/api-server.js.map +1 -1
  11. package/dist/electron/modules/azure-speech-realtime.d.ts +13 -3
  12. package/dist/electron/modules/azure-speech-realtime.d.ts.map +1 -1
  13. package/dist/electron/modules/azure-speech-realtime.js +187 -54
  14. package/dist/electron/modules/azure-speech-realtime.js.map +1 -1
  15. package/dist/electron/modules/capture.d.ts.map +1 -1
  16. package/dist/electron/modules/capture.js +27 -8
  17. package/dist/electron/modules/capture.js.map +1 -1
  18. package/dist/electron/modules/dictation.d.ts +2 -0
  19. package/dist/electron/modules/dictation.d.ts.map +1 -1
  20. package/dist/electron/modules/dictation.js +145 -20
  21. package/dist/electron/modules/dictation.js.map +1 -1
  22. package/dist/electron/modules/ocr.d.ts.map +1 -1
  23. package/dist/electron/modules/ocr.js +15 -3
  24. package/dist/electron/modules/ocr.js.map +1 -1
  25. package/dist/electron/modules/recording/capture-queue.d.ts.map +1 -1
  26. package/dist/electron/modules/recording/capture-queue.js +43 -10
  27. package/dist/electron/modules/recording/capture-queue.js.map +1 -1
  28. package/dist/electron/modules/recording/index.d.ts.map +1 -1
  29. package/dist/electron/modules/recording/index.js +12 -6
  30. package/dist/electron/modules/recording/index.js.map +1 -1
  31. package/dist/electron/modules/recording/monitor-analyzer.d.ts +40 -0
  32. package/dist/electron/modules/recording/monitor-analyzer.d.ts.map +1 -0
  33. package/dist/electron/modules/recording/monitor-analyzer.js +220 -0
  34. package/dist/electron/modules/recording/monitor-analyzer.js.map +1 -0
  35. package/dist/electron/modules/recording/providers/change-detect-provider.d.ts +28 -0
  36. package/dist/electron/modules/recording/providers/change-detect-provider.d.ts.map +1 -0
  37. package/dist/electron/modules/recording/providers/change-detect-provider.js +181 -0
  38. package/dist/electron/modules/recording/providers/change-detect-provider.js.map +1 -0
  39. package/dist/electron/modules/recording/providers/provider-factory.d.ts +8 -2
  40. package/dist/electron/modules/recording/providers/provider-factory.d.ts.map +1 -1
  41. package/dist/electron/modules/recording/providers/provider-factory.js +33 -12
  42. package/dist/electron/modules/recording/providers/provider-factory.js.map +1 -1
  43. package/dist/electron/modules/recording/providers/uiohook-provider.d.ts.map +1 -1
  44. package/dist/electron/modules/recording/providers/uiohook-provider.js +9 -5
  45. package/dist/electron/modules/recording/providers/uiohook-provider.js.map +1 -1
  46. package/dist/electron/modules/recording/recording-session.d.ts +5 -1
  47. package/dist/electron/modules/recording/recording-session.d.ts.map +1 -1
  48. package/dist/electron/modules/recording/recording-session.js +78 -6
  49. package/dist/electron/modules/recording/recording-session.js.map +1 -1
  50. package/dist/electron/modules/recording/trigger-engine.d.ts.map +1 -1
  51. package/dist/electron/modules/recording/trigger-engine.js +10 -3
  52. package/dist/electron/modules/recording/trigger-engine.js.map +1 -1
  53. package/dist/electron/modules/store.js +2 -2
  54. package/dist/electron/modules/store.js.map +1 -1
  55. package/dist/electron/modules/uiohook-manager.d.ts +19 -0
  56. package/dist/electron/modules/uiohook-manager.d.ts.map +1 -0
  57. package/dist/electron/modules/uiohook-manager.js +101 -0
  58. package/dist/electron/modules/uiohook-manager.js.map +1 -0
  59. package/dist/headless/electron/modules/active-window.js +8 -0
  60. package/dist/headless/electron/modules/api-server.js +137 -3
  61. package/dist/headless/electron/modules/azure-speech-realtime.js +187 -54
  62. package/dist/headless/electron/modules/dictation.js +122 -0
  63. package/dist/headless/headless/dictation-hotkey.js +212 -47
  64. package/dist/headless/headless/dictation-overlay.js +218 -0
  65. package/dist/headless/headless/mic-capture.js +95 -1
  66. package/dist/headless/headless/platform-headless.js +103 -3
  67. package/dist/headless/headless/win32-text-injector.js +359 -0
  68. package/dist/headless/mic-capture.d.ts +21 -1
  69. package/dist/headless/mic-capture.d.ts.map +1 -1
  70. package/dist/headless/mic-capture.js +95 -1
  71. package/dist/headless/mic-capture.js.map +1 -1
  72. package/dist/shared/constants.d.ts +1 -1
  73. package/dist/shared/constants.js +1 -1
  74. package/dist/shared/constants.js.map +1 -1
  75. package/dist/shared/recording-types.d.ts +12 -0
  76. package/dist/shared/recording-types.d.ts.map +1 -1
  77. package/mcp-server/dist/api-client.js +9 -0
  78. package/mcp-server/dist/index.js +91 -6
  79. package/package.json +2 -2
@@ -1,15 +1,27 @@
1
1
  # SuperBased — AI Screenshot Tool for Developers
2
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, record sessions, run visual regression tests, and compress text — all programmatically from your coding environment.
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
4
 
5
5
  ## Setup
6
6
 
7
7
  ### 1. Make sure SuperBased is running
8
- The desktop app must be running for the MCP tools to work. It starts an HTTP API on `http://127.0.0.1:47592` automatically.
8
+ The desktop app or headless server must be running. It starts an HTTP API on `http://127.0.0.1:47592` automatically.
9
9
 
10
- ### 2. Add MCP server to Claude Code
11
- Create `.mcp.json` in your project root:
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
+ ```
12
22
 
23
+ ### 2. Add MCP server (alternative: node path)
24
+ If `superbased` isn't on PATH, use the full node path:
13
25
  ```json
14
26
  {
15
27
  "mcpServers": {
@@ -20,11 +32,10 @@ Create `.mcp.json` in your project root:
20
32
  }
21
33
  }
22
34
  ```
23
-
24
- Check `~/.superbased/superbased-mcp.json` for the correct path after starting SuperBased. Restart Claude Code after creating the file.
35
+ Check `~/.superbased/mcp.json` for the correct path after starting SuperBased. Restart your editor after creating the file.
25
36
 
26
37
  ### 3. Verify connection
27
- Ask: "Check the SuperBased health status" — Claude should call `superbased_health` and show version, uptime, and features.
38
+ Ask: "Check the SuperBased health status" — the agent should call `superbased_health` and show version, uptime, and features.
28
39
 
29
40
  ---
30
41
 
@@ -38,7 +49,7 @@ Take a screenshot. Returns capture ID and metadata (no image inline — use `sup
38
49
  | Parameter | Type | Description |
39
50
  |-----------|------|-------------|
40
51
  | `mode` | `fullscreen` / `region` / `active_window` | What to capture |
41
- | `x`, `y`, `width`, `height` | number | Coordinates for region mode |
52
+ | `x`, `y`, `width`, `height` | number | Absolute screen pixel coordinates for region mode (0,0 = top-left) |
42
53
  | `projectDir` | string | Where to save (default: CWD) |
43
54
 
44
55
  #### superbased_capture_image
@@ -48,23 +59,34 @@ Capture screen and return the **image inline** so you can see it. Supports resol
48
59
  |-----------|------|-------------|
49
60
  | `mode` | `fullscreen` / `region` / `active_window` | Capture mode (default: fullscreen) |
50
61
  | `resolution` | `full` / `high` / `half` / `quarter` / `thumbnail` | Image resolution (default: half — saves ~4x tokens vs full) |
51
- | `window` | string | Capture a specific window by name substring |
52
- | `x`, `y`, `width`, `height` | number | For region mode |
62
+ | `window` | string | Capture a specific window by name substring (case-insensitive). Activates the window (even if minimized), captures, then restores the previous foreground window. Use `superbased_window_list` to find window names. |
63
+ | `x`, `y`, `width`, `height` | number | Absolute screen pixel coordinates for region mode |
53
64
 
54
65
  **Token savings**: A 1920x1080 screenshot at `full` = ~2,765 tokens. At `half` = ~691 tokens. At `quarter` = ~173 tokens.
55
66
 
67
+ **Window targeting workflow:**
68
+ 1. Call `superbased_window_list` to see all windows
69
+ 2. Pick the window name (or a unique substring)
70
+ 3. Call `superbased_capture_image` with `window="substring"` — SuperBased will activate the window (restore if minimized), capture it, then restore focus to the previous window
71
+
56
72
  #### superbased_gallery_image
57
73
  Retrieve a saved capture's image inline from the gallery.
58
74
 
59
75
  | Parameter | Type | Description |
60
76
  |-----------|------|-------------|
61
77
  | `captureId` | number | Gallery capture ID |
62
- | `resolution` | `full` / `high` / `half` / `quarter` / `thumbnail` | Image resolution (default: half) |
78
+ | `resolution` | `full` / `high` / `half` / `quarter` / `thumbnail` | Image resolution (default: half). Use `quarter` or `thumbnail` when you only need to check layout/presence, not read text. |
79
+
80
+ **Token savings**: Same as `superbased_capture_image` — `half` saves ~4x vs `full`, `quarter` saves ~16x.
63
81
 
64
82
  #### superbased_window_list
65
- List all visible windows on screen. Use this to find window names for targeted capture.
83
+ List all visible windows on screen. Returns each window's name, active status, and minimized state. Use window names with `superbased_capture_image` to target specific windows.
66
84
 
67
- Returns: list of windows with names and active status.
85
+ Returns: `{ windows: [{ id, name, hwnd, minimized, isActive }], activeWindow: { appName, windowTitle } }`
86
+
87
+ - `hwnd` (Windows only): Window handle used internally for activation
88
+ - `minimized`: Whether the window is minimized to taskbar
89
+ - `isActive`: Whether this is the currently focused window
68
90
 
69
91
  ### AI & OCR
70
92
 
@@ -73,7 +95,7 @@ Send a screenshot to AI for analysis. If no image provided, captures the screen
73
95
 
74
96
  | Parameter | Type | Description |
75
97
  |-----------|------|-------------|
76
- | `instruction` | string | What to do. Slash commands: `/extract`, `/summarize`, `/code`, `/explain`, `/translate`, `/table`, `/edit`, `/reformat` |
98
+ | `instruction` | string | What to do. Supports slash commands: `/extract` (get text), `/summarize`, `/code` (extract code), `/explain`, `/translate`, `/table` (extract tabular data), `/edit`, `/reformat` |
77
99
  | `captureId` | number | Use an existing capture from gallery |
78
100
  | `screenshotPath` | string | Path to an image file |
79
101
  | `projectDir` | string | For auto-captures |
@@ -90,7 +112,7 @@ Extract text from a screenshot using Tesseract OCR (runs locally — no data lea
90
112
  Check your daily AI quota (used/remaining/limit). Requires sign-in.
91
113
 
92
114
  #### superbased_transcribe
93
- Transcribe an audio file to text via Whisper.
115
+ Transcribe an audio file to text via Whisper (raw transcription, no cleanup). For voice notes with filler word removal, use `superbased_dictate` instead.
94
116
 
95
117
  | Parameter | Type | Description |
96
118
  |-----------|------|-------------|
@@ -152,28 +174,39 @@ Add programmatic annotations to captures (rectangles, highlights, blur, text lab
152
174
  | Parameter | Type | Description |
153
175
  |-----------|------|-------------|
154
176
  | `captureId` | number | Capture to annotate |
155
- | `annotations` | array | Annotation objects (see below) |
156
- | `save` | boolean | Save over the original (default: false) |
177
+ | `annotations` | array | Annotation objects (see types below) |
178
+ | `save` | boolean | Save over the original (default: false — returns annotated image without modifying the original) |
179
+
180
+ **Annotation types:**
181
+ - `rectangle`: bounding box outline — `{type:"rectangle", x, y, width, height, color}`
182
+ - `highlight`: semi-transparent overlay — `{type:"highlight", x, y, width, height, color}`
183
+ - `blur`: pixelate a region — `{type:"blur", x, y, width, height}`
184
+ - `text`: text label — `{type:"text", x, y, text, color, fontSize}`
185
+ - `arrow`: arrow between two points — `{type:"arrow", x, y, toX, toY, color}`
157
186
 
158
- Annotation types:
159
- - `rectangle`: bounding box outline (x, y, width, height, color)
160
- - `highlight`: semi-transparent overlay (x, y, width, height, color)
161
- - `blur`: pixelate a region (x, y, width, height)
162
- - `text`: text label (x, y, text, color, fontSize)
163
- - `arrow`: arrow from one point to another (x, y, toX, toY, color)
187
+ **Example:**
188
+ ```
189
+ superbased_annotate captureId=42 annotations=[{type:"rectangle",x:100,y:200,width:300,height:50,color:"#ff0000"},{type:"text",x:100,y:190,text:"Bug: misaligned button",color:"#ff0000"}]
190
+ ```
164
191
 
165
192
  ### Dictation & Voice
166
193
 
167
194
  #### superbased_dictate
168
- Transcribe audio with text cleanup (filler word removal, deduplication).
195
+ Transcribe audio with text cleanup (filler word removal, deduplication). Supports file input, base64, or **live microphone recording**.
169
196
 
170
197
  | Parameter | Type | Description |
171
198
  |-----------|------|-------------|
172
199
  | `audioPath` | string | Path to audio file |
173
200
  | `audioBase64` | string | Base64-encoded audio |
201
+ | `mic` | boolean | Set to `true` to record from the microphone (requires ffmpeg installed) |
202
+ | `duration` | number | Mic recording duration in seconds (default: 10) |
174
203
  | `language` | string | BCP 47 language code |
175
204
  | `cleanup` | boolean | Apply filler removal + dedup (default: true) |
176
205
 
206
+ **When to use `mic`:** The user asks you to "listen", "hear what I'm saying", or wants live voice input. Set `mic=true` and optionally `duration=15` for longer recordings.
207
+
208
+ **`superbased_dictate` vs `superbased_transcribe`:** Dictate adds text cleanup (filler words, deduplication) and supports mic recording. Transcribe is raw Whisper output only.
209
+
177
210
  #### superbased_dictation_history
178
211
  Query past voice transcriptions.
179
212
 
@@ -184,14 +217,31 @@ Query past voice transcriptions.
184
217
  ### Recording & Visual QA
185
218
 
186
219
  #### superbased_recording
187
- Control automated screenshot recording sessions.
220
+ Control automated screenshot recording sessions. Supports 4 modes: interaction (desktop input hooks), periodic (fixed interval), smart (change detection — headless default), and monitor (smart + AI analysis loop).
188
221
 
189
222
  | Parameter | Type | Description |
190
223
  |-----------|------|-------------|
191
- | `action` | `start` / `stop` / `pause` / `resume` / `status` / `capture` | Recording action |
224
+ | `action` | `start` / `stop` / `pause` / `resume` / `status` / `capture` / `get_analysis` | Recording action |
192
225
  | `name` | string | Session name |
193
226
  | `profile` | `automated_test` / `bug_report` / `user_journey` / `compliance` | Recording profile |
194
227
  | `targetApp` | string | Process name to scope to |
228
+ | `mode` | `interaction` / `periodic` / `smart` / `monitor` | Recording mode (default: smart for headless, interaction for desktop) |
229
+ | `interval` | number | Capture interval in seconds (default: 3 for smart, 5 for monitor) |
230
+ | `changeThreshold` | number | 0-1, minimum visual change to trigger capture (default: 0.05 = 5%) |
231
+ | `analysisPrompt` | string | Custom AI instruction for monitor mode (e.g. "Flag any errors or test failures") |
232
+ | `analyzeEvery` | number | AI analysis every N significant frames (monitor mode, default: 5) |
233
+ | `analyzeInterval` | number | Minimum seconds between AI analyses (monitor mode, default: 30) |
234
+ | `analysisDetail` | `low` / `high` | Image resolution for AI: low=512px, high=1024px (monitor mode, default: low) |
235
+ | `sessionId` | string | Session ID (for `get_analysis` action) |
236
+ | `since` | number | Only analyses after frame N (for `get_analysis` action) |
237
+
238
+ **Recording modes:**
239
+ - **`smart`** (recommended for headless/MCP): Captures at interval, but only saves frames when the screen visually changes by more than the threshold. Efficient — no redundant frames.
240
+ - **`monitor`**: Like smart, but periodically sends captured frames to AI for analysis. AI flags errors, warnings, or unexpected states. Alerts are sent as MCP notifications and stored on frames. Use `get_analysis` to retrieve all AI analyses for a session.
241
+ - **`periodic`**: Captures every N seconds regardless of changes. Simple time-lapse.
242
+ - **`interaction`**: Desktop only — captures on clicks, keystrokes, scrolls (requires input hooks).
243
+
244
+ **Monitor mode token budget:** Control AI costs with `analyzeEvery` (frames between AI calls) and `analyzeInterval` (minimum seconds between AI calls). Use `analysisDetail=low` to send 512px images (fewer tokens).
195
245
 
196
246
  #### superbased_sessions
197
247
  List past recording sessions and their frames.
@@ -254,13 +304,14 @@ View or update app settings. API keys are never exposed.
254
304
  | `value` | string | New value for `set` |
255
305
 
256
306
  #### superbased_presets
257
- Manage AI instruction presets (saved templates).
307
+ Manage AI instruction presets (saved templates with optional keyboard shortcuts).
258
308
 
259
309
  | Parameter | Type | Description |
260
310
  |-----------|------|-------------|
261
311
  | `action` | `list` / `create` / `update` / `delete` | What to do |
262
312
  | `name` | string | Preset name |
263
313
  | `instruction` | string | AI instruction template |
314
+ | `shortcut` | string | Keyboard shortcut (e.g. "Ctrl+Shift+1") |
264
315
  | `id` | number | Preset ID (for update/delete) |
265
316
 
266
317
  ### Status & Auth
@@ -282,6 +333,8 @@ Read or write system clipboard.
282
333
  | `action` | `read` / `write` / `readImage` | Clipboard action |
283
334
  | `text` | string | Text to write (for write action) |
284
335
 
336
+ **Returns:** `read` returns clipboard text. `write` confirms success. `readImage` returns the clipboard image inline (PNG) — useful for reading screenshots copied from other apps.
337
+
285
338
  ---
286
339
 
287
340
  ## Common Workflows
@@ -291,10 +344,18 @@ Read or write system clipboard.
291
344
  superbased_capture_image mode=fullscreen resolution=half
292
345
  ```
293
346
 
294
- ### Capture a specific window (saves tokens)
347
+ ### Capture a specific window (even if minimized)
348
+ ```
349
+ 1. superbased_window_list -> find the window name
350
+ 2. superbased_capture_image window="Notepad" resolution=half
351
+ ```
352
+ The window will be activated (restored if minimized), captured, and focus restored to the previous window.
353
+
354
+ ### Read text from a specific window
295
355
  ```
296
- 1. superbased_window_list → find the window name
297
- 2. superbased_capture_image window="VS Code" resolution=quarter
356
+ 1. superbased_window_list -> find window name
357
+ 2. superbased_capture_image window="Chrome" resolution=half -> capture + view it
358
+ 3. superbased_ocr captureId=<id> -> extract text from capture
298
359
  ```
299
360
 
300
361
  ### Screenshot and extract text
@@ -314,6 +375,28 @@ superbased_ai instruction="/extract"
314
375
  2. superbased_redact captureId=<id> secrets=true pii=true
315
376
  ```
316
377
 
378
+ ### Live mic dictation
379
+ ```
380
+ superbased_dictate mic=true duration=15
381
+ ```
382
+ Records from the microphone for 15 seconds, transcribes with cleanup.
383
+
384
+ ### Smart screen recording (change detection)
385
+ ```
386
+ superbased_recording action=start name="Testing checkout" mode=smart interval=2
387
+ (do things on screen — only visual changes are captured)
388
+ superbased_recording action=stop
389
+ superbased_sessions action=frames sessionId=<id>
390
+ ```
391
+
392
+ ### Proactive screen monitoring
393
+ ```
394
+ superbased_recording action=start mode=monitor name="Deploy watch" analysisPrompt="Flag any errors, failed health checks, or red status indicators" analyzeEvery=3 analyzeInterval=20
395
+ (AI will analyze frames and alert via MCP notifications)
396
+ superbased_recording action=get_analysis sessionId=<id>
397
+ superbased_recording action=stop
398
+ ```
399
+
317
400
  ### Visual regression testing
318
401
  ```
319
402
  1. superbased_recording action=start name="Before: login flow" profile=automated_test
@@ -334,6 +417,12 @@ superbased_ai instruction="/extract"
334
417
  2. superbased_annotate captureId=<id> annotations=[{type:"rectangle", x:100, y:200, width:300, height:50, color:"#ff0000"}, {type:"text", x:100, y:190, text:"Bug: button is misaligned"}] save=true
335
418
  ```
336
419
 
420
+ ### Read an image from clipboard
421
+ ```
422
+ superbased_clipboard action=readImage
423
+ ```
424
+ Returns the clipboard image inline — useful when the user says "look at what I copied."
425
+
337
426
  ### Compress large text for token savings
338
427
  ```
339
428
  superbased_compress_text text="<large text content>" preset=compact theme=dark
@@ -342,17 +431,23 @@ superbased_compress_text text="<large text content>" preset=compact theme=dark
342
431
  ## Tips
343
432
 
344
433
  - **Use `resolution=half` or `quarter`** to save tokens when you don't need full detail
345
- - **Use `window` param** to capture just the window you care about — much smaller image
434
+ - **Use `window` param** to capture just the window you care about — works even on minimized windows
346
435
  - **The `/extract` slash command** is the fastest way to get text from screen
347
436
  - **Captures are saved to your project** when `projectDir` is set (automatic in Claude Code)
348
437
  - **Gallery persists across sessions** — search for past captures anytime
349
438
  - **OCR is local** (Tesseract) — no data leaves your machine for text extraction
350
439
  - **Redact before sharing** — use `superbased_redact` to remove API keys and PII
351
- - **Visual QA workflow**: record → change → record → diff → report
440
+ - **Mic dictation** — `superbased_dictate mic=true` records live audio, no file needed
441
+ - **Visual QA workflow**: record -> change -> record -> diff -> report
442
+ - **Smart recording** — use `mode=smart` to only capture when the screen changes (no redundant frames)
443
+ - **Monitor mode** — use `mode=monitor` for proactive AI screen watching; the AI will flag errors and unexpected states
444
+ - **Monitor token control** — set `analyzeEvery=10 analyzeInterval=60` to reduce AI calls during long monitoring sessions
445
+ - **Clipboard image** — `superbased_clipboard action=readImage` shows whatever image the user copied
352
446
 
353
447
  ## Troubleshooting
354
448
 
355
- - **"Cannot connect to SuperBased"** — Make sure the desktop app is running
356
- - **"Authentication required"** — Sign in via SuperBased app, or run `superbased_auth`
449
+ - **"Cannot connect to SuperBased"** — Make sure the desktop app or `superbased mcp` is running
450
+ - **"Authentication required"** — Sign in via SuperBased app, or run `superbased auth login`
357
451
  - **Recording tools return errors** — Enable recording in SuperBased Settings > Recording
452
+ - **Window capture gets wrong window** — Use the exact window name from `superbased_window_list`
358
453
  - **Check app status**: Use `superbased_health` or check `~/.superbased/mcp.json`
@@ -12,6 +12,8 @@ export interface Platform {
12
12
  listWindows(): Promise<{
13
13
  id: string;
14
14
  name: string;
15
+ hwnd?: string;
16
+ minimized?: boolean;
15
17
  }[]>;
16
18
  openUrl(url: string): void;
17
19
  isElectron(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../electron/core/platform.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,MAAM,CAAC;IACrB,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,gBAAgB,IAAI,MAAM,CAAC;IAC3B,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,IAAI,OAAO,CAAC;CACvB;AAID,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAE7C;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAGtC"}
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../electron/core/platform.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,MAAM,CAAC;IACrB,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,gBAAgB,IAAI,MAAM,CAAC;IAC3B,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC3F,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,IAAI,OAAO,CAAC;CACvB;AAID,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAE7C;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAGtC"}
@@ -159,7 +159,7 @@ function framelessWindowOptions() {
159
159
  return {
160
160
  titleBarStyle: 'hidden',
161
161
  trafficLightPosition: { x: 12, y: 12 },
162
- fullscreenable: false,
162
+ fullscreenable: true,
163
163
  };
164
164
  }
165
165
  return { frame: false, icon: getAppIcon() };
@@ -226,10 +226,21 @@ function attachCrashHandlers(win, windowName) {
226
226
  }
227
227
  function isPathSafe(filePath) {
228
228
  const resolved = path.resolve(filePath);
229
+ if (resolved.includes('..'))
230
+ return false;
229
231
  const capturesDir = getCapturesDir();
230
232
  const userDataDir = electron_1.app.getPath('userData');
231
233
  const tempDir = electron_1.app.getPath('temp');
232
- return resolved.startsWith(capturesDir) || resolved.startsWith(userDataDir) || resolved.startsWith(tempDir);
234
+ if (resolved.startsWith(capturesDir) || resolved.startsWith(userDataDir) || resolved.startsWith(tempDir)) {
235
+ return true;
236
+ }
237
+ // Allow project-specific MCP captures: {projectDir}/.superbased/captures/
238
+ const sep = path.sep;
239
+ const marker = `${sep}.superbased${sep}captures${sep}`;
240
+ if (resolved.includes(marker) && path.isAbsolute(resolved) && fs.existsSync(resolved)) {
241
+ return true;
242
+ }
243
+ return false;
233
244
  }
234
245
  function getCapturesDir() {
235
246
  const custom = (0, store_1.getSetting)('screenshotFolder');
@@ -355,6 +366,13 @@ async function createSelectionWindowInner() {
355
366
  selectionWindow.setAlwaysOnTop(true, 'screen-saver');
356
367
  selectionWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
357
368
  }
369
+ // Fallback Escape key handler at the main-process level (macOS simpleFullscreen
370
+ // can sometimes swallow renderer keyboard events)
371
+ selectionWindow.webContents.on('before-input-event', (_event, input) => {
372
+ if (input.key === 'Escape' && input.type === 'keyDown') {
373
+ closeSelectionWindow();
374
+ }
375
+ });
358
376
  attachCrashHandlers(selectionWindow, 'selection');
359
377
  selectionWindow.loadFile(path.join(__dirname, '../renderer/selection.html'));
360
378
  selectionWindow.setIgnoreMouseEvents(false);
@@ -441,7 +459,20 @@ function createOverlayWindow(initData, region) {
441
459
  // Show on all workspaces so overlay appears on fullscreen app spaces
442
460
  overlayWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
443
461
  }
444
- makeWindowFocusAware(overlayWindow);
462
+ // Bring overlay above other app windows (e.g. gallery) on creation
463
+ overlayWindow.once('ready-to-show', () => {
464
+ if (overlayWindow && !overlayWindow.isDestroyed()) {
465
+ overlayWindow.show();
466
+ overlayWindow.setAlwaysOnTop(true);
467
+ overlayWindow.focus();
468
+ // Drop back to normal z-order after a tick so it doesn't stay permanently on top
469
+ setTimeout(() => {
470
+ if (overlayWindow && !overlayWindow.isDestroyed()) {
471
+ overlayWindow.setAlwaysOnTop(false);
472
+ }
473
+ }, 300);
474
+ }
475
+ });
445
476
  overlayWindow.loadFile(path.join(__dirname, '../renderer/overlay.html'));
446
477
  overlayWindow.webContents.on('did-finish-load', () => {
447
478
  logger_1.default.info(`[Overlay] did-finish-load, sending init: screenshotPath=${initData.screenshotPath}, regionScreenshots=${(initData.regionScreenshots || []).length}`);
@@ -832,6 +863,7 @@ function setupIpcHandlers() {
832
863
  // Show overlay again and notify it of the new screenshot
833
864
  if (overlayWindow && !overlayWindow.isDestroyed()) {
834
865
  overlayWindow.show();
866
+ overlayWindow.focus();
835
867
  overlayWindow.webContents.send('capture:screenshot-added', filepath);
836
868
  }
837
869
  return { success: true, filepath };
@@ -994,7 +1026,7 @@ function setupIpcHandlers() {
994
1026
  createSelectionWindow();
995
1027
  return { success: true };
996
1028
  });
997
- electron_1.ipcMain.handle('ai:process', async (_event, data) => {
1029
+ electron_1.ipcMain.handle('ai:process', async (event, data) => {
998
1030
  // Require authentication for AI features
999
1031
  if (!(0, auth_1.isAuthenticated)()) {
1000
1032
  return { success: false, error: 'Please sign in to use AI features.' };
@@ -1037,8 +1069,8 @@ function setupIpcHandlers() {
1037
1069
  const megapixels = sizeBytes / (3 * 1024 * 1024);
1038
1070
  totalEstTokens += Math.max(1600, Math.round(megapixels * 1600));
1039
1071
  }
1040
- if (totalEstTokens > 80000 && overlayWindow && !overlayWindow.isDestroyed()) {
1041
- overlayWindow.webContents.send('ai:token-warning', {
1072
+ if (totalEstTokens > 80000 && !event.sender.isDestroyed()) {
1073
+ event.sender.send('ai:token-warning', {
1042
1074
  estimatedTokens: totalEstTokens,
1043
1075
  imageCount: imagesBase64.length,
1044
1076
  });
@@ -1063,15 +1095,15 @@ function setupIpcHandlers() {
1063
1095
  })) {
1064
1096
  fullResponse += chunk;
1065
1097
  chunksSent++;
1066
- if (overlayWindow && !overlayWindow.isDestroyed()) {
1067
- overlayWindow.webContents.send('ai:stream-chunk', chunk);
1098
+ if (!event.sender.isDestroyed()) {
1099
+ event.sender.send('ai:stream-chunk', chunk);
1068
1100
  }
1069
1101
  }
1070
1102
  logger_1.default.info(`[AI] Stream finished. Chunks sent: ${chunksSent}, Response length: ${fullResponse.length}`);
1071
1103
  logger_1.default.info(`[AI] First 200 chars: ${fullResponse.slice(0, 200)}`);
1072
- if (overlayWindow && !overlayWindow.isDestroyed()) {
1073
- overlayWindow.webContents.send('ai:stream-complete');
1074
- logger_1.default.info('[AI] Sent stream-complete to overlay');
1104
+ if (!event.sender.isDestroyed()) {
1105
+ event.sender.send('ai:stream-complete');
1106
+ logger_1.default.info('[AI] Sent stream-complete to sender');
1075
1107
  }
1076
1108
  (0, database_1.updateCapture)(data.captureId, {
1077
1109
  aiResponse: fullResponse,
@@ -1083,8 +1115,8 @@ function setupIpcHandlers() {
1083
1115
  }
1084
1116
  catch (error) {
1085
1117
  const errorMsg = error instanceof Error ? error.message : String(error);
1086
- if (overlayWindow && !overlayWindow.isDestroyed()) {
1087
- overlayWindow.webContents.send('ai:stream-error', errorMsg);
1118
+ if (!event.sender.isDestroyed()) {
1119
+ event.sender.send('ai:stream-error', errorMsg);
1088
1120
  }
1089
1121
  return { success: false, error: errorMsg };
1090
1122
  }
@@ -1707,6 +1739,42 @@ function setupIpcHandlers() {
1707
1739
  return { success: false, error: String(error) };
1708
1740
  }
1709
1741
  });
1742
+ // Merge multiple screenshots into a single image file and return its path
1743
+ electron_1.ipcMain.handle('overlay:merge-to-file', async (_event, filepaths) => {
1744
+ try {
1745
+ if (filepaths.length <= 1) {
1746
+ return { success: true, path: filepaths[0] };
1747
+ }
1748
+ const sharp = require('sharp');
1749
+ const metas = await Promise.all(filepaths.map(async (fp) => {
1750
+ const meta = await sharp(fp).metadata();
1751
+ return { path: fp, width: meta.width || 200, height: meta.height || 200 };
1752
+ }));
1753
+ const gap = 4;
1754
+ const totalWidth = metas.reduce((sum, m) => sum + m.width, 0) + gap * (metas.length - 1);
1755
+ const maxHeight = Math.max(...metas.map((m) => m.height));
1756
+ const compositeInputs = [];
1757
+ let xOffset = 0;
1758
+ for (const m of metas) {
1759
+ compositeInputs.push({ input: m.path, left: xOffset, top: Math.round((maxHeight - m.height) / 2) });
1760
+ xOffset += m.width + gap;
1761
+ }
1762
+ const exportDir = getCapturesDir();
1763
+ ensureCapturesDir();
1764
+ const mergedPath = path.join(exportDir, `merged-${Date.now()}.png`);
1765
+ await sharp({
1766
+ create: { width: totalWidth, height: maxHeight, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } },
1767
+ })
1768
+ .composite(compositeInputs)
1769
+ .png()
1770
+ .toFile(mergedPath);
1771
+ return { success: true, path: mergedPath };
1772
+ }
1773
+ catch (err) {
1774
+ logger_1.default.error('[Copy] Merge-to-file failed:', err);
1775
+ return { success: false, error: err instanceof Error ? err.message : String(err) };
1776
+ }
1777
+ });
1710
1778
  // Export screenshots to user's folder and copy file paths to clipboard
1711
1779
  // mode: 'files' = copy as file drop list, 'paths' = copy paths as text
1712
1780
  electron_1.ipcMain.handle('overlay:export-screenshots', async (_event, data) => {
@@ -2007,6 +2075,20 @@ function setupIpcHandlers() {
2007
2075
  return { success: false, error: err instanceof Error ? err.message : String(err) };
2008
2076
  }
2009
2077
  });
2078
+ // Show file in OS file manager (Finder on macOS, Explorer on Windows)
2079
+ electron_1.ipcMain.handle('shell:show-in-folder', async (_event, filepath) => {
2080
+ try {
2081
+ if (!isPathSafe(filepath)) {
2082
+ return { success: false, error: 'Invalid file path' };
2083
+ }
2084
+ const { shell } = require('electron');
2085
+ shell.showItemInFolder(filepath);
2086
+ return { success: true };
2087
+ }
2088
+ catch (err) {
2089
+ return { success: false, error: err instanceof Error ? err.message : String(err) };
2090
+ }
2091
+ });
2010
2092
  // Thumbnail cache: generate 256px thumbnails for gallery
2011
2093
  // thumbnailCache is declared at module level above
2012
2094
  electron_1.ipcMain.handle('capture:get-thumbnail', async (_event, imagePath) => {
@@ -1 +1 @@
1
- {"version":3,"file":"active-window.d.ts","sourceRoot":"","sources":["../../../electron/modules/active-window.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAID,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAuBrE"}
1
+ {"version":3,"file":"active-window.d.ts","sourceRoot":"","sources":["../../../electron/modules/active-window.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAID,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CA+BrE"}
@@ -39,8 +39,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getActiveWindowInfo = getActiveWindowInfo;
40
40
  // Detects the currently active window for capture metadata
41
41
  const logger_1 = __importDefault(require("../logger"));
42
+ const platform_1 = require("../core/platform");
42
43
  let activeWinErrorLogged = false;
43
44
  async function getActiveWindowInfo() {
45
+ // active-win is a native module compiled for Electron's Node.js.
46
+ // In headless mode (system Node.js), loading the native binding crashes
47
+ // at the C++ level (NODE_MODULE_VERSION mismatch) which can't be caught
48
+ // by try/catch. Skip it entirely outside Electron.
49
+ if (!(0, platform_1.getPlatform)().isElectron()) {
50
+ return { appName: null, windowTitle: null };
51
+ }
44
52
  try {
45
53
  // active-win is ESM-only, use dynamic import
46
54
  const activeWin = await Promise.resolve().then(() => __importStar(require('active-win')));
@@ -1 +1 @@
1
- {"version":3,"file":"active-window.js","sourceRoot":"","sources":["../../../electron/modules/active-window.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,kDAuBC;AAjCD,2DAA2D;AAC3D,uDAA4B;AAO5B,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAE1B,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC;QACH,6CAA6C;QAC7C,MAAM,SAAS,GAAG,wDAAa,YAAY,GAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,MAAM,EAAE,CAAC;YACX,oBAAoB,GAAG,KAAK,CAAC,CAAC,mBAAmB;YACjD,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI;gBACnC,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI;aAClC,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,gBAAG,CAAC,IAAI,CAAC,6DAA6D,EAAE,KAAK,CAAC,CAAC;YAC/E,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAClC,gBAAG,CAAC,IAAI,CAAC,6GAA6G,CAAC,CAAC;YAC1H,CAAC;YACD,oBAAoB,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"active-window.js","sourceRoot":"","sources":["../../../electron/modules/active-window.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,kDA+BC;AA1CD,2DAA2D;AAC3D,uDAA4B;AAC5B,+CAA+C;AAO/C,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAE1B,KAAK,UAAU,mBAAmB;IACvC,iEAAiE;IACjE,wEAAwE;IACxE,wEAAwE;IACxE,mDAAmD;IACnD,IAAI,CAAC,IAAA,sBAAW,GAAE,CAAC,UAAU,EAAE,EAAE,CAAC;QAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,6CAA6C;QAC7C,MAAM,SAAS,GAAG,wDAAa,YAAY,GAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,MAAM,EAAE,CAAC;YACX,oBAAoB,GAAG,KAAK,CAAC,CAAC,mBAAmB;YACjD,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI;gBACnC,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI;aAClC,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,gBAAG,CAAC,IAAI,CAAC,6DAA6D,EAAE,KAAK,CAAC,CAAC;YAC/E,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAClC,gBAAG,CAAC,IAAI,CAAC,6GAA6G,CAAC,CAAC;YAC1H,CAAC;YACD,oBAAoB,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC9C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../../../electron/modules/api-server.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AA2oBjF,wBAAgB,+BAA+B,IAAI,IAAI,CA8LtD;AA8hBD,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAmCpD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAOnD;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,YAAY,IAAI,eAAe,GAAG,IAAI,CAErD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
1
+ {"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../../../electron/modules/api-server.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AA2oBjF,wBAAgB,+BAA+B,IAAI,IAAI,CA6StD;AAgrBD,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAmCpD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAOnD;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,YAAY,IAAI,eAAe,GAAG,IAAI,CAErD;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}