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