Build: fix RPC sendable params and CLI imports

This commit is contained in:
Peter Steinberger
2025-12-09 03:33:16 +01:00
parent a8b26570e0
commit c568284f1b
4 changed files with 17 additions and 10 deletions

View File

@@ -1,6 +1,10 @@
import Foundation
import OSLog
struct ControlRequestParams: @unchecked Sendable {
let raw: [String: AnyHashable]
}
actor AgentRPC {
static let shared = AgentRPC()
@@ -173,13 +177,13 @@ actor AgentRPC {
}
}
func controlRequest(method: String, params: [String: Any]? = nil) async throws -> Data {
func controlRequest(method: String, params: ControlRequestParams? = nil) async throws -> Data {
if self.process?.isRunning != true {
try await self.start()
}
let id = UUID().uuidString
var frame: [String: Any] = ["type": "control-request", "id": id, "method": method]
if let params { frame["params"] = params }
if let params { frame["params"] = params.raw }
let data = try JSONSerialization.data(withJSONObject: frame)
guard let stdinHandle else { throw RpcError(message: "stdin missing") }
return try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Data, Error>) in