Preserve macOS app permissions via dynamic launcher, .env workspace path, and session/audio tools
This commit is contained in:
@@ -4,15 +4,53 @@ import Foundation
|
||||
struct VoiceAgentLauncher {
|
||||
static func main() {
|
||||
let fileManager = FileManager.default
|
||||
let projDir = "/Users/adolforeyna/Projects/VoiceAgent1"
|
||||
let homeDir = fileManager.homeDirectoryForCurrentUser.path
|
||||
|
||||
// Load configuration from .env files if present
|
||||
var envConfig = [String: String]()
|
||||
let envPaths = [
|
||||
"\(homeDir)/.voiceagent.env",
|
||||
"\(homeDir)/.config/voiceagent/env",
|
||||
"\(homeDir)/.env"
|
||||
]
|
||||
|
||||
for envPath in envPaths {
|
||||
if let content = try? String(contentsOfFile: envPath, encoding: .utf8) {
|
||||
for line in content.components(separatedBy: .newlines) {
|
||||
let trimmed = line.trimmingCharacters(in: .whitespaces)
|
||||
if trimmed.isEmpty || trimmed.hasPrefix("#") { continue }
|
||||
let parts = trimmed.split(separator: "=", maxSplits: 1).map { String($0).trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
if parts.count == 2 {
|
||||
let key = parts[0]
|
||||
var val = parts[1]
|
||||
if (val.hasPrefix("\"") && val.hasSuffix("\"")) || (val.hasPrefix("'") && val.hasSuffix("'")) {
|
||||
val = String(val.dropFirst().dropLast())
|
||||
}
|
||||
envConfig[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let defaultProjDir = "/Users/adolforeyna/Projects/VoiceAgent1"
|
||||
let configuredProjDir = ProcessInfo.processInfo.environment["VOICEAGENT_DIR"]
|
||||
?? envConfig["VOICEAGENT_DIR"]
|
||||
?? envConfig["WORKSPACE_DIR"]
|
||||
?? defaultProjDir
|
||||
|
||||
let bundleResPath = Bundle.main.resourcePath ?? ""
|
||||
let bundledSrcPath = "\(bundleResPath)/src"
|
||||
|
||||
let workDir = fileManager.fileExists(atPath: projDir) ? projDir : bundledSrcPath
|
||||
let pythonBin = "\(projDir)/.venv/bin/python"
|
||||
let workDir = fileManager.fileExists(atPath: configuredProjDir) ? configuredProjDir : bundledSrcPath
|
||||
|
||||
let defaultPythonBin = "\(workDir)/.venv/bin/python"
|
||||
let configuredPython = ProcessInfo.processInfo.environment["VOICEAGENT_PYTHON"]
|
||||
?? envConfig["VOICEAGENT_PYTHON"]
|
||||
?? envConfig["PYTHON_PATH"]
|
||||
?? defaultPythonBin
|
||||
|
||||
let fallbackPython = "/usr/bin/python3"
|
||||
let targetPython = fileManager.fileExists(atPath: pythonBin) ? pythonBin : fallbackPython
|
||||
let targetPython = fileManager.fileExists(atPath: configuredPython) ? configuredPython : fallbackPython
|
||||
let targetScript = "\(workDir)/app_main.py"
|
||||
|
||||
setenv("SSL_CERT_FILE", "/etc/ssl/cert.pem", 1)
|
||||
|
||||
+22
-7
@@ -9,8 +9,19 @@ set -euo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$HERE"
|
||||
|
||||
swiftc -O -parse-as-library SpeechHelper.swift -o speech-helper
|
||||
echo "built $HERE/speech-helper"
|
||||
FORCE=0
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "-f" ] || [ "$arg" = "--force" ]; then
|
||||
FORCE=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$FORCE" -eq 1 ] || [ ! -f speech-helper ] || [ SpeechHelper.swift -nt speech-helper ]; then
|
||||
swiftc -O -parse-as-library SpeechHelper.swift -o speech-helper
|
||||
echo "built $HERE/speech-helper"
|
||||
else
|
||||
echo "speech-helper is up to date — skipping recompile"
|
||||
fi
|
||||
|
||||
if ./speech-helper --check >/dev/null 2>&1; then
|
||||
echo "speech-helper runs — ./speech-helper --check for details"
|
||||
@@ -24,12 +35,16 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
if swiftc -O -parse-as-library -target arm64-apple-macosx26.0 LLMHelper.swift -o llm-helper 2>/dev/null; then
|
||||
echo "built $HERE/llm-helper"
|
||||
if ./llm-helper --check >/dev/null 2>&1; then
|
||||
echo "llm-helper runs — ./llm-helper --check for details"
|
||||
if [ "$FORCE" -eq 1 ] || [ ! -f llm-helper ] || [ LLMHelper.swift -nt llm-helper ]; then
|
||||
if swiftc -O -parse-as-library -target arm64-apple-macosx26.0 LLMHelper.swift -o llm-helper 2>/dev/null; then
|
||||
echo "built $HERE/llm-helper"
|
||||
if ./llm-helper --check >/dev/null 2>&1; then
|
||||
echo "llm-helper runs — ./llm-helper --check for details"
|
||||
fi
|
||||
else
|
||||
echo "could not build llm-helper with FoundationModels; fallback to Python MLX bridge will be available"
|
||||
fi
|
||||
else
|
||||
echo "could not build llm-helper with FoundationModels; fallback to Python MLX bridge will be available"
|
||||
echo "llm-helper is up to date — skipping recompile"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user