diff --git a/apps/macos/Sources/Clawdis/AgentRPC.swift b/apps/macos/Sources/Clawdis/AgentRPC.swift index ef81df76e..5dbc3a8b0 100644 --- a/apps/macos/Sources/Clawdis/AgentRPC.swift +++ b/apps/macos/Sources/Clawdis/AgentRPC.swift @@ -14,8 +14,10 @@ actor AgentRPC { private struct RpcError: Error { let message: String } func send(text: String, thinking: String?, session: String) async -> (ok: Bool, text: String?, error: String?) { - guard process?.isRunning == true else { - return (false, nil, "rpc worker not running") + if process?.isRunning != true { + do { try await ensureRunning() } catch { + return (false, nil, "rpc worker not running") + } } do { let payload: [String: Any] = [ @@ -23,6 +25,7 @@ actor AgentRPC { "text": text, "session": session, "thinking": thinking ?? "default", + "deliver": true, ] let data = try JSONSerialization.data(withJSONObject: payload) guard let stdinHandle else { throw RpcError(message: "stdin missing") } @@ -56,8 +59,10 @@ actor AgentRPC { } func status() async -> (ok: Bool, error: String?) { - guard process?.isRunning == true else { - return (false, "rpc worker not running") + if process?.isRunning != true { + do { try await ensureRunning() } catch { + return (false, "rpc worker not running") + } } do { let payload: [String: Any] = ["type": "status"] @@ -114,6 +119,11 @@ actor AgentRPC { } } + private func ensureRunning() async throws { + if let process, process.isRunning { return } + try await start() + } + private func stop() async { stdoutHandle?.readabilityHandler = nil process?.terminate() diff --git a/apps/macos/Sources/Clawdis/Constants.swift b/apps/macos/Sources/Clawdis/Constants.swift index f177b00c0..c8c260594 100644 --- a/apps/macos/Sources/Clawdis/Constants.swift +++ b/apps/macos/Sources/Clawdis/Constants.swift @@ -24,7 +24,7 @@ let modelCatalogPathKey = "clawdis.modelCatalogPath" let modelCatalogReloadKey = "clawdis.modelCatalogReload" let voiceWakeSupported: Bool = ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 26 let cliHelperSearchPaths = ["/usr/local/bin", "/opt/homebrew/bin"] -let defaultVoiceWakeForwardCommand = "clawdis-mac agent --message \"${text}\" --thinking low" +let defaultVoiceWakeForwardCommand = "clawdis-mac agent --message \"${text}\" --thinking low --session main --deliver" let defaultVoiceWakeForwardPort = 22 // Allow enough time for remote agent responses (LLM replies often take >10s). let defaultVoiceWakeForwardTimeout: TimeInterval = 30