voicecc 1.2.3 → 1.2.4

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 (2) hide show
  1. package/bin/voicecc.js +83 -68
  2. package/package.json +1 -1
package/bin/voicecc.js CHANGED
@@ -95,13 +95,88 @@ function generatePassword() {
95
95
  return randomBytes(18).toString("base64url");
96
96
  }
97
97
 
98
+ function findPython() {
99
+ const candidates = ["python3.12", "python3.13", "python3", "python"];
100
+ for (const candidate of candidates) {
101
+ if (commandExists(candidate)) {
102
+ try {
103
+ const version = execSync(`${candidate} --version 2>&1`, { encoding: "utf-8" }).trim();
104
+ const match = version.match(/Python (\d+)\.(\d+)/);
105
+ if (match && (parseInt(match[1]) > 3 || (parseInt(match[1]) === 3 && parseInt(match[2]) >= 12))) {
106
+ return candidate;
107
+ }
108
+ } catch { /* skip */ }
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+
114
+ function linuxInstallPackage(pkg) {
115
+ if (commandExists("apt-get")) {
116
+ execSync(`apt-get update -qq && apt-get install -y -qq ${pkg} 2>&1`, { stdio: "inherit" });
117
+ } else if (commandExists("dnf")) {
118
+ execSync(`dnf install -y ${pkg} 2>&1`, { stdio: "inherit" });
119
+ } else if (commandExists("yum")) {
120
+ execSync(`yum install -y ${pkg} 2>&1`, { stdio: "inherit" });
121
+ } else {
122
+ throw new Error("No supported package manager found (apt-get, dnf, yum).");
123
+ }
124
+ }
125
+
126
+ function ensurePython() {
127
+ let systemPython = findPython();
128
+ if (systemPython) return systemPython;
129
+
130
+ if (process.platform !== "linux") {
131
+ console.error("ERROR: Python 3.12+ is required but not found.");
132
+ console.error("Install Python 3.12+ and run 'voicecc' again.");
133
+ process.exit(1);
134
+ }
135
+
136
+ console.log("Python 3.12+ not found. Installing...");
137
+ try {
138
+ linuxInstallPackage("python3.12 python3.12-venv python3.12-dev");
139
+ } catch (err) {
140
+ console.error(`Failed to install Python: ${err.message}`);
141
+ process.exit(1);
142
+ }
143
+
144
+ systemPython = findPython();
145
+ if (!systemPython) {
146
+ console.error("Python installation completed but Python 3.12+ still not found.");
147
+ process.exit(1);
148
+ }
149
+ return systemPython;
150
+ }
151
+
152
+ function ensureVenvModule(systemPython) {
153
+ try {
154
+ execSync(`${systemPython} -c "import venv" 2>&1`, { encoding: "utf-8" });
155
+ return;
156
+ } catch { /* venv not available */ }
157
+
158
+ if (process.platform !== "linux") {
159
+ console.error("ERROR: Python venv module is missing.");
160
+ console.error("Install it and run 'voicecc' again.");
161
+ process.exit(1);
162
+ }
163
+
164
+ const version = execSync(`${systemPython} --version 2>&1`, { encoding: "utf-8" }).trim().match(/Python (\d+)\.(\d+)/);
165
+ const venvPkg = version ? `python${version[1]}.${version[2]}-venv` : "python3-venv";
166
+ console.log(`Python venv module missing. Installing ${venvPkg}...`);
167
+ try {
168
+ linuxInstallPackage(venvPkg);
169
+ } catch (err) {
170
+ console.error(`Failed to install ${venvPkg}: ${err.message}`);
171
+ process.exit(1);
172
+ }
173
+ }
174
+
98
175
  /**
99
176
  * Ensure the Python virtual environment exists and dependencies are installed.
100
177
  *
101
178
  * Creates voice-server/.venv if missing, installs requirements.txt, and
102
179
  * stores a checksum so subsequent runs skip installation unless deps change.
103
- *
104
- * @returns true if the venv is ready, false if Python is unavailable
105
180
  */
106
181
  function ensurePythonVenv() {
107
182
  const voiceServerDir = join(PKG_ROOT, "voice-server");
@@ -114,72 +189,13 @@ function ensurePythonVenv() {
114
189
  return true; // No voice-server requirements, nothing to do
115
190
  }
116
191
 
117
- // Find a working Python 3.12+
118
- const pythonCandidates = ["python3.12", "python3.13", "python3", "python"];
119
- let systemPython = null;
120
- for (const candidate of pythonCandidates) {
121
- if (commandExists(candidate)) {
122
- try {
123
- const version = execSync(`${candidate} --version 2>&1`, { encoding: "utf-8" }).trim();
124
- const match = version.match(/Python (\d+)\.(\d+)/);
125
- if (match && (parseInt(match[1]) > 3 || (parseInt(match[1]) === 3 && parseInt(match[2]) >= 12))) {
126
- systemPython = candidate;
127
- break;
128
- }
129
- } catch { /* skip */ }
130
- }
131
- }
192
+ // Step 1: Ensure Python 3.12+ is installed
193
+ const systemPython = ensurePython();
132
194
 
133
- if (!systemPython) {
134
- // Attempt to install Python 3.12 automatically on Linux
135
- if (process.platform === "linux") {
136
- console.log("Python 3.12+ not found. Installing automatically...");
137
- try {
138
- if (commandExists("apt-get")) {
139
- execSync("apt-get update -qq && apt-get install -y -qq python3.12 python3.12-venv python3.12-dev 2>&1", { stdio: "inherit" });
140
- } else if (commandExists("dnf")) {
141
- execSync("dnf install -y python3.12 2>&1", { stdio: "inherit" });
142
- } else if (commandExists("yum")) {
143
- execSync("yum install -y python3.12 2>&1", { stdio: "inherit" });
144
- } else {
145
- console.error("No supported package manager found (apt-get, dnf, yum).");
146
- console.error("Install Python 3.12+ manually and run 'voicecc' again.");
147
- process.exit(1);
148
- }
149
- // Re-check for Python after installation
150
- for (const candidate of pythonCandidates) {
151
- if (commandExists(candidate)) {
152
- try {
153
- const version = execSync(`${candidate} --version 2>&1`, { encoding: "utf-8" }).trim();
154
- const match = version.match(/Python (\d+)\.(\d+)/);
155
- if (match && (parseInt(match[1]) > 3 || (parseInt(match[1]) === 3 && parseInt(match[2]) >= 12))) {
156
- systemPython = candidate;
157
- console.log(`Python installed successfully: ${version}`);
158
- break;
159
- }
160
- } catch { /* skip */ }
161
- }
162
- }
163
- if (!systemPython) {
164
- console.error("Python installation completed but Python 3.12+ still not found.");
165
- console.error("Install Python 3.12+ manually and run 'voicecc' again.");
166
- process.exit(1);
167
- }
168
- } catch (err) {
169
- console.error(`Failed to install Python 3.12: ${err.message}`);
170
- console.error("Install Python 3.12+ manually and run 'voicecc' again.");
171
- process.exit(1);
172
- }
173
- } else {
174
- console.error("");
175
- console.error("ERROR: Python 3.12+ is required but not found.");
176
- console.error("Install Python 3.12+ and run 'voicecc' again.");
177
- console.error("");
178
- process.exit(1);
179
- }
180
- }
195
+ // Step 2: Ensure venv module is available
196
+ ensureVenvModule(systemPython);
181
197
 
182
- // Check if venv needs to be created
198
+ // Step 3: Create venv if needed
183
199
  if (!existsSync(venvPython)) {
184
200
  console.log("Setting up Python environment for voice server...");
185
201
  try {
@@ -190,7 +206,7 @@ function ensurePythonVenv() {
190
206
  }
191
207
  }
192
208
 
193
- // Check if requirements have changed since last install
209
+ // Step 4: Install/update dependencies if requirements changed
194
210
  const currentChecksum = (() => {
195
211
  try {
196
212
  const content = readFileSync(requirementsFile, "utf-8");
@@ -207,7 +223,6 @@ function ensurePythonVenv() {
207
223
  return true; // Dependencies up to date
208
224
  }
209
225
 
210
- // Install/update dependencies
211
226
  console.log("Installing Python dependencies for voice server...");
212
227
  try {
213
228
  execSync(`${venvPython} -m pip install -r ${requirementsFile}`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voicecc",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Voice Agent Platform running on Claude Code -- create and deploy conversational voice agents with ElevenLabs STT/TTS and VAD",
5
5
  "repository": {
6
6
  "type": "git",