@agora-build/audictl 0.1.0

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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @agora-build/audictl
2
+
3
+ Manage macOS audio devices from the command line — a scriptable, agent-friendly
4
+ replacement for the audio-device half of Audio MIDI Setup.
5
+
6
+ ```sh
7
+ npm install -g @agora-build/audictl
8
+ audictl list
9
+ ```
10
+
11
+ The postinstall step downloads the prebuilt binary for your platform from
12
+ [GitHub Releases](https://github.com/Agora-Build/audictl/releases). macOS only.
13
+
14
+ Alternative install without npm:
15
+
16
+ ```sh
17
+ curl -fsSL https://dl.agora.build/audictl/install.sh | bash
18
+ ```
19
+
20
+ Full documentation: https://github.com/Agora-Build/audictl
package/bin/audictl ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ echo "audictl binary not found. Run 'npm rebuild @agora-build/audictl' to install." >&2
3
+ exit 1
package/install.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const https = require("https");
5
+ const http = require("http");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const { execSync } = require("child_process");
9
+ const os = require("os");
10
+
11
+ const pkg = require("./package.json");
12
+ const VERSION = `v${pkg.version}`;
13
+ const REPO = "Agora-Build/audictl";
14
+ const BIN_DIR = path.join(__dirname, "bin");
15
+ const BIN_PATH = path.join(BIN_DIR, "audictl");
16
+
17
+ function getPlatformKey() {
18
+ const platform = os.platform();
19
+ const arch = os.arch();
20
+
21
+ const map = {
22
+ "darwin-x64": "darwin-x86_64",
23
+ "darwin-arm64": "darwin-aarch64",
24
+ };
25
+
26
+ const key = `${platform}-${arch}`;
27
+ if (!map[key]) {
28
+ console.error(`Unsupported platform: ${key}`);
29
+ console.error("audictl drives CoreAudio and only runs on macOS (darwin-x64, darwin-arm64).");
30
+ process.exit(1);
31
+ }
32
+ return map[key];
33
+ }
34
+
35
+ function getDownloadUrl() {
36
+ const platformKey = getPlatformKey();
37
+ return `https://github.com/${REPO}/releases/download/${VERSION}/audictl-${VERSION}-${platformKey}.tar.gz`;
38
+ }
39
+
40
+ function fetch(url, redirects = 0) {
41
+ if (redirects > 5) {
42
+ return Promise.reject(new Error("Too many redirects"));
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ const client = url.startsWith("https") ? https : http;
46
+ client
47
+ .get(url, { headers: { "User-Agent": "audictl-npm-installer" } }, (res) => {
48
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
49
+ return resolve(fetch(res.headers.location, redirects + 1));
50
+ }
51
+ if (res.statusCode !== 200) {
52
+ return reject(new Error(`Download failed: HTTP ${res.statusCode} for ${url}`));
53
+ }
54
+ const chunks = [];
55
+ res.on("data", (chunk) => chunks.push(chunk));
56
+ res.on("end", () => resolve(Buffer.concat(chunks)));
57
+ res.on("error", reject);
58
+ })
59
+ .on("error", reject);
60
+ });
61
+ }
62
+
63
+ async function install() {
64
+ const url = getDownloadUrl();
65
+ console.log(`Downloading audictl ${VERSION} for ${getPlatformKey()}...`);
66
+ console.log(` ${url}`);
67
+
68
+ const tarball = await fetch(url);
69
+
70
+ // Write tarball to temp file and extract
71
+ const tmpFile = path.join(os.tmpdir(), `audictl-${Date.now()}.tar.gz`);
72
+ fs.writeFileSync(tmpFile, tarball);
73
+
74
+ fs.mkdirSync(BIN_DIR, { recursive: true });
75
+
76
+ try {
77
+ execSync(`tar -xzf "${tmpFile}" -C "${BIN_DIR}"`, { stdio: "pipe" });
78
+ } finally {
79
+ fs.unlinkSync(tmpFile);
80
+ }
81
+
82
+ // Ensure the binary is executable
83
+ fs.chmodSync(BIN_PATH, 0o755);
84
+ console.log(`Installed audictl ${VERSION} to ${BIN_PATH}`);
85
+ }
86
+
87
+ install().catch((err) => {
88
+ console.error(`Failed to install audictl: ${err.message}`);
89
+ console.error("");
90
+ console.error("You can manually download the binary from:");
91
+ console.error(` https://github.com/${REPO}/releases/tag/${VERSION}`);
92
+ process.exit(1);
93
+ });
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@agora-build/audictl",
3
+ "version": "0.1.0",
4
+ "description": "Manage macOS audio devices from the command line — a scriptable, agent-friendly replacement for Audio MIDI Setup.",
5
+ "bin": {
6
+ "audictl": "bin/audictl"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "install.js",
14
+ "README.md"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Agora-Build/audictl.git"
19
+ },
20
+ "keywords": [
21
+ "macos",
22
+ "audio",
23
+ "coreaudio",
24
+ "aggregate-device",
25
+ "sample-rate",
26
+ "cli",
27
+ "ai",
28
+ "agent"
29
+ ],
30
+ "author": "Agora Build <build@agora.io>",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/Agora-Build/audictl/issues"
34
+ },
35
+ "homepage": "https://github.com/Agora-Build/audictl#readme",
36
+ "os": [
37
+ "darwin"
38
+ ],
39
+ "cpu": [
40
+ "x64",
41
+ "arm64"
42
+ ]
43
+ }