mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(app:macos): 【 OpenClaw ⇄ clawdbot 】- Peekaboo Bridge discovery after the OpenClaw rename (#6033)
* fix(mac): keep OpenClaw bridge socket and harden legacy symlink * fix(mac): add clawdis legacy Peekaboo bridge symlink * macos: include moltbot in PeekabooBridge legacy socket paths * changelog: note peekaboo legacy socket compatibility paths --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
@@ -13,14 +13,29 @@ final class PeekabooBridgeHostCoordinator {
|
||||
|
||||
private var host: PeekabooBridgeHost?
|
||||
private var services: OpenClawPeekabooBridgeServices?
|
||||
|
||||
private static let legacySocketDirectoryNames = ["clawdbot", "clawdis", "moltbot"]
|
||||
|
||||
private static var openclawSocketPath: String {
|
||||
let fileManager = FileManager.default
|
||||
let base = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
|
||||
?? fileManager.homeDirectoryForCurrentUser.appendingPathComponent("Library/Application Support")
|
||||
let directory = base.appendingPathComponent("OpenClaw", isDirectory: true)
|
||||
return directory.appendingPathComponent(PeekabooBridgeConstants.socketName, isDirectory: false).path
|
||||
return Self.makeSocketPath(for: "OpenClaw", in: base)
|
||||
}
|
||||
|
||||
private static func makeSocketPath(for directoryName: String, in baseDirectory: URL) -> String {
|
||||
baseDirectory
|
||||
.appendingPathComponent(directoryName, isDirectory: true)
|
||||
.appendingPathComponent(PeekabooBridgeConstants.socketName, isDirectory: false)
|
||||
.path
|
||||
}
|
||||
|
||||
private static var legacySocketPaths: [String] {
|
||||
let fileManager = FileManager.default
|
||||
let base = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
|
||||
?? fileManager.homeDirectoryForCurrentUser.appendingPathComponent("Library/Application Support")
|
||||
return Self.legacySocketDirectoryNames.map { Self.makeSocketPath(for: $0, in: base) }
|
||||
}
|
||||
func setEnabled(_ enabled: Bool) async {
|
||||
if enabled {
|
||||
await self.startIfNeeded()
|
||||
@@ -46,6 +61,8 @@ final class PeekabooBridgeHostCoordinator {
|
||||
}
|
||||
let allowlistedBundles: Set<String> = []
|
||||
|
||||
self.ensureLegacySocketSymlinks()
|
||||
|
||||
let services = OpenClawPeekabooBridgeServices()
|
||||
let server = PeekabooBridgeServer(
|
||||
services: services,
|
||||
@@ -67,6 +84,42 @@ final class PeekabooBridgeHostCoordinator {
|
||||
.info("PeekabooBridge host started at \(Self.openclawSocketPath, privacy: .public)")
|
||||
}
|
||||
|
||||
private func ensureLegacySocketSymlinks() {
|
||||
Self.legacySocketPaths.forEach { legacyPath in
|
||||
self.ensureLegacySocketSymlink(at: legacyPath)
|
||||
}
|
||||
}
|
||||
|
||||
private func ensureLegacySocketSymlink(at legacyPath: String) {
|
||||
let fileManager = FileManager.default
|
||||
let legacyDirectory = (legacyPath as NSString).deletingLastPathComponent
|
||||
do {
|
||||
let directoryAttributes: [FileAttributeKey: Any] = [
|
||||
.posixPermissions: 0o700,
|
||||
]
|
||||
try fileManager.createDirectory(
|
||||
atPath: legacyDirectory,
|
||||
withIntermediateDirectories: true,
|
||||
attributes: directoryAttributes)
|
||||
let linkURL = URL(fileURLWithPath: legacyPath)
|
||||
let linkValues = try? linkURL.resourceValues(forKeys: [.isSymbolicLinkKey])
|
||||
if linkValues?.isSymbolicLink == true {
|
||||
let destination = try FileManager.default.destinationOfSymbolicLink(atPath: legacyPath)
|
||||
let destinationURL = URL(fileURLWithPath: destination, relativeTo: linkURL.deletingLastPathComponent())
|
||||
.standardizedFileURL
|
||||
if destinationURL.path == URL(fileURLWithPath: Self.openclawSocketPath).standardizedFileURL.path {
|
||||
return
|
||||
}
|
||||
try fileManager.removeItem(atPath: legacyPath)
|
||||
} else if fileManager.fileExists(atPath: legacyPath) {
|
||||
try fileManager.removeItem(atPath: legacyPath)
|
||||
}
|
||||
try fileManager.createSymbolicLink(atPath: legacyPath, withDestinationPath: Self.openclawSocketPath)
|
||||
} catch {
|
||||
self.logger.debug("Failed to create legacy PeekabooBridge socket symlink: \(error.localizedDescription, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
private static func currentTeamID() -> String? {
|
||||
var code: SecCode?
|
||||
guard SecCodeCopySelf(SecCSFlags(), &code) == errSecSuccess,
|
||||
|
||||
Reference in New Issue
Block a user