Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Wax/Broker/AgentBrokerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ package enum AgentBrokerClient {
}

private static func startBrokerIfNeeded(configuration: AgentBrokerConfiguration) throws -> Bool {
#if os(iOS) || os(tvOS) || os(watchOS)
throw BrokerClientError("Starting a broker process is not supported on this platform.")
#else
guard FileManager.default.isExecutableFile(atPath: configuration.brokerExecutablePath) else {
throw BrokerClientError(
"Broker executable is not executable at \(configuration.brokerExecutablePath)"
Expand Down Expand Up @@ -160,6 +163,7 @@ package enum AgentBrokerClient {
}

throw BrokerClientError("Timed out waiting for broker startup.")
#endif
}

private static func shutdownStartedBroker(configuration: AgentBrokerConfiguration) throws {
Expand Down
12 changes: 12 additions & 0 deletions Sources/Wax/Broker/AgentBrokerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,19 @@ package enum AgentBrokerPathing {
return URL(fileURLWithPath: expandPath(raw), isDirectory: true)
}

#if os(iOS) || os(tvOS) || os(watchOS)
let root = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
?? FileManager.default.temporaryDirectory
return root
.appendingPathComponent("waxmcp", isDirectory: true)
.appendingPathComponent("broker", isDirectory: true)
#else
return FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent(".local", isDirectory: true)
.appendingPathComponent("share", isDirectory: true)
.appendingPathComponent("waxmcp", isDirectory: true)
.appendingPathComponent("broker", isDirectory: true)
#endif
}

package static func resolveBrokerCLIPath(
Expand Down Expand Up @@ -317,6 +325,9 @@ package enum AgentBrokerPathing {
}

private static func resolveExecutableOnPath(_ tool: String) -> String? {
#if os(iOS) || os(tvOS) || os(watchOS)
nil
#else
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
process.arguments = ["which", tool]
Expand All @@ -341,5 +352,6 @@ package enum AgentBrokerPathing {
let path = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines)
guard let path, !path.isEmpty else { return nil }
return path
#endif
}
}
Loading