Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

664 B
Raw Blame
import Foundation

public enum AgentConnectionRequestLoop {
    /// Serves request lines until `readLine` returns nil or `handle` returns false.
    public static func run(readLine: () -> String?, handle: (String) -> Bool) {
        var keepServing = true
        while keepServing {
            // Why: a connection thread outlives its requests; without a per-request pool, objects
            // autoreleased while encoding a screenshot keep its WindowServer buffer until disconnect.
            keepServing = autoreleasepool {
                guard let line = readLine() else { return false }
                return handle(line)
            }
        }
    }
}