@aglit-ai/cli 0.1.17089 → 0.1.17091
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/package.json +1 -1
- package/src/mac-audio.cjs +38 -0
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
const driver = '/Library/Audio/Plug-Ins/HAL/BlackHole2ch.driver';
|
|
5
|
+
const signingRequirement = '=identifier "audio.existential.BlackHole2ch" and anchor apple generic and certificate leaf[subject.OU] = "Q5C99V536K"';
|
|
6
|
+
function run(file, args, options = {}) {
|
|
7
|
+
const result = spawnSync(file, args, { encoding: 'utf8', timeout: 20000, shell: false, ...options });
|
|
8
|
+
if (result.error || result.status !== 0) throw Error('macOS audio setup failed; existing audio configuration was preserved.');
|
|
9
|
+
return result.stdout || '';
|
|
10
|
+
}
|
|
11
|
+
function status() {
|
|
12
|
+
if (process.platform !== 'darwin') return { supported: false, installed: false };
|
|
13
|
+
if (!fs.existsSync(driver)) return { supported: true, installed: false };
|
|
14
|
+
const stat = fs.lstatSync(driver);
|
|
15
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || stat.uid !== 0) throw Error('Existing BlackHole driver needs review; it will not be replaced.');
|
|
16
|
+
run('/usr/bin/codesign', ['--verify', '--deep', '--strict', '-R', signingRequirement, driver]);
|
|
17
|
+
const version = run('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleShortVersionString', driver + '/Contents/Info.plist']).trim();
|
|
18
|
+
const devices = run('/usr/sbin/system_profiler', ['SPAudioDataType', '-json', '-timeout', '10']);
|
|
19
|
+
return { supported: true, installed: true, version, restartRequired: !devices.includes('"BlackHole 2ch"') };
|
|
20
|
+
}
|
|
21
|
+
function setup({ interactive = false } = {}) {
|
|
22
|
+
const current = status();
|
|
23
|
+
if (!current.supported || current.installed) return current;
|
|
24
|
+
// Preserve other variants: the vendor installer may alter all BlackHole bundles.
|
|
25
|
+
if (fs.readdirSync('/Library/Audio/Plug-Ins/HAL').some(name => /^BlackHole.*ch\.driver$/.test(name)))
|
|
26
|
+
throw Error('Another BlackHole variant is installed. Select it in the remote app instead of replacing it.');
|
|
27
|
+
if (!interactive) return { ...current, actionRequired: 'Run aglit init in an interactive terminal to install BlackHole 2ch.' };
|
|
28
|
+
const brew = ['/opt/homebrew/bin/brew', '/usr/local/bin/brew'].find(file => fs.existsSync(file));
|
|
29
|
+
if (!brew) return { ...current, actionRequired: 'Install Homebrew, then rerun aglit init. See https://brew.sh/.' };
|
|
30
|
+
// Homebrew verifies the official cask package. Administrator approval stays in
|
|
31
|
+
// the user's terminal. Never restart CoreAudio or change their default devices.
|
|
32
|
+
run(brew, ['install', '--cask', 'homebrew/cask/blackhole-2ch'], { stdio: 'inherit', timeout: 180000,
|
|
33
|
+
env: { ...process.env, HOMEBREW_NO_AUTO_UPDATE: '1', HOMEBREW_NO_INSTALL_CLEANUP: '1' } });
|
|
34
|
+
const installed = status();
|
|
35
|
+
if (!installed.installed) throw Error('BlackHole installation did not produce a verified driver.');
|
|
36
|
+
return installed;
|
|
37
|
+
}
|
|
38
|
+
module.exports = { status, setup };
|