Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

698 B
Raw Blame
import Foundation

/// One direction of a screen candidate exchange, under the host's rules:
/// at most `ScreenCandidate.maxCount` candidates, then one completion, then nothing.
public struct CandidateProgress: Sendable {
    public private(set) var count = 0
    public private(set) var isComplete = false

    public init() {}

    public mutating func accept(_ event: ScreenCandidate) throws {
        guard !isComplete else { throw ScreenError.candidatesAlreadyComplete }
        if event.type == .complete {
            isComplete = true
        } else {
            guard count < ScreenCandidate.maxCount else { throw ScreenError.tooManyCandidates }
            count += 1
        }
    }
}