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)
|
||||
|
||||
Reference in New Issue
Block a user