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.
- package/SUPERBASED_SKILL.md +129 -34
- package/dist/electron/core/platform.d.ts +2 -0
- package/dist/electron/core/platform.d.ts.map +1 -1
- package/dist/electron/main.js +95 -13
- package/dist/electron/modules/active-window.d.ts.map +1 -1
- package/dist/electron/modules/active-window.js +8 -0
- package/dist/electron/modules/active-window.js.map +1 -1
- package/dist/electron/modules/api-server.d.ts.map +1 -1
- package/dist/electron/modules/api-server.js +232 -4
- package/dist/electron/modules/api-server.js.map +1 -1
- package/dist/electron/modules/azure-speech-realtime.d.ts +13 -3
- package/dist/electron/modules/azure-speech-realtime.d.ts.map +1 -1
- package/dist/electron/modules/azure-speech-realtime.js +187 -54
- package/dist/electron/modules/azure-speech-realtime.js.map +1 -1
- package/dist/electron/modules/capture.d.ts.map +1 -1
- package/dist/electron/modules/capture.js +27 -8
- package/dist/electron/modules/capture.js.map +1 -1
- package/dist/electron/modules/dictation.d.ts +2 -0
- package/dist/electron/modules/dictation.d.ts.map +1 -1
- package/dist/electron/modules/dictation.js +145 -20
- package/dist/electron/modules/dictation.js.map +1 -1
- package/dist/electron/modules/ocr.d.ts.map +1 -1
- package/dist/electron/modules/ocr.js +15 -3
- package/dist/electron/modules/ocr.js.map +1 -1
- package/dist/electron/modules/recording/capture-queue.d.ts.map +1 -1
- package/dist/electron/modules/recording/capture-queue.js +43 -10
- package/dist/electron/modules/recording/capture-queue.js.map +1 -1
- package/dist/electron/modules/recording/index.d.ts.map +1 -1
- package/dist/electron/modules/recording/index.js +12 -6
- package/dist/electron/modules/recording/index.js.map +1 -1
- package/dist/electron/modules/recording/monitor-analyzer.d.ts +40 -0
- package/dist/electron/modules/recording/monitor-analyzer.d.ts.map +1 -0
- package/dist/electron/modules/recording/monitor-analyzer.js +220 -0
- package/dist/electron/modules/recording/monitor-analyzer.js.map +1 -0
- package/dist/electron/modules/recording/providers/change-detect-provider.d.ts +28 -0
- package/dist/electron/modules/recording/providers/change-detect-provider.d.ts.map +1 -0
- package/dist/electron/modules/recording/providers/change-detect-provider.js +181 -0
- package/dist/electron/modules/recording/providers/change-detect-provider.js.map +1 -0
- package/dist/electron/modules/recording/providers/provider-factory.d.ts +8 -2
- package/dist/electron/modules/recording/providers/provider-factory.d.ts.map +1 -1
- package/dist/electron/modules/recording/providers/provider-factory.js +33 -12
- package/dist/electron/modules/recording/providers/provider-factory.js.map +1 -1
- package/dist/electron/modules/recording/providers/uiohook-provider.d.ts.map +1 -1
- package/dist/electron/modules/recording/providers/uiohook-provider.js +9 -5
- package/dist/electron/modules/recording/providers/uiohook-provider.js.map +1 -1
- package/dist/electron/modules/recording/recording-session.d.ts +5 -1
- package/dist/electron/modules/recording/recording-session.d.ts.map +1 -1
- package/dist/electron/modules/recording/recording-session.js +78 -6
- package/dist/electron/modules/recording/recording-session.js.map +1 -1
- package/dist/electron/modules/recording/trigger-engine.d.ts.map +1 -1
- package/dist/electron/modules/recording/trigger-engine.js +10 -3
- package/dist/electron/modules/recording/trigger-engine.js.map +1 -1
- package/dist/electron/modules/store.js +2 -2
- package/dist/electron/modules/store.js.map +1 -1
- package/dist/electron/modules/uiohook-manager.d.ts +19 -0
- package/dist/electron/modules/uiohook-manager.d.ts.map +1 -0
- package/dist/electron/modules/uiohook-manager.js +101 -0
- package/dist/electron/modules/uiohook-manager.js.map +1 -0
- package/dist/headless/electron/modules/active-window.js +8 -0
- package/dist/headless/electron/modules/api-server.js +137 -3
- package/dist/headless/electron/modules/azure-speech-realtime.js +187 -54
- package/dist/headless/electron/modules/dictation.js +122 -0
- package/dist/headless/headless/dictation-hotkey.js +212 -47
- package/dist/headless/headless/dictation-overlay.js +218 -0
- package/dist/headless/headless/mic-capture.js +95 -1
- package/dist/headless/headless/platform-headless.js +103 -3
- package/dist/headless/headless/win32-text-injector.js +359 -0
- package/dist/headless/mic-capture.d.ts +21 -1
- package/dist/headless/mic-capture.d.ts.map +1 -1
- package/dist/headless/mic-capture.js +95 -1
- package/dist/headless/mic-capture.js.map +1 -1
- package/dist/shared/constants.d.ts +1 -1
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/recording-types.d.ts +12 -0
- package/dist/shared/recording-types.d.ts.map +1 -1
- package/mcp-server/dist/api-client.js +9 -0
- package/mcp-server/dist/index.js +91 -6
- package/package.json +2 -2
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Floating overlay indicator for headless dictation (Windows).
|
|
3
|
+
// Pre-spawns a PowerShell/WinForms process that shows a small always-on-top
|
|
4
|
+
// pill when a signal file exists, and hides it when removed.
|
|
5
|
+
// This avoids the keyboard input pipeline entirely — no modifier key conflicts.
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.initOverlay = initOverlay;
|
|
44
|
+
exports.showOverlay = showOverlay;
|
|
45
|
+
exports.hideOverlay = hideOverlay;
|
|
46
|
+
exports.shutdownOverlay = shutdownOverlay;
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const os = __importStar(require("os"));
|
|
50
|
+
const child_process_1 = require("child_process");
|
|
51
|
+
const file_logger_1 = __importDefault(require("../electron/core/file-logger"));
|
|
52
|
+
const SIGNAL_FILE = path.join(os.tmpdir(), 'superbased-dictation.signal');
|
|
53
|
+
const EXIT_FILE = path.join(os.tmpdir(), 'superbased-dictation-exit.signal');
|
|
54
|
+
let overlayProcess = null;
|
|
55
|
+
let ready = false;
|
|
56
|
+
function initOverlay() {
|
|
57
|
+
if (process.platform !== 'win32')
|
|
58
|
+
return; // Windows only for now
|
|
59
|
+
// Clean up stale signal files
|
|
60
|
+
try {
|
|
61
|
+
fs.unlinkSync(SIGNAL_FILE);
|
|
62
|
+
}
|
|
63
|
+
catch { /* ignore */ }
|
|
64
|
+
try {
|
|
65
|
+
fs.unlinkSync(EXIT_FILE);
|
|
66
|
+
}
|
|
67
|
+
catch { /* ignore */ }
|
|
68
|
+
const scriptPath = path.join(os.tmpdir(), 'superbased-overlay.ps1');
|
|
69
|
+
fs.writeFileSync(scriptPath, OVERLAY_PS1);
|
|
70
|
+
overlayProcess = (0, child_process_1.spawn)('powershell', [
|
|
71
|
+
'-ExecutionPolicy', 'Bypass',
|
|
72
|
+
'-WindowStyle', 'Hidden',
|
|
73
|
+
'-File', scriptPath,
|
|
74
|
+
SIGNAL_FILE,
|
|
75
|
+
EXIT_FILE,
|
|
76
|
+
], {
|
|
77
|
+
stdio: 'ignore',
|
|
78
|
+
detached: false,
|
|
79
|
+
windowsHide: true,
|
|
80
|
+
});
|
|
81
|
+
overlayProcess.on('error', (err) => {
|
|
82
|
+
file_logger_1.default.warn('[Overlay] Failed to spawn:', err);
|
|
83
|
+
overlayProcess = null;
|
|
84
|
+
});
|
|
85
|
+
overlayProcess.on('exit', () => {
|
|
86
|
+
overlayProcess = null;
|
|
87
|
+
ready = false;
|
|
88
|
+
});
|
|
89
|
+
// Allow time for PowerShell + WinForms init (~2-3s)
|
|
90
|
+
setTimeout(() => { if (overlayProcess)
|
|
91
|
+
ready = true; }, 3000);
|
|
92
|
+
file_logger_1.default.info('[Overlay] Pre-spawned dictation overlay process');
|
|
93
|
+
}
|
|
94
|
+
function showOverlay(mode = 'recording') {
|
|
95
|
+
if (!ready || !overlayProcess)
|
|
96
|
+
return;
|
|
97
|
+
try {
|
|
98
|
+
fs.writeFileSync(SIGNAL_FILE, mode);
|
|
99
|
+
}
|
|
100
|
+
catch { /* ignore */ }
|
|
101
|
+
}
|
|
102
|
+
function hideOverlay() {
|
|
103
|
+
try {
|
|
104
|
+
fs.unlinkSync(SIGNAL_FILE);
|
|
105
|
+
}
|
|
106
|
+
catch { /* ignore */ }
|
|
107
|
+
}
|
|
108
|
+
function shutdownOverlay() {
|
|
109
|
+
// Signal the overlay to exit gracefully
|
|
110
|
+
try {
|
|
111
|
+
fs.writeFileSync(EXIT_FILE, 'exit');
|
|
112
|
+
}
|
|
113
|
+
catch { /* ignore */ }
|
|
114
|
+
try {
|
|
115
|
+
fs.unlinkSync(SIGNAL_FILE);
|
|
116
|
+
}
|
|
117
|
+
catch { /* ignore */ }
|
|
118
|
+
if (overlayProcess) {
|
|
119
|
+
const proc = overlayProcess;
|
|
120
|
+
overlayProcess = null;
|
|
121
|
+
// Give it time to exit gracefully, then force kill
|
|
122
|
+
setTimeout(() => { try {
|
|
123
|
+
proc.kill();
|
|
124
|
+
}
|
|
125
|
+
catch { /* ignore */ } }, 2000);
|
|
126
|
+
}
|
|
127
|
+
ready = false;
|
|
128
|
+
}
|
|
129
|
+
// PowerShell script that creates a WinForms overlay window.
|
|
130
|
+
// Uses file-based signaling: poll signal file every 150ms.
|
|
131
|
+
// - File exists with "recording" → show red "Recording..." pill
|
|
132
|
+
// - File exists with "transcribing" → show yellow "Transcribing..." pill
|
|
133
|
+
// - File deleted → hide
|
|
134
|
+
// - Exit file exists → exit process
|
|
135
|
+
const OVERLAY_PS1 = `param([string]$SignalFile, [string]$ExitFile)
|
|
136
|
+
|
|
137
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
138
|
+
Add-Type -AssemblyName System.Drawing
|
|
139
|
+
|
|
140
|
+
$w = 190; $h = 38
|
|
141
|
+
|
|
142
|
+
$form = New-Object System.Windows.Forms.Form
|
|
143
|
+
$form.FormBorderStyle = 'None'
|
|
144
|
+
$form.TopMost = $true
|
|
145
|
+
$form.ShowInTaskbar = $false
|
|
146
|
+
$form.Size = New-Object System.Drawing.Size($w, $h)
|
|
147
|
+
$form.StartPosition = 'Manual'
|
|
148
|
+
$form.Opacity = 0.94
|
|
149
|
+
$form.BackColor = [System.Drawing.Color]::FromArgb(28, 28, 42)
|
|
150
|
+
|
|
151
|
+
# Position at top-center of primary screen
|
|
152
|
+
$scr = [System.Windows.Forms.Screen]::PrimaryScreen
|
|
153
|
+
$form.Location = New-Object System.Drawing.Point(
|
|
154
|
+
[int](($scr.WorkingArea.Width - $w) / 2), 10
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Rounded corners
|
|
158
|
+
$gp = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
159
|
+
$r = 14
|
|
160
|
+
$gp.AddArc(0, 0, $r, $r, 180, 90)
|
|
161
|
+
$gp.AddArc($w - $r - 1, 0, $r, $r, 270, 90)
|
|
162
|
+
$gp.AddArc($w - $r - 1, $h - $r - 1, $r, $r, 0, 90)
|
|
163
|
+
$gp.AddArc(0, $h - $r - 1, $r, $r, 90, 90)
|
|
164
|
+
$gp.CloseFigure()
|
|
165
|
+
$form.Region = New-Object System.Drawing.Region($gp)
|
|
166
|
+
|
|
167
|
+
$lbl = New-Object System.Windows.Forms.Label
|
|
168
|
+
$lbl.ForeColor = [System.Drawing.Color]::White
|
|
169
|
+
$lbl.Font = New-Object System.Drawing.Font("Segoe UI Semibold", 10.5)
|
|
170
|
+
$lbl.AutoSize = $false
|
|
171
|
+
$lbl.Dock = 'Fill'
|
|
172
|
+
$lbl.TextAlign = 'MiddleCenter'
|
|
173
|
+
$lbl.BackColor = [System.Drawing.Color]::Transparent
|
|
174
|
+
$form.Controls.Add($lbl)
|
|
175
|
+
|
|
176
|
+
$st = @{ vis = $false; f = 0 }
|
|
177
|
+
$dots = @([char]0x25CF, [char]0x25C9, [char]0x25CF, [char]0x25CB)
|
|
178
|
+
|
|
179
|
+
$tmr = New-Object System.Windows.Forms.Timer
|
|
180
|
+
$tmr.Interval = 150
|
|
181
|
+
$tmr.Add_Tick({
|
|
182
|
+
# Check exit signal
|
|
183
|
+
if ([IO.File]::Exists($ExitFile)) {
|
|
184
|
+
try { [IO.File]::Delete($ExitFile) } catch {}
|
|
185
|
+
$tmr.Stop(); $form.Close(); return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if ([IO.File]::Exists($SignalFile)) {
|
|
189
|
+
$m = 'recording'
|
|
190
|
+
try { $m = [IO.File]::ReadAllText($SignalFile).Trim() } catch {}
|
|
191
|
+
|
|
192
|
+
if (-not $st.vis) {
|
|
193
|
+
$form.Show(); $form.BringToFront()
|
|
194
|
+
$st.vis = $true; $st.f = 0
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if ($m -eq 'transcribing') {
|
|
198
|
+
$form.BackColor = [System.Drawing.Color]::FromArgb(38, 32, 14)
|
|
199
|
+
$lbl.ForeColor = [System.Drawing.Color]::FromArgb(255, 210, 80)
|
|
200
|
+
$spin = @([char]0x2836, [char]0x2834, [char]0x2826, [char]0x2807, [char]0x280B, [char]0x2819, [char]0x2838, [char]0x2830)
|
|
201
|
+
$lbl.Text = $spin[$st.f % 8] + ' Transcribing...'
|
|
202
|
+
} else {
|
|
203
|
+
$form.BackColor = [System.Drawing.Color]::FromArgb(38, 14, 14)
|
|
204
|
+
$lbl.ForeColor = [System.Drawing.Color]::FromArgb(255, 90, 90)
|
|
205
|
+
$d = $dots[$st.f % 4]
|
|
206
|
+
$lbl.Text = "$d Recording..."
|
|
207
|
+
}
|
|
208
|
+
$st.f++
|
|
209
|
+
} elseif ($st.vis) {
|
|
210
|
+
$form.Hide()
|
|
211
|
+
$st.vis = $false
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
# Hide immediately on shown, then start polling
|
|
216
|
+
$form.Add_Shown({ $form.Hide(); $tmr.Start() })
|
|
217
|
+
[System.Windows.Forms.Application]::Run($form)
|
|
218
|
+
`;
|
|
@@ -48,6 +48,11 @@ exports.isMicAvailable = isMicAvailable;
|
|
|
48
48
|
exports.getMicBackend = getMicBackend;
|
|
49
49
|
exports.startRecording = startRecording;
|
|
50
50
|
exports.recordForDuration = recordForDuration;
|
|
51
|
+
exports.startWarmMic = startWarmMic;
|
|
52
|
+
exports.startWarmCapture = startWarmCapture;
|
|
53
|
+
exports.stopWarmCapture = stopWarmCapture;
|
|
54
|
+
exports.shutdownWarmMic = shutdownWarmMic;
|
|
55
|
+
exports.isWarmMicRunning = isWarmMicRunning;
|
|
51
56
|
exports.prewarm = prewarm;
|
|
52
57
|
const childProcess = __importStar(require("child_process"));
|
|
53
58
|
const os = __importStar(require("os"));
|
|
@@ -300,8 +305,97 @@ async function recordForDuration(seconds) {
|
|
|
300
305
|
await new Promise((r) => setTimeout(r, seconds * 1000));
|
|
301
306
|
return handle.stop();
|
|
302
307
|
}
|
|
308
|
+
// ── Warm Mic (persistent ffmpeg for instant dictation start) ──
|
|
309
|
+
let warmProc = null;
|
|
310
|
+
let warmPcmCallback = null;
|
|
311
|
+
let warmHeaderSkipped = false;
|
|
312
|
+
let warmActive = false;
|
|
303
313
|
/**
|
|
304
|
-
*
|
|
314
|
+
* Start a persistent ffmpeg process that keeps the mic open.
|
|
315
|
+
* PCM chunks are only forwarded when startWarmCapture() is called.
|
|
316
|
+
* Eliminates the ~800ms dshow device open delay on each dictation.
|
|
317
|
+
*/
|
|
318
|
+
function startWarmMic() {
|
|
319
|
+
if (warmProc || detectBackend() !== 'ffmpeg')
|
|
320
|
+
return;
|
|
321
|
+
let inputArgs;
|
|
322
|
+
if (process.platform === 'win32') {
|
|
323
|
+
const micName = detectWindowsMicrophone();
|
|
324
|
+
inputArgs = ['-f', 'dshow', '-i', `audio=${micName}`];
|
|
325
|
+
}
|
|
326
|
+
else if (process.platform === 'darwin') {
|
|
327
|
+
inputArgs = ['-f', 'avfoundation', '-i', ':default'];
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
inputArgs = ['-f', 'pulse', '-i', 'default'];
|
|
331
|
+
}
|
|
332
|
+
const args = [
|
|
333
|
+
'-hide_banner', '-loglevel', 'error',
|
|
334
|
+
'-y',
|
|
335
|
+
...inputArgs,
|
|
336
|
+
'-ar', '16000', '-ac', '1', '-f', 'wav',
|
|
337
|
+
'pipe:1',
|
|
338
|
+
];
|
|
339
|
+
warmProc = childProcess.spawn(ffmpegPath, args, { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
340
|
+
warmHeaderSkipped = false;
|
|
341
|
+
warmProc.stdout?.on('data', (chunk) => {
|
|
342
|
+
if (!warmActive || !warmPcmCallback)
|
|
343
|
+
return;
|
|
344
|
+
// Skip 44-byte WAV header on first chunk
|
|
345
|
+
if (!warmHeaderSkipped) {
|
|
346
|
+
warmHeaderSkipped = true;
|
|
347
|
+
if (chunk.length > 44) {
|
|
348
|
+
warmPcmCallback(chunk.subarray(44));
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
warmPcmCallback(chunk);
|
|
353
|
+
});
|
|
354
|
+
warmProc.on('close', () => { warmProc = null; });
|
|
355
|
+
warmProc.on('error', () => { warmProc = null; });
|
|
356
|
+
// Suppress stderr noise
|
|
357
|
+
warmProc.stderr?.on('data', () => { });
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Start forwarding PCM chunks from the warm mic to the callback.
|
|
361
|
+
* Returns immediately — no ffmpeg spawn delay.
|
|
362
|
+
*/
|
|
363
|
+
function startWarmCapture(callback) {
|
|
364
|
+
warmPcmCallback = callback;
|
|
365
|
+
warmActive = true;
|
|
366
|
+
// Reset header skip for fresh WAV header detection if mic was restarted
|
|
367
|
+
if (!warmProc) {
|
|
368
|
+
startWarmMic();
|
|
369
|
+
warmHeaderSkipped = false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Stop forwarding PCM chunks but keep the warm mic alive.
|
|
374
|
+
*/
|
|
375
|
+
function stopWarmCapture() {
|
|
376
|
+
warmActive = false;
|
|
377
|
+
warmPcmCallback = null;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Shut down the warm mic entirely.
|
|
381
|
+
*/
|
|
382
|
+
function shutdownWarmMic() {
|
|
383
|
+
warmActive = false;
|
|
384
|
+
warmPcmCallback = null;
|
|
385
|
+
if (warmProc) {
|
|
386
|
+
try {
|
|
387
|
+
warmProc.stdin?.write('q');
|
|
388
|
+
}
|
|
389
|
+
catch { /* ignore */ }
|
|
390
|
+
warmProc.kill('SIGTERM');
|
|
391
|
+
warmProc = null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function isWarmMicRunning() {
|
|
395
|
+
return warmProc !== null;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Pre-warm: detect backend + cache mic device name + start warm mic on startup.
|
|
305
399
|
* Call this early to avoid detection latency on first dictation.
|
|
306
400
|
*/
|
|
307
401
|
function prewarm() {
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.headlessPlatform = void 0;
|
|
39
39
|
const os = __importStar(require("os"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
41
42
|
const childProcess = __importStar(require("child_process"));
|
|
42
43
|
const paths_1 = require("../electron/core/paths");
|
|
43
44
|
function getVersion() {
|
|
@@ -112,9 +113,108 @@ exports.headlessPlatform = {
|
|
|
112
113
|
setClipboardText: clipboardWrite,
|
|
113
114
|
getClipboardImage: () => null, // Not supported in headless without Electron
|
|
114
115
|
listWindows: async () => {
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
|
|
116
|
+
// List ALL visible windows using platform-specific commands.
|
|
117
|
+
// On Windows, Get-Process only returns one MainWindowTitle per process,
|
|
118
|
+
// so Electron apps with multiple windows only show up once. We use
|
|
119
|
+
// Win32 EnumWindows via inline C# to enumerate every top-level window.
|
|
120
|
+
try {
|
|
121
|
+
if (process.platform === 'win32') {
|
|
122
|
+
// Write PowerShell script to temp file to avoid quote-escaping issues
|
|
123
|
+
// with inline C# code passed via -command argument.
|
|
124
|
+
const tmpScript = path.join(os.tmpdir(), 'superbased-winlist.ps1');
|
|
125
|
+
fs.writeFileSync(tmpScript, `
|
|
126
|
+
Add-Type -TypeDefinition @'
|
|
127
|
+
using System; using System.Text; using System.Runtime.InteropServices; using System.Collections.Generic;
|
|
128
|
+
public class WinEnum {
|
|
129
|
+
[DllImport("user32.dll")] static extern bool EnumWindows(CallBack cb, int lp);
|
|
130
|
+
[DllImport("user32.dll")] static extern int GetWindowText(IntPtr h, StringBuilder s, int n);
|
|
131
|
+
[DllImport("user32.dll")] static extern bool IsWindowVisible(IntPtr h);
|
|
132
|
+
[DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr h);
|
|
133
|
+
[DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);
|
|
134
|
+
[DllImport("user32.dll")] static extern bool IsIconic(IntPtr h);
|
|
135
|
+
delegate bool CallBack(IntPtr h, int lp);
|
|
136
|
+
public static List<long> handles = new List<long>();
|
|
137
|
+
public static List<int[]> pids = new List<int[]>();
|
|
138
|
+
public static List<string> titles = new List<string>();
|
|
139
|
+
public static List<bool> minimized = new List<bool>();
|
|
140
|
+
public static void Run() {
|
|
141
|
+
EnumWindows((h, l) => {
|
|
142
|
+
if (IsWindowVisible(h) && GetWindowTextLength(h) > 0) {
|
|
143
|
+
var t = new StringBuilder(512); GetWindowText(h, t, 512);
|
|
144
|
+
uint pid; GetWindowThreadProcessId(h, out pid);
|
|
145
|
+
handles.Add(h.ToInt64()); pids.Add(new int[]{(int)pid});
|
|
146
|
+
titles.Add(t.ToString()); minimized.Add(IsIconic(h));
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}, 0);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
'@
|
|
153
|
+
[WinEnum]::Run()
|
|
154
|
+
$r = @(); for($i=0;$i -lt [WinEnum]::titles.Count;$i++){
|
|
155
|
+
$r += [PSCustomObject]@{Hwnd=[WinEnum]::handles[$i];Id=[WinEnum]::pids[$i][0];Title=[WinEnum]::titles[$i];Minimized=[WinEnum]::minimized[$i]}
|
|
156
|
+
}
|
|
157
|
+
$r | ConvertTo-Json -Compress
|
|
158
|
+
`);
|
|
159
|
+
const output = childProcess.execSync(`powershell -ExecutionPolicy Bypass -File "${tmpScript}"`, { encoding: 'utf-8', timeout: 8000 });
|
|
160
|
+
try {
|
|
161
|
+
fs.unlinkSync(tmpScript);
|
|
162
|
+
}
|
|
163
|
+
catch { /* cleanup */ }
|
|
164
|
+
const parsed = JSON.parse(output.trim());
|
|
165
|
+
const items = Array.isArray(parsed) ? parsed : [parsed];
|
|
166
|
+
return items
|
|
167
|
+
.filter((w) => w.Title && w.Title.trim())
|
|
168
|
+
.map((w) => ({
|
|
169
|
+
id: String(w.Id),
|
|
170
|
+
name: w.Title,
|
|
171
|
+
hwnd: String(w.Hwnd),
|
|
172
|
+
minimized: w.Minimized,
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
else if (process.platform === 'darwin') {
|
|
176
|
+
// List all visible windows with their app name and window title
|
|
177
|
+
const output = childProcess.execSync(`osascript -e '
|
|
178
|
+
set output to ""
|
|
179
|
+
tell application "System Events"
|
|
180
|
+
set procs to every process whose visible is true
|
|
181
|
+
repeat with p in procs
|
|
182
|
+
set pName to name of p
|
|
183
|
+
set pId to unix id of p
|
|
184
|
+
try
|
|
185
|
+
set wins to every window of p
|
|
186
|
+
repeat with w in wins
|
|
187
|
+
set wTitle to name of w
|
|
188
|
+
set output to output & pId & "\\t" & pName & " - " & wTitle & "\\n"
|
|
189
|
+
end repeat
|
|
190
|
+
end try
|
|
191
|
+
end repeat
|
|
192
|
+
end tell
|
|
193
|
+
return output'`, { encoding: 'utf-8', timeout: 8000 });
|
|
194
|
+
return output.trim().split('\n').filter(Boolean).map((line) => {
|
|
195
|
+
const tabIdx = line.indexOf('\t');
|
|
196
|
+
if (tabIdx === -1)
|
|
197
|
+
return { id: '0', name: line.trim() };
|
|
198
|
+
return {
|
|
199
|
+
id: line.substring(0, tabIdx).trim(),
|
|
200
|
+
name: line.substring(tabIdx + 1).trim(),
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// Linux: wmctrl or xdotool
|
|
206
|
+
const output = childProcess.execSync('wmctrl -l 2>/dev/null || xdotool search --name "" getwindowname 2>/dev/null || echo ""', {
|
|
207
|
+
encoding: 'utf-8', timeout: 5000,
|
|
208
|
+
});
|
|
209
|
+
return output.trim().split('\n').filter(Boolean).map((line, i) => ({
|
|
210
|
+
id: String(i),
|
|
211
|
+
name: line.replace(/^0x[\da-f]+\s+\d+\s+\S+\s+/i, '').trim() || line.trim(),
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
118
218
|
},
|
|
119
219
|
openUrl,
|
|
120
220
|
isElectron: () => false,
|