Skip to main content

okbot_agent/
lib.rs

1//! Agent backends for okbot: agent CLIs through agent-call, fallback chains and CLI detection.
2//!
3//! - [`CliBackend`] runs one agent CLI (Claude Code, Codex, OpenCode, Devin) per turn.
4//! - [`AgentChain`] tries backends in order, enforces the tool policy and limits concurrency.
5//! - [`detect`] finds installed CLIs and whether they are logged in, for `okbot init` and `doctor`.
6
7mod chain;
8mod cli;
9pub mod detect;
10mod env;
11mod prompt;
12mod slots;
13
14pub use agent_call::Provider;
15pub use chain::AgentChain;
16pub use cli::{CliBackend, CliBackendConfig};
17pub use env::EnvScrub;
18pub use prompt::inline_system_prompt;
19pub use slots::{MachineSlots, Slot};
20
21/// Parses a provider name as used in configuration (`claude`, `codex`, `opencode`, `devin`).
22pub fn parse_provider(name: &str) -> Option<Provider> {
23    match name {
24        "claude" => Some(Provider::Claude),
25        "codex" => Some(Provider::Codex),
26        "opencode" => Some(Provider::OpenCodeV2),
27        "devin" => Some(Provider::Devin),
28        _ => None,
29    }
30}
31
32/// The configuration name of a provider.
33pub fn provider_name(provider: Provider) -> &'static str {
34    match provider {
35        Provider::Claude => "claude",
36        Provider::Codex => "codex",
37        Provider::OpenCodeV2 => "opencode",
38        Provider::Devin => "devin",
39    }
40}
41
42/// Every provider okbot knows, in the order the setup wizard lists them.
43pub const PROVIDERS: [Provider; 4] = [
44    Provider::Claude,
45    Provider::Codex,
46    Provider::OpenCodeV2,
47    Provider::Devin,
48];