Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
528dfe01a1 | ||
|
|
fb6c8e3fc0 | ||
|
|
76d6fc2749 | ||
|
|
2f013b4751 | ||
|
|
66dce4415a | ||
|
|
6460349fc7 | ||
|
|
6926c27f20 | ||
|
|
cbf82f9317 | ||
|
|
bf9ec15912 | ||
|
|
01b8415a02 | ||
|
|
4edfaf4906 |
@@ -10,6 +10,8 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.cs.disable-library-validation</key>
|
<key>com.apple.security.cs.disable-library-validation</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.security.device.audio-input</key>
|
<key>com.apple.security.device.audio-input</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.device.microphone</key>
|
<key>com.apple.security.device.microphone</key>
|
||||||
|
|||||||
+33
-8
@@ -1,5 +1,7 @@
|
|||||||
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
|
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
|
||||||
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
|
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
packagerConfig: {
|
packagerConfig: {
|
||||||
@@ -7,18 +9,37 @@ module.exports = {
|
|||||||
extraResource: ['./src/assets/SystemAudioDump'],
|
extraResource: ['./src/assets/SystemAudioDump'],
|
||||||
name: 'Cheating Daddy',
|
name: 'Cheating Daddy',
|
||||||
icon: 'src/assets/logo',
|
icon: 'src/assets/logo',
|
||||||
|
// Fix executable permissions after packaging
|
||||||
|
afterCopy: [
|
||||||
|
(buildPath, electronVersion, platform, arch, callback) => {
|
||||||
|
if (platform === 'darwin') {
|
||||||
|
const systemAudioDump = path.join(buildPath, '..', 'Resources', 'SystemAudioDump');
|
||||||
|
if (fs.existsSync(systemAudioDump)) {
|
||||||
|
try {
|
||||||
|
fs.chmodSync(systemAudioDump, 0o755);
|
||||||
|
console.log('✓ Set executable permissions for SystemAudioDump');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('✗ Failed to set permissions:', err.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('SystemAudioDump not found at:', systemAudioDump);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
],
|
||||||
// use `security find-identity -v -p codesigning` to find your identity
|
// use `security find-identity -v -p codesigning` to find your identity
|
||||||
// for macos signing
|
// for macos signing
|
||||||
// also fuck apple
|
// Disabled for local builds - ad-hoc signing causes issues
|
||||||
// osxSign: {
|
// osxSign: {
|
||||||
// identity: '<paste your identity here>',
|
// identity: '-', // ad-hoc signing (no Apple Developer account needed)
|
||||||
// optionsForFile: (filePath) => {
|
// optionsForFile: (filePath) => {
|
||||||
// return {
|
// return {
|
||||||
// entitlements: 'entitlements.plist',
|
// entitlements: 'entitlements.plist',
|
||||||
// };
|
// };
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// notarize if off cuz i ran this for 6 hours and it still didnt finish
|
// notarize is off - requires Apple Developer account
|
||||||
// osxNotarize: {
|
// osxNotarize: {
|
||||||
// appleId: 'your apple id',
|
// appleId: 'your apple id',
|
||||||
// appleIdPassword: 'app specific password',
|
// appleIdPassword: 'app specific password',
|
||||||
@@ -40,6 +61,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
name: '@electron-forge/maker-dmg',
|
name: '@electron-forge/maker-dmg',
|
||||||
platforms: ['darwin'],
|
platforms: ['darwin'],
|
||||||
|
config: {
|
||||||
|
name: 'CheatingDaddy',
|
||||||
|
format: 'ULFO',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '@reforged/maker-appimage',
|
name: '@reforged/maker-appimage',
|
||||||
|
|||||||
+4
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "cheating-daddy",
|
"name": "cheating-daddy",
|
||||||
"productName": "cheating-daddy",
|
"productName": "cheating-daddy",
|
||||||
"version": "0.5.0",
|
"version": "0.5.11",
|
||||||
"description": "cheating daddy",
|
"description": "cheating daddy",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
"cheating daddy ai assistant for interviews"
|
"cheating daddy ai assistant for interviews"
|
||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "sohzm",
|
"name": "ShiftyX1",
|
||||||
"email": "sohambharambe9@gmail.com"
|
"email": "lead@pyserve.org"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
"@electron-forge/plugin-auto-unpack-natives": "^7.11.1",
|
"@electron-forge/plugin-auto-unpack-natives": "^7.11.1",
|
||||||
"@electron-forge/plugin-fuses": "^7.11.1",
|
"@electron-forge/plugin-fuses": "^7.11.1",
|
||||||
"@electron/fuses": "^2.0.0",
|
"@electron/fuses": "^2.0.0",
|
||||||
|
"@electron/osx-sign": "^2.3.0",
|
||||||
"@reforged/maker-appimage": "^5.1.1",
|
"@reforged/maker-appimage": "^5.1.1",
|
||||||
"electron": "^39.2.7"
|
"electron": "^39.2.7"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+17
@@ -48,6 +48,9 @@ importers:
|
|||||||
'@electron/fuses':
|
'@electron/fuses':
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
|
'@electron/osx-sign':
|
||||||
|
specifier: ^2.3.0
|
||||||
|
version: 2.3.0
|
||||||
'@reforged/maker-appimage':
|
'@reforged/maker-appimage':
|
||||||
specifier: ^5.1.1
|
specifier: ^5.1.1
|
||||||
version: 5.1.1
|
version: 5.1.1
|
||||||
@@ -173,6 +176,11 @@ packages:
|
|||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
'@electron/osx-sign@2.3.0':
|
||||||
|
resolution: {integrity: sha512-qh/BkWUHITP2W1grtCWn8Pm4EML3q1Rfo2tnd/KHo+f1le5gAYotBc6yEfK6X2VHyN21mPZ3CjvOiYOwjimBlA==}
|
||||||
|
engines: {node: '>=22.12.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
'@electron/packager@18.4.4':
|
'@electron/packager@18.4.4':
|
||||||
resolution: {integrity: sha512-fTUCmgL25WXTcFpM1M72VmFP8w3E4d+KNzWxmTDRpvwkfn/S206MAtM2cy0GF78KS9AwASMOUmlOIzCHeNxcGQ==}
|
resolution: {integrity: sha512-fTUCmgL25WXTcFpM1M72VmFP8w3E4d+KNzWxmTDRpvwkfn/S206MAtM2cy0GF78KS9AwASMOUmlOIzCHeNxcGQ==}
|
||||||
engines: {node: '>= 16.13.0'}
|
engines: {node: '>= 16.13.0'}
|
||||||
@@ -2487,6 +2495,15 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
'@electron/osx-sign@2.3.0':
|
||||||
|
dependencies:
|
||||||
|
debug: 4.4.3
|
||||||
|
isbinaryfile: 4.0.10
|
||||||
|
plist: 3.1.0
|
||||||
|
semver: 7.7.3
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
'@electron/packager@18.4.4':
|
'@electron/packager@18.4.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@electron/asar': 3.4.1
|
'@electron/asar': 3.4.1
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { HelpView } from '../views/HelpView.js';
|
|||||||
import { HistoryView } from '../views/HistoryView.js';
|
import { HistoryView } from '../views/HistoryView.js';
|
||||||
import { AssistantView } from '../views/AssistantView.js';
|
import { AssistantView } from '../views/AssistantView.js';
|
||||||
import { OnboardingView } from '../views/OnboardingView.js';
|
import { OnboardingView } from '../views/OnboardingView.js';
|
||||||
|
import { ScreenPickerDialog } from '../views/ScreenPickerDialog.js';
|
||||||
|
|
||||||
export class CheatingDaddyApp extends LitElement {
|
export class CheatingDaddyApp extends LitElement {
|
||||||
static styles = css`
|
static styles = css`
|
||||||
@@ -112,6 +113,8 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
_storageLoaded: { state: true },
|
_storageLoaded: { state: true },
|
||||||
aiProvider: { type: String },
|
aiProvider: { type: String },
|
||||||
modelInfo: { type: Object },
|
modelInfo: { type: Object },
|
||||||
|
showScreenPicker: { type: Boolean },
|
||||||
|
screenSources: { type: Array },
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -137,6 +140,8 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
this._storageLoaded = false;
|
this._storageLoaded = false;
|
||||||
this.aiProvider = 'gemini';
|
this.aiProvider = 'gemini';
|
||||||
this.modelInfo = { model: '', visionModel: '', whisperModel: '' };
|
this.modelInfo = { model: '', visionModel: '', whisperModel: '' };
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
this.screenSources = [];
|
||||||
|
|
||||||
// Load from storage
|
// Load from storage
|
||||||
this._loadFromStorage();
|
this._loadFromStorage();
|
||||||
@@ -549,6 +554,16 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
<div class="view-container">${this.renderCurrentView()}</div>
|
<div class="view-container">${this.renderCurrentView()}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
${this.showScreenPicker
|
||||||
|
? html`
|
||||||
|
<screen-picker-dialog
|
||||||
|
?visible=${this.showScreenPicker}
|
||||||
|
.sources=${this.screenSources}
|
||||||
|
@source-selected=${this.handleSourceSelected}
|
||||||
|
@cancelled=${this.handlePickerCancelled}
|
||||||
|
></screen-picker-dialog>
|
||||||
|
`
|
||||||
|
: ''}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -579,6 +594,44 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
|
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async showScreenPickerDialog() {
|
||||||
|
const { ipcRenderer } = window.require('electron');
|
||||||
|
const result = await ipcRenderer.invoke('get-screen-sources');
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
this.screenSources = result.sources;
|
||||||
|
this.showScreenPicker = true;
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this._screenPickerResolve = resolve;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error('Failed to get screen sources:', result.error);
|
||||||
|
return { cancelled: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleSourceSelected(event) {
|
||||||
|
const { source } = event.detail;
|
||||||
|
const { ipcRenderer } = window.require('electron');
|
||||||
|
|
||||||
|
// Tell main process which source was selected
|
||||||
|
await ipcRenderer.invoke('set-selected-source', source.id);
|
||||||
|
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
if (this._screenPickerResolve) {
|
||||||
|
this._screenPickerResolve({ source });
|
||||||
|
this._screenPickerResolve = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handlePickerCancelled() {
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
if (this._screenPickerResolve) {
|
||||||
|
this._screenPickerResolve({ cancelled: true });
|
||||||
|
this._screenPickerResolve = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('cheating-daddy-app', CheatingDaddyApp);
|
customElements.define('cheating-daddy-app', CheatingDaddyApp);
|
||||||
|
|||||||
@@ -170,6 +170,25 @@ export class HelpView extends LitElement {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.open-logs-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 14px;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.open-logs-btn:hover {
|
||||||
|
background: var(--hover-background);
|
||||||
|
}
|
||||||
|
|
||||||
.usage-steps {
|
.usage-steps {
|
||||||
counter-reset: step-counter;
|
counter-reset: step-counter;
|
||||||
}
|
}
|
||||||
@@ -442,9 +461,33 @@ export class HelpView extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
<div class="description">The AI listens to conversations and provides contextual assistance based on what it hears.</div>
|
<div class="description">The AI listens to conversations and provides contextual assistance based on what it hears.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="option-group">
|
||||||
|
<div class="option-label">
|
||||||
|
<span>Troubleshooting</span>
|
||||||
|
</div>
|
||||||
|
<div class="description" style="margin-bottom: 12px;">
|
||||||
|
If you're experiencing issues with audio capture or other features, check the application logs for diagnostic information.
|
||||||
|
</div>
|
||||||
|
<button class="open-logs-btn" @click=${this.openLogsFolder}>
|
||||||
|
📁 Open Logs Folder
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async openLogsFolder() {
|
||||||
|
try {
|
||||||
|
const { ipcRenderer } = require('electron');
|
||||||
|
const result = await ipcRenderer.invoke('open-logs-folder');
|
||||||
|
if (!result.success) {
|
||||||
|
console.error('Failed to open logs folder:', result.error);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error opening logs folder:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('help-view', HelpView);
|
customElements.define('help-view', HelpView);
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';
|
||||||
|
|
||||||
|
export class ScreenPickerDialog extends LitElement {
|
||||||
|
static properties = {
|
||||||
|
sources: { type: Array },
|
||||||
|
visible: { type: Boolean },
|
||||||
|
};
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.8);
|
||||||
|
z-index: 10000;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([visible]) {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog {
|
||||||
|
background: var(--background-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 24px;
|
||||||
|
max-width: 800px;
|
||||||
|
max-height: 80vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0 0 16px 0;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sources-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item {
|
||||||
|
background: var(--input-background);
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item:hover {
|
||||||
|
border-color: var(--border-default);
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item.selected {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-thumbnail {
|
||||||
|
width: 100%;
|
||||||
|
height: 120px;
|
||||||
|
object-fit: contain;
|
||||||
|
background: #1a1a1a;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-name {
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: var(--button-background);
|
||||||
|
color: var(--text-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
transition: background-color 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: white;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary:hover {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.sources = [];
|
||||||
|
this.visible = false;
|
||||||
|
this.selectedSource = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSource(source) {
|
||||||
|
this.selectedSource = source;
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
if (this.selectedSource) {
|
||||||
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('source-selected', {
|
||||||
|
detail: { source: this.selectedSource },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.dispatchEvent(new CustomEvent('cancelled'));
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<div class="dialog">
|
||||||
|
<h2>Choose screen or window to share</h2>
|
||||||
|
<div class="sources-grid">
|
||||||
|
${this.sources.map(
|
||||||
|
source => html`
|
||||||
|
<div
|
||||||
|
class="source-item ${this.selectedSource?.id === source.id ? 'selected' : ''}"
|
||||||
|
@click=${() => this.selectSource(source)}
|
||||||
|
>
|
||||||
|
<img class="source-thumbnail" src="${source.thumbnail}" alt="${source.name}" />
|
||||||
|
<div class="source-name">${source.name}</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<button @click=${this.cancel}>Cancel</button>
|
||||||
|
<button class="primary" @click=${this.confirm} ?disabled=${!this.selectedSource}>Share</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
customElements.define('screen-picker-dialog', ScreenPickerDialog);
|
||||||
@@ -6,6 +6,7 @@ const { app, BrowserWindow, shell, ipcMain } = require('electron');
|
|||||||
const { createWindow, updateGlobalShortcuts } = require('./utils/window');
|
const { createWindow, updateGlobalShortcuts } = require('./utils/window');
|
||||||
const { setupAIProviderIpcHandlers } = require('./utils/ai-provider-manager');
|
const { setupAIProviderIpcHandlers } = require('./utils/ai-provider-manager');
|
||||||
const { stopMacOSAudioCapture } = require('./utils/gemini');
|
const { stopMacOSAudioCapture } = require('./utils/gemini');
|
||||||
|
const { initLogger, closeLogger, getLogPath } = require('./utils/logger');
|
||||||
const storage = require('./storage');
|
const storage = require('./storage');
|
||||||
|
|
||||||
const geminiSessionRef = { current: null };
|
const geminiSessionRef = { current: null };
|
||||||
@@ -24,6 +25,10 @@ function createMainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
|
// Initialize file logger first
|
||||||
|
const logPath = initLogger();
|
||||||
|
console.log('App starting, log file:', logPath);
|
||||||
|
|
||||||
// Initialize storage (checks version, resets if needed)
|
// Initialize storage (checks version, resets if needed)
|
||||||
storage.initializeStorage();
|
storage.initializeStorage();
|
||||||
|
|
||||||
@@ -31,10 +36,22 @@ app.whenReady().then(async () => {
|
|||||||
setupAIProviderIpcHandlers(geminiSessionRef);
|
setupAIProviderIpcHandlers(geminiSessionRef);
|
||||||
setupStorageIpcHandlers();
|
setupStorageIpcHandlers();
|
||||||
setupGeneralIpcHandlers();
|
setupGeneralIpcHandlers();
|
||||||
|
|
||||||
|
// Add handler to get log path from renderer
|
||||||
|
ipcMain.handle('get-log-path', () => getLogPath());
|
||||||
|
|
||||||
|
// Add handler for renderer logs (so they go to the log file)
|
||||||
|
ipcMain.on('renderer-log', (event, { level, message }) => {
|
||||||
|
const prefix = '[RENDERER]';
|
||||||
|
if (level === 'error') console.error(prefix, message);
|
||||||
|
else if (level === 'warn') console.warn(prefix, message);
|
||||||
|
else console.log(prefix, message);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
stopMacOSAudioCapture();
|
stopMacOSAudioCapture();
|
||||||
|
closeLogger();
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
@@ -42,6 +59,7 @@ app.on('window-all-closed', () => {
|
|||||||
|
|
||||||
app.on('before-quit', () => {
|
app.on('before-quit', () => {
|
||||||
stopMacOSAudioCapture();
|
stopMacOSAudioCapture();
|
||||||
|
closeLogger();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
@@ -284,6 +302,18 @@ function setupGeneralIpcHandlers() {
|
|||||||
return app.getVersion();
|
return app.getVersion();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('open-logs-folder', async () => {
|
||||||
|
try {
|
||||||
|
const logPath = getLogPath();
|
||||||
|
const logsDir = require('path').dirname(logPath);
|
||||||
|
await shell.openPath(logsDir);
|
||||||
|
return { success: true, path: logsDir };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error opening logs folder:', error);
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.handle('quit-application', async event => {
|
ipcMain.handle('quit-application', async event => {
|
||||||
try {
|
try {
|
||||||
stopMacOSAudioCapture();
|
stopMacOSAudioCapture();
|
||||||
|
|||||||
+59
-6
@@ -418,10 +418,12 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
// Kill any existing SystemAudioDump processes first
|
// Kill any existing SystemAudioDump processes first
|
||||||
await killExistingSystemAudioDump();
|
await killExistingSystemAudioDump();
|
||||||
|
|
||||||
console.log('Starting macOS audio capture with SystemAudioDump...');
|
console.log('=== Starting macOS audio capture ===');
|
||||||
|
sendToRenderer('update-status', 'Starting audio capture...');
|
||||||
|
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
let systemAudioPath;
|
let systemAudioPath;
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
@@ -430,7 +432,35 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
systemAudioPath = path.join(__dirname, '../assets', 'SystemAudioDump');
|
systemAudioPath = path.join(__dirname, '../assets', 'SystemAudioDump');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('SystemAudioDump path:', systemAudioPath);
|
console.log('SystemAudioDump config:', {
|
||||||
|
path: systemAudioPath,
|
||||||
|
isPackaged: app.isPackaged,
|
||||||
|
resourcesPath: process.resourcesPath,
|
||||||
|
exists: fs.existsSync(systemAudioPath),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if file exists
|
||||||
|
if (!fs.existsSync(systemAudioPath)) {
|
||||||
|
console.error('FATAL: SystemAudioDump not found at:', systemAudioPath);
|
||||||
|
sendToRenderer('update-status', 'Error: Audio binary not found');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check and fix executable permissions
|
||||||
|
try {
|
||||||
|
fs.accessSync(systemAudioPath, fs.constants.X_OK);
|
||||||
|
console.log('SystemAudioDump is executable');
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('SystemAudioDump not executable, fixing permissions...');
|
||||||
|
try {
|
||||||
|
fs.chmodSync(systemAudioPath, 0o755);
|
||||||
|
console.log('Fixed executable permissions');
|
||||||
|
} catch (chmodErr) {
|
||||||
|
console.error('Failed to fix permissions:', chmodErr);
|
||||||
|
sendToRenderer('update-status', 'Error: Cannot execute audio binary');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const spawnOptions = {
|
const spawnOptions = {
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
@@ -439,10 +469,12 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('Spawning SystemAudioDump...');
|
||||||
systemAudioProc = spawn(systemAudioPath, [], spawnOptions);
|
systemAudioProc = spawn(systemAudioPath, [], spawnOptions);
|
||||||
|
|
||||||
if (!systemAudioProc.pid) {
|
if (!systemAudioProc.pid) {
|
||||||
console.error('Failed to start SystemAudioDump');
|
console.error('FATAL: Failed to start SystemAudioDump - no PID');
|
||||||
|
sendToRenderer('update-status', 'Error: Audio capture failed to start');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,8 +487,16 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;
|
const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;
|
||||||
|
|
||||||
let audioBuffer = Buffer.alloc(0);
|
let audioBuffer = Buffer.alloc(0);
|
||||||
|
let chunkCount = 0;
|
||||||
|
let firstDataReceived = false;
|
||||||
|
|
||||||
systemAudioProc.stdout.on('data', data => {
|
systemAudioProc.stdout.on('data', data => {
|
||||||
|
if (!firstDataReceived) {
|
||||||
|
firstDataReceived = true;
|
||||||
|
console.log('First audio data received! Size:', data.length);
|
||||||
|
sendToRenderer('update-status', 'Listening...');
|
||||||
|
}
|
||||||
|
|
||||||
audioBuffer = Buffer.concat([audioBuffer, data]);
|
audioBuffer = Buffer.concat([audioBuffer, data]);
|
||||||
|
|
||||||
while (audioBuffer.length >= CHUNK_SIZE) {
|
while (audioBuffer.length >= CHUNK_SIZE) {
|
||||||
@@ -467,6 +507,11 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
const base64Data = monoChunk.toString('base64');
|
const base64Data = monoChunk.toString('base64');
|
||||||
sendAudioToGemini(base64Data, geminiSessionRef);
|
sendAudioToGemini(base64Data, geminiSessionRef);
|
||||||
|
|
||||||
|
chunkCount++;
|
||||||
|
if (chunkCount % 100 === 0) {
|
||||||
|
console.log(`Audio: ${chunkCount} chunks processed`);
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.DEBUG_AUDIO) {
|
if (process.env.DEBUG_AUDIO) {
|
||||||
console.log(`Processed audio chunk: ${chunk.length} bytes`);
|
console.log(`Processed audio chunk: ${chunk.length} bytes`);
|
||||||
saveDebugAudio(monoChunk, 'system_audio');
|
saveDebugAudio(monoChunk, 'system_audio');
|
||||||
@@ -480,16 +525,24 @@ async function startMacOSAudioCapture(geminiSessionRef) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.stderr.on('data', data => {
|
systemAudioProc.stderr.on('data', data => {
|
||||||
console.error('SystemAudioDump stderr:', data.toString());
|
const msg = data.toString();
|
||||||
|
console.error('SystemAudioDump stderr:', msg);
|
||||||
|
if (msg.toLowerCase().includes('error')) {
|
||||||
|
sendToRenderer('update-status', 'Audio error: ' + msg.substring(0, 50));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.on('close', code => {
|
systemAudioProc.on('close', code => {
|
||||||
console.log('SystemAudioDump process closed with code:', code);
|
console.log('SystemAudioDump closed with code:', code, 'chunks processed:', chunkCount);
|
||||||
|
if (code !== 0 && code !== null) {
|
||||||
|
sendToRenderer('update-status', `Audio stopped (exit: ${code})`);
|
||||||
|
}
|
||||||
systemAudioProc = null;
|
systemAudioProc = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.on('error', err => {
|
systemAudioProc.on('error', err => {
|
||||||
console.error('SystemAudioDump process error:', err);
|
console.error('SystemAudioDump spawn error:', err.message);
|
||||||
|
sendToRenderer('update-status', 'Audio error: ' + err.message);
|
||||||
systemAudioProc = null;
|
systemAudioProc = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { app } = require('electron');
|
||||||
|
|
||||||
|
let logFile = null;
|
||||||
|
let logPath = null;
|
||||||
|
|
||||||
|
function getLogPath() {
|
||||||
|
if (logPath) return logPath;
|
||||||
|
|
||||||
|
const userDataPath = app.getPath('userData');
|
||||||
|
const logsDir = path.join(userDataPath, 'logs');
|
||||||
|
|
||||||
|
// Create logs directory if it doesn't exist
|
||||||
|
if (!fs.existsSync(logsDir)) {
|
||||||
|
fs.mkdirSync(logsDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create log file with timestamp
|
||||||
|
const timestamp = new Date().toISOString().split('T')[0];
|
||||||
|
logPath = path.join(logsDir, `app-${timestamp}.log`);
|
||||||
|
|
||||||
|
return logPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initLogger() {
|
||||||
|
try {
|
||||||
|
const filePath = getLogPath();
|
||||||
|
logFile = fs.createWriteStream(filePath, { flags: 'a' });
|
||||||
|
|
||||||
|
const startMsg = `\n${'='.repeat(60)}\nApp started at ${new Date().toISOString()}\nPlatform: ${process.platform}, Arch: ${process.arch}\nElectron: ${process.versions.electron}, Node: ${process.versions.node}\nPackaged: ${app.isPackaged}\n${'='.repeat(60)}\n`;
|
||||||
|
logFile.write(startMsg);
|
||||||
|
|
||||||
|
// Override console methods to also write to file
|
||||||
|
const originalLog = console.log;
|
||||||
|
const originalError = console.error;
|
||||||
|
const originalWarn = console.warn;
|
||||||
|
|
||||||
|
console.log = (...args) => {
|
||||||
|
originalLog.apply(console, args);
|
||||||
|
writeLog('INFO', args);
|
||||||
|
};
|
||||||
|
|
||||||
|
console.error = (...args) => {
|
||||||
|
originalError.apply(console, args);
|
||||||
|
writeLog('ERROR', args);
|
||||||
|
};
|
||||||
|
|
||||||
|
console.warn = (...args) => {
|
||||||
|
originalWarn.apply(console, args);
|
||||||
|
writeLog('WARN', args);
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('Logger initialized, writing to:', filePath);
|
||||||
|
|
||||||
|
return filePath;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to initialize logger:', err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeLog(level, args) {
|
||||||
|
if (!logFile) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
const message = args.map(arg => {
|
||||||
|
if (typeof arg === 'object') {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(arg, null, 2);
|
||||||
|
} catch {
|
||||||
|
return String(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String(arg);
|
||||||
|
}).join(' ');
|
||||||
|
|
||||||
|
logFile.write(`[${timestamp}] [${level}] ${message}\n`);
|
||||||
|
} catch (err) {
|
||||||
|
// Silently fail - don't want logging errors to crash the app
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeLogger() {
|
||||||
|
if (logFile) {
|
||||||
|
logFile.write(`\nApp closed at ${new Date().toISOString()}\n`);
|
||||||
|
logFile.end();
|
||||||
|
logFile = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
initLogger,
|
||||||
|
closeLogger,
|
||||||
|
getLogPath,
|
||||||
|
};
|
||||||
+138
-10
@@ -277,10 +277,14 @@ async function sendImageMessage(base64Image, prompt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process audio chunk and get response
|
// Process audio chunk and get response
|
||||||
// This accumulates audio and transcribes when silence is detected
|
// This accumulates audio and transcribes when silence is detected or timer expires
|
||||||
let audioChunks = [];
|
let audioChunks = [];
|
||||||
let lastAudioTime = 0;
|
let lastAudioTime = 0;
|
||||||
|
let firstChunkTime = 0;
|
||||||
const SILENCE_THRESHOLD_MS = 1500; // 1.5 seconds of silence
|
const SILENCE_THRESHOLD_MS = 1500; // 1.5 seconds of silence
|
||||||
|
const MAX_BUFFER_DURATION_MS = 5000; // 5 seconds max buffering before forced transcription
|
||||||
|
let silenceCheckTimer = null;
|
||||||
|
let windowsTranscriptionTimer = null;
|
||||||
|
|
||||||
async function processAudioChunk(base64Audio, mimeType) {
|
async function processAudioChunk(base64Audio, mimeType) {
|
||||||
if (!openaiClient) {
|
if (!openaiClient) {
|
||||||
@@ -290,12 +294,43 @@ async function processAudioChunk(base64Audio, mimeType) {
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const buffer = Buffer.from(base64Audio, 'base64');
|
const buffer = Buffer.from(base64Audio, 'base64');
|
||||||
|
|
||||||
|
// Track first chunk time for duration-based flushing
|
||||||
|
if (audioChunks.length === 0) {
|
||||||
|
firstChunkTime = now;
|
||||||
|
|
||||||
|
// Start periodic transcription timer (Windows needs this)
|
||||||
|
if (!windowsTranscriptionTimer && process.platform === 'win32') {
|
||||||
|
console.log('Starting Windows periodic transcription timer...');
|
||||||
|
windowsTranscriptionTimer = setInterval(async () => {
|
||||||
|
if (audioChunks.length > 0) {
|
||||||
|
const bufferDuration = Date.now() - firstChunkTime;
|
||||||
|
if (bufferDuration >= MAX_BUFFER_DURATION_MS) {
|
||||||
|
console.log(`Periodic flush: ${bufferDuration}ms of audio buffered`);
|
||||||
|
await flushAudioAndTranscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2000); // Check every 2 seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add to audio buffer
|
// Add to audio buffer
|
||||||
audioChunks.push(buffer);
|
audioChunks.push(buffer);
|
||||||
lastAudioTime = now;
|
lastAudioTime = now;
|
||||||
|
|
||||||
// Check for silence (no new audio for SILENCE_THRESHOLD_MS)
|
// Clear existing timer
|
||||||
// This is a simple approach - in production you'd want proper VAD
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set timer to check for silence
|
||||||
|
silenceCheckTimer = setTimeout(async () => {
|
||||||
|
const silenceDuration = Date.now() - lastAudioTime;
|
||||||
|
if (silenceDuration >= SILENCE_THRESHOLD_MS && audioChunks.length > 0) {
|
||||||
|
console.log('Silence detected, flushing audio for transcription...');
|
||||||
|
await flushAudioAndTranscribe();
|
||||||
|
}
|
||||||
|
}, SILENCE_THRESHOLD_MS);
|
||||||
|
|
||||||
return { success: true, buffering: true };
|
return { success: true, buffering: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,15 +339,30 @@ async function flushAudioAndTranscribe() {
|
|||||||
return { success: true, text: '' };
|
return { success: true, text: '' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear Windows transcription timer
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Combine all audio chunks
|
// Combine all audio chunks
|
||||||
const combinedBuffer = Buffer.concat(audioChunks);
|
const combinedBuffer = Buffer.concat(audioChunks);
|
||||||
|
const chunkCount = audioChunks.length;
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
|
firstChunkTime = 0;
|
||||||
|
|
||||||
|
// Calculate audio duration
|
||||||
|
const bytesPerSample = 2;
|
||||||
|
const audioDurationMs = (combinedBuffer.length / bytesPerSample / SAMPLE_RATE) * 1000;
|
||||||
|
|
||||||
|
console.log(`Transcribing ${chunkCount} chunks (${audioDurationMs.toFixed(0)}ms of audio)...`);
|
||||||
|
|
||||||
// Transcribe
|
// Transcribe
|
||||||
const transcription = await transcribeAudio(combinedBuffer);
|
const transcription = await transcribeAudio(combinedBuffer);
|
||||||
|
|
||||||
if (transcription && transcription.trim()) {
|
if (transcription && transcription.trim()) {
|
||||||
|
console.log('Transcription result:', transcription);
|
||||||
// Send to chat
|
// Send to chat
|
||||||
const response = await sendTextMessage(transcription);
|
const response = await sendTextMessage(transcription);
|
||||||
|
|
||||||
@@ -334,6 +384,16 @@ function clearConversation() {
|
|||||||
const systemMessage = conversationMessages.find(m => m.role === 'system');
|
const systemMessage = conversationMessages.find(m => m.role === 'system');
|
||||||
conversationMessages = systemMessage ? [systemMessage] : [];
|
conversationMessages = systemMessage ? [systemMessage] : [];
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
|
|
||||||
|
// Clear timers
|
||||||
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
silenceCheckTimer = null;
|
||||||
|
}
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeOpenAISDK() {
|
function closeOpenAISDK() {
|
||||||
@@ -343,6 +403,17 @@ function closeOpenAISDK() {
|
|||||||
conversationMessages = [];
|
conversationMessages = [];
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
|
|
||||||
|
// Clear timers
|
||||||
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
silenceCheckTimer = null;
|
||||||
|
}
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
sendToRenderer('update-status', 'Disconnected');
|
sendToRenderer('update-status', 'Disconnected');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,9 +512,11 @@ async function startMacOSAudioCapture() {
|
|||||||
// Kill any existing SystemAudioDump processes first
|
// Kill any existing SystemAudioDump processes first
|
||||||
await killExistingSystemAudioDump();
|
await killExistingSystemAudioDump();
|
||||||
|
|
||||||
console.log('Starting macOS audio capture with SystemAudioDump for OpenAI SDK...');
|
console.log('=== Starting macOS audio capture (OpenAI SDK) ===');
|
||||||
|
sendToRenderer('update-status', 'Starting audio capture...');
|
||||||
|
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
let systemAudioPath;
|
let systemAudioPath;
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
@@ -452,7 +525,35 @@ async function startMacOSAudioCapture() {
|
|||||||
systemAudioPath = path.join(__dirname, '../assets', 'SystemAudioDump');
|
systemAudioPath = path.join(__dirname, '../assets', 'SystemAudioDump');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('SystemAudioDump path:', systemAudioPath);
|
console.log('SystemAudioDump config:', {
|
||||||
|
path: systemAudioPath,
|
||||||
|
isPackaged: app.isPackaged,
|
||||||
|
resourcesPath: process.resourcesPath,
|
||||||
|
exists: fs.existsSync(systemAudioPath),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if file exists
|
||||||
|
if (!fs.existsSync(systemAudioPath)) {
|
||||||
|
console.error('FATAL: SystemAudioDump not found at:', systemAudioPath);
|
||||||
|
sendToRenderer('update-status', 'Error: Audio binary not found');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check and fix executable permissions
|
||||||
|
try {
|
||||||
|
fs.accessSync(systemAudioPath, fs.constants.X_OK);
|
||||||
|
console.log('SystemAudioDump is executable');
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('SystemAudioDump not executable, fixing permissions...');
|
||||||
|
try {
|
||||||
|
fs.chmodSync(systemAudioPath, 0o755);
|
||||||
|
console.log('Fixed executable permissions');
|
||||||
|
} catch (chmodErr) {
|
||||||
|
console.error('Failed to fix permissions:', chmodErr);
|
||||||
|
sendToRenderer('update-status', 'Error: Cannot execute audio binary');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const spawnOptions = {
|
const spawnOptions = {
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
@@ -461,10 +562,12 @@ async function startMacOSAudioCapture() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('Spawning SystemAudioDump...');
|
||||||
systemAudioProc = spawn(systemAudioPath, [], spawnOptions);
|
systemAudioProc = spawn(systemAudioPath, [], spawnOptions);
|
||||||
|
|
||||||
if (!systemAudioProc.pid) {
|
if (!systemAudioProc.pid) {
|
||||||
console.error('Failed to start SystemAudioDump');
|
console.error('FATAL: Failed to start SystemAudioDump - no PID');
|
||||||
|
sendToRenderer('update-status', 'Error: Audio capture failed to start');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,8 +579,16 @@ async function startMacOSAudioCapture() {
|
|||||||
const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;
|
const CHUNK_SIZE = SAMPLE_RATE * BYTES_PER_SAMPLE * CHANNELS * CHUNK_DURATION;
|
||||||
|
|
||||||
let tempBuffer = Buffer.alloc(0);
|
let tempBuffer = Buffer.alloc(0);
|
||||||
|
let chunkCount = 0;
|
||||||
|
let firstDataReceived = false;
|
||||||
|
|
||||||
systemAudioProc.stdout.on('data', data => {
|
systemAudioProc.stdout.on('data', data => {
|
||||||
|
if (!firstDataReceived) {
|
||||||
|
firstDataReceived = true;
|
||||||
|
console.log('First audio data received! Size:', data.length);
|
||||||
|
sendToRenderer('update-status', 'Listening...');
|
||||||
|
}
|
||||||
|
|
||||||
tempBuffer = Buffer.concat([tempBuffer, data]);
|
tempBuffer = Buffer.concat([tempBuffer, data]);
|
||||||
|
|
||||||
while (tempBuffer.length >= CHUNK_SIZE) {
|
while (tempBuffer.length >= CHUNK_SIZE) {
|
||||||
@@ -489,6 +600,11 @@ async function startMacOSAudioCapture() {
|
|||||||
|
|
||||||
// Add to audio buffer for transcription
|
// Add to audio buffer for transcription
|
||||||
audioBuffer = Buffer.concat([audioBuffer, monoChunk]);
|
audioBuffer = Buffer.concat([audioBuffer, monoChunk]);
|
||||||
|
|
||||||
|
chunkCount++;
|
||||||
|
if (chunkCount % 100 === 0) {
|
||||||
|
console.log(`Audio: ${chunkCount} chunks processed, buffer size: ${audioBuffer.length}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit buffer size (max 30 seconds of audio)
|
// Limit buffer size (max 30 seconds of audio)
|
||||||
@@ -499,21 +615,33 @@ async function startMacOSAudioCapture() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.stderr.on('data', data => {
|
systemAudioProc.stderr.on('data', data => {
|
||||||
console.error('SystemAudioDump stderr:', data.toString());
|
const msg = data.toString();
|
||||||
|
console.error('SystemAudioDump stderr:', msg);
|
||||||
|
if (msg.toLowerCase().includes('error')) {
|
||||||
|
sendToRenderer('update-status', 'Audio error: ' + msg.substring(0, 50));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.on('close', code => {
|
systemAudioProc.on('close', (code, signal) => {
|
||||||
console.log('SystemAudioDump process closed with code:', code);
|
console.log('SystemAudioDump closed:', { code, signal, chunksProcessed: chunkCount, tempBufferSize: tempBuffer.length });
|
||||||
|
if (code !== 0 && code !== null) {
|
||||||
|
sendToRenderer('update-status', `Audio stopped (exit: ${code}, signal: ${signal})`);
|
||||||
|
}
|
||||||
systemAudioProc = null;
|
systemAudioProc = null;
|
||||||
stopTranscriptionTimer();
|
stopTranscriptionTimer();
|
||||||
});
|
});
|
||||||
|
|
||||||
systemAudioProc.on('error', err => {
|
systemAudioProc.on('error', err => {
|
||||||
console.error('SystemAudioDump process error:', err);
|
console.error('SystemAudioDump spawn error:', err.message, err.stack);
|
||||||
|
sendToRenderer('update-status', 'Audio error: ' + err.message);
|
||||||
systemAudioProc = null;
|
systemAudioProc = null;
|
||||||
stopTranscriptionTimer();
|
stopTranscriptionTimer();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
systemAudioProc.on('exit', (code, signal) => {
|
||||||
|
console.log('SystemAudioDump exit event:', { code, signal });
|
||||||
|
});
|
||||||
|
|
||||||
// Start periodic transcription
|
// Start periodic transcription
|
||||||
startTranscriptionTimer();
|
startTranscriptionTimer();
|
||||||
|
|
||||||
|
|||||||
+115
-24
@@ -18,6 +18,23 @@ let currentImageQuality = 'medium'; // Store current image quality for manual sc
|
|||||||
|
|
||||||
const isLinux = process.platform === 'linux';
|
const isLinux = process.platform === 'linux';
|
||||||
const isMacOS = process.platform === 'darwin';
|
const isMacOS = process.platform === 'darwin';
|
||||||
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
|
// Send logs to main process for file logging
|
||||||
|
function logToMain(level, ...args) {
|
||||||
|
const message = args.map(arg => {
|
||||||
|
if (typeof arg === 'object') {
|
||||||
|
try { return JSON.stringify(arg); } catch { return String(arg); }
|
||||||
|
}
|
||||||
|
return String(arg);
|
||||||
|
}).join(' ');
|
||||||
|
ipcRenderer.send('renderer-log', { level, message });
|
||||||
|
|
||||||
|
// Also log to console
|
||||||
|
if (level === 'error') console.error(...args);
|
||||||
|
else if (level === 'warn') console.warn(...args);
|
||||||
|
else console.log(...args);
|
||||||
|
}
|
||||||
|
|
||||||
// ============ STORAGE API ============
|
// ============ STORAGE API ============
|
||||||
// Wrapper for IPC-based storage access
|
// Wrapper for IPC-based storage access
|
||||||
@@ -277,7 +294,21 @@ async function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'mediu
|
|||||||
|
|
||||||
console.log('Linux capture started - system audio:', mediaStream.getAudioTracks().length > 0, 'microphone mode:', audioMode);
|
console.log('Linux capture started - system audio:', mediaStream.getAudioTracks().length > 0, 'microphone mode:', audioMode);
|
||||||
} else {
|
} else {
|
||||||
// Windows - use display media with loopback for system audio
|
// Windows - show custom screen picker first
|
||||||
|
logToMain('info', '=== Starting Windows audio capture ===');
|
||||||
|
cheatingDaddy.setStatus('Choose screen to share...');
|
||||||
|
|
||||||
|
// Show screen picker dialog
|
||||||
|
const appElement = document.querySelector('cheating-daddy-app');
|
||||||
|
const pickerResult = await appElement.showScreenPickerDialog();
|
||||||
|
|
||||||
|
if (pickerResult.cancelled) {
|
||||||
|
cheatingDaddy.setStatus('Cancelled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheatingDaddy.setStatus('Starting capture...');
|
||||||
|
|
||||||
mediaStream = await navigator.mediaDevices.getDisplayMedia({
|
mediaStream = await navigator.mediaDevices.getDisplayMedia({
|
||||||
video: {
|
video: {
|
||||||
frameRate: 1,
|
frameRate: 1,
|
||||||
@@ -293,10 +324,29 @@ async function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'mediu
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Windows capture started with loopback audio');
|
const audioTracks = mediaStream.getAudioTracks();
|
||||||
|
const videoTracks = mediaStream.getVideoTracks();
|
||||||
|
|
||||||
// Setup audio processing for Windows loopback audio only
|
logToMain('info', 'Windows capture result:', {
|
||||||
setupWindowsLoopbackProcessing();
|
hasVideo: videoTracks.length > 0,
|
||||||
|
hasAudio: audioTracks.length > 0,
|
||||||
|
audioTrackInfo: audioTracks.map(t => ({
|
||||||
|
label: t.label,
|
||||||
|
enabled: t.enabled,
|
||||||
|
muted: t.muted,
|
||||||
|
readyState: t.readyState,
|
||||||
|
settings: t.getSettings()
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (audioTracks.length === 0) {
|
||||||
|
logToMain('warn', 'WARNING: No audio tracks! User must check "Share audio" in screen picker dialog');
|
||||||
|
cheatingDaddy.setStatus('Warning: No audio - enable "Share audio" checkbox');
|
||||||
|
} else {
|
||||||
|
logToMain('info', 'Audio track acquired, setting up processing...');
|
||||||
|
// Setup audio processing for Windows loopback audio only
|
||||||
|
setupWindowsLoopbackProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
if (audioMode === 'mic_only' || audioMode === 'both') {
|
if (audioMode === 'mic_only' || audioMode === 'both') {
|
||||||
let micStream = null;
|
let micStream = null;
|
||||||
@@ -412,32 +462,73 @@ function setupLinuxSystemAudioProcessing() {
|
|||||||
|
|
||||||
function setupWindowsLoopbackProcessing() {
|
function setupWindowsLoopbackProcessing() {
|
||||||
// Setup audio processing for Windows loopback audio only
|
// Setup audio processing for Windows loopback audio only
|
||||||
audioContext = new AudioContext({ sampleRate: SAMPLE_RATE });
|
logToMain('info', 'Setting up Windows loopback audio processing...');
|
||||||
const source = audioContext.createMediaStreamSource(mediaStream);
|
|
||||||
audioProcessor = audioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);
|
|
||||||
|
|
||||||
let audioBuffer = [];
|
try {
|
||||||
const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;
|
audioContext = new AudioContext({ sampleRate: SAMPLE_RATE });
|
||||||
|
|
||||||
audioProcessor.onaudioprocess = async e => {
|
logToMain('info', 'AudioContext created:', {
|
||||||
const inputData = e.inputBuffer.getChannelData(0);
|
state: audioContext.state,
|
||||||
audioBuffer.push(...inputData);
|
sampleRate: audioContext.sampleRate,
|
||||||
|
});
|
||||||
|
|
||||||
// Process audio in chunks
|
// Resume AudioContext if suspended (Chrome policy)
|
||||||
while (audioBuffer.length >= samplesPerChunk) {
|
if (audioContext.state === 'suspended') {
|
||||||
const chunk = audioBuffer.splice(0, samplesPerChunk);
|
logToMain('warn', 'AudioContext suspended, attempting resume...');
|
||||||
const pcmData16 = convertFloat32ToInt16(chunk);
|
audioContext.resume().then(() => {
|
||||||
const base64Data = arrayBufferToBase64(pcmData16.buffer);
|
logToMain('info', 'AudioContext resumed successfully');
|
||||||
|
}).catch(err => {
|
||||||
await ipcRenderer.invoke('send-audio-content', {
|
logToMain('error', 'Failed to resume AudioContext:', err.message);
|
||||||
data: base64Data,
|
|
||||||
mimeType: 'audio/pcm;rate=24000',
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
source.connect(audioProcessor);
|
const source = audioContext.createMediaStreamSource(mediaStream);
|
||||||
audioProcessor.connect(audioContext.destination);
|
audioProcessor = audioContext.createScriptProcessor(BUFFER_SIZE, 1, 1);
|
||||||
|
|
||||||
|
let audioBuffer = [];
|
||||||
|
const samplesPerChunk = SAMPLE_RATE * AUDIO_CHUNK_DURATION;
|
||||||
|
let chunkCount = 0;
|
||||||
|
let totalSamples = 0;
|
||||||
|
|
||||||
|
audioProcessor.onaudioprocess = async e => {
|
||||||
|
const inputData = e.inputBuffer.getChannelData(0);
|
||||||
|
audioBuffer.push(...inputData);
|
||||||
|
totalSamples += inputData.length;
|
||||||
|
|
||||||
|
// Process audio in chunks
|
||||||
|
while (audioBuffer.length >= samplesPerChunk) {
|
||||||
|
const chunk = audioBuffer.splice(0, samplesPerChunk);
|
||||||
|
const pcmData16 = convertFloat32ToInt16(chunk);
|
||||||
|
const base64Data = arrayBufferToBase64(pcmData16.buffer);
|
||||||
|
|
||||||
|
await ipcRenderer.invoke('send-audio-content', {
|
||||||
|
data: base64Data,
|
||||||
|
mimeType: 'audio/pcm;rate=24000',
|
||||||
|
});
|
||||||
|
|
||||||
|
chunkCount++;
|
||||||
|
|
||||||
|
// Log progress every 100 chunks (~10 seconds)
|
||||||
|
if (chunkCount === 1) {
|
||||||
|
logToMain('info', 'First audio chunk sent to AI');
|
||||||
|
cheatingDaddy.setStatus('Listening...');
|
||||||
|
} else if (chunkCount % 100 === 0) {
|
||||||
|
// Calculate max amplitude to check if we're getting real audio
|
||||||
|
const maxAmp = Math.max(...chunk.map(Math.abs));
|
||||||
|
logToMain('info', `Audio progress: ${chunkCount} chunks, maxAmplitude: ${maxAmp.toFixed(4)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
source.connect(audioProcessor);
|
||||||
|
audioProcessor.connect(audioContext.destination);
|
||||||
|
|
||||||
|
logToMain('info', 'Windows audio processing pipeline connected');
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
logToMain('error', 'Error setting up Windows audio:', err.message, err.stack);
|
||||||
|
cheatingDaddy.setStatus('Audio error: ' + err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function captureScreenshot(imageQuality = 'medium', isManual = false) {
|
async function captureScreenshot(imageQuality = 'medium', isManual = false) {
|
||||||
|
|||||||
+63
-45
@@ -34,59 +34,54 @@ function createWindow(sendToRenderer, geminiSessionRef) {
|
|||||||
|
|
||||||
const { session, desktopCapturer } = require('electron');
|
const { session, desktopCapturer } = require('electron');
|
||||||
|
|
||||||
// Setup display media request handler for screen capture
|
// Store selected source for Windows custom picker
|
||||||
// On macOS, use system picker for better UX
|
let selectedSourceId = null;
|
||||||
|
|
||||||
|
// Setup display media handler based on platform
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
|
// macOS: Use native system picker
|
||||||
session.defaultSession.setDisplayMediaRequestHandler(
|
session.defaultSession.setDisplayMediaRequestHandler(
|
||||||
async (request, callback) => {
|
(request, callback) => {
|
||||||
try {
|
desktopCapturer.getSources({ types: ['screen'] }).then(sources => {
|
||||||
const sources = await desktopCapturer.getSources({
|
|
||||||
types: ['screen'],
|
|
||||||
thumbnailSize: { width: 0, height: 0 } // Skip thumbnail generation for speed
|
|
||||||
});
|
|
||||||
|
|
||||||
if (sources.length === 0) {
|
|
||||||
console.error('No screen sources available');
|
|
||||||
callback(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On macOS, directly use the first screen (system already granted permission)
|
|
||||||
console.log('Screen capture source:', sources[0].name);
|
|
||||||
callback({ video: sources[0], audio: 'loopback' });
|
callback({ video: sources[0], audio: 'loopback' });
|
||||||
} catch (error) {
|
});
|
||||||
console.error('Error getting screen sources:', error);
|
|
||||||
callback(null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ useSystemPicker: false } // Disable system picker, use our source directly
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// On other platforms, use the system picker
|
|
||||||
session.defaultSession.setDisplayMediaRequestHandler(
|
|
||||||
async (request, callback) => {
|
|
||||||
try {
|
|
||||||
const sources = await desktopCapturer.getSources({
|
|
||||||
types: ['screen'],
|
|
||||||
thumbnailSize: { width: 0, height: 0 }
|
|
||||||
});
|
|
||||||
|
|
||||||
if (sources.length === 0) {
|
|
||||||
console.error('No screen sources available');
|
|
||||||
callback(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback({ video: sources[0], audio: 'loopback' });
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error getting screen sources:', error);
|
|
||||||
callback(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ useSystemPicker: true }
|
{ useSystemPicker: true }
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// Windows/Linux: Use selected source from custom picker
|
||||||
|
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
||||||
|
try {
|
||||||
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ['screen', 'window'],
|
||||||
|
thumbnailSize: { width: 0, height: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find the selected source or use first screen
|
||||||
|
let source = sources[0];
|
||||||
|
if (selectedSourceId) {
|
||||||
|
const found = sources.find(s => s.id === selectedSourceId);
|
||||||
|
if (found) source = found;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source) {
|
||||||
|
callback({ video: source, audio: 'loopback' });
|
||||||
|
} else {
|
||||||
|
callback({});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in display media handler:', error);
|
||||||
|
callback({});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IPC handler to set selected source
|
||||||
|
ipcMain.handle('set-selected-source', async (event, sourceId) => {
|
||||||
|
selectedSourceId = sourceId;
|
||||||
|
return { success: true };
|
||||||
|
});
|
||||||
|
|
||||||
mainWindow.setResizable(false);
|
mainWindow.setResizable(false);
|
||||||
mainWindow.setContentProtection(true);
|
mainWindow.setContentProtection(true);
|
||||||
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||||
@@ -760,6 +755,29 @@ function setupWindowIpcHandlers(mainWindow, sendToRenderer, geminiSessionRef) {
|
|||||||
return { success: false, error: error.message };
|
return { success: false, error: error.message };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get available screen sources for picker
|
||||||
|
ipcMain.handle('get-screen-sources', async () => {
|
||||||
|
try {
|
||||||
|
const { desktopCapturer } = require('electron');
|
||||||
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ['screen', 'window'],
|
||||||
|
thumbnailSize: { width: 150, height: 150 },
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
sources: sources.map(source => ({
|
||||||
|
id: source.id,
|
||||||
|
name: source.name,
|
||||||
|
thumbnail: source.thumbnail.toDataURL(),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting screen sources:', error);
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in New Issue
Block a user