An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
refactor(mac): give the downloader its own file, so the updater can share it
Shahriar7086ce156bdc
diff --git a/src/mac/Sources/Browsentic/Core/Downloader.swift b/src/mac/Sources/Browsentic/Core/Downloader.swiftnew file mode 100644index 0000000..5d8cd84--- /dev/null+++ b/src/mac/Sources/Browsentic/Core/Downloader.swift@@ -0,0 +1,46 @@+import Foundation++final class Downloader: NSObject, URLSessionDownloadDelegate, @unchecked Sendable {+ private var continuation: CheckedContinuation<URL, Error>?+ private var onProgress: (@Sendable (Double) -> Void)?++ func download(_ url: URL, onProgress: @escaping @Sendable (Double) -> Void) async throws -> URL {+ self.onProgress = onProgress+ let session = URLSession(configuration: .ephemeral, delegate: self, delegateQueue: nil)+ defer { session.finishTasksAndInvalidate() }+ return try await withCheckedThrowingContinuation { continuation in+ self.continuation = continuation+ session.downloadTask(with: url).resume()+ }+ }++ func urlSession(+ _: URLSession, downloadTask _: URLSessionDownloadTask, didWriteData _: Int64,+ totalBytesWritten written: Int64, totalBytesExpectedToWrite expected: Int64+ ) {+ if expected > 0 { onProgress?(Double(written) / Double(expected)) }+ }++ func urlSession(_: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {+ let status = (downloadTask.response as? HTTPURLResponse)?.statusCode ?? 200+ guard (200..<300).contains(status) else {+ continuation?.resume(throwing: URLError(.badServerResponse))+ continuation = nil+ return+ }+ let kept = FileManager.default.temporaryDirectory.appendingPathComponent("browsentic-\(UUID().uuidString)-\(downloadTask.originalRequest?.url?.lastPathComponent ?? "download")")+ do {+ try FileManager.default.moveItem(at: location, to: kept)+ continuation?.resume(returning: kept)+ } catch {+ continuation?.resume(throwing: error)+ }+ continuation = nil+ }++ func urlSession(_: URLSession, task _: URLSessionTask, didCompleteWithError error: Error?) {+ guard let error else { return }+ continuation?.resume(throwing: error)+ continuation = nil+ }+}diff --git a/src/mac/Sources/Browsentic/Core/NodeRuntime.swift b/src/mac/Sources/Browsentic/Core/NodeRuntime.swiftindex 487e915..a1304be 100644--- a/src/mac/Sources/Browsentic/Core/NodeRuntime.swift+++ b/src/mac/Sources/Browsentic/Core/NodeRuntime.swift@@ -111,48 +111,3 @@ enum NodeRuntime {return NodeInstall(path: Paths.privateNode.path, version: release.version, isPrivate: true)}}--private final class Downloader: NSObject, URLSessionDownloadDelegate, @unchecked Sendable {- private var continuation: CheckedContinuation<URL, Error>?- private var onProgress: (@Sendable (Double) -> Void)?-- func download(_ url: URL, onProgress: @escaping @Sendable (Double) -> Void) async throws -> URL {- self.onProgress = onProgress- let session = URLSession(configuration: .ephemeral, delegate: self, delegateQueue: nil)- defer { session.finishTasksAndInvalidate() }- return try await withCheckedThrowingContinuation { continuation in- self.continuation = continuation- session.downloadTask(with: url).resume()- }- }-- func urlSession(- _: URLSession, downloadTask _: URLSessionDownloadTask, didWriteData _: Int64,- totalBytesWritten written: Int64, totalBytesExpectedToWrite expected: Int64- ) {- if expected > 0 { onProgress?(Double(written) / Double(expected)) }- }-- func urlSession(_: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {- let status = (downloadTask.response as? HTTPURLResponse)?.statusCode ?? 200- guard (200..<300).contains(status) else {- continuation?.resume(throwing: URLError(.badServerResponse))- continuation = nil- return- }- let kept = FileManager.default.temporaryDirectory.appendingPathComponent("browsentic-node-\(UUID().uuidString).tar.gz")- do {- try FileManager.default.moveItem(at: location, to: kept)- continuation?.resume(returning: kept)- } catch {- continuation?.resume(throwing: error)- }- continuation = nil- }-- func urlSession(_: URLSession, task _: URLSessionTask, didCompleteWithError error: Error?) {- guard let error else { return }- continuation?.resume(throwing: error)- continuation = nil- }-}