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//! - [`ScriptedBackend`] answers from rules instead, for scripts and CI (`okbot chat --replies`).
6//! - [`detect`] finds installed CLIs and whether they are logged in, for `okbot init` and `doctor`.
7
8mod chain;
9mod cli;
10pub mod detect;
11mod env;
12mod model;
13mod prompt;
14mod scripted;
15mod slots;
16
17pub use agent_call::Provider;
18pub use chain::AgentChain;
19pub use cli::{CliBackend, CliBackendConfig};
20pub use env::EnvScrub;
21pub use model::{model_parts, validate_model};
22pub use prompt::inline_system_prompt;
23pub use scripted::ScriptedBackend;
24pub use slots::{MachineSlots, Slot};
25
26/// Parses a provider name as used in configuration (`claude`, `codex`, `opencode`, `devin`).
27pub fn parse_provider(name: &str) -> Option<Provider> {
28    match name {
29        "claude" => Some(Provider::Claude),
30        "codex" => Some(Provider::Codex),
31        "opencode" => Some(Provider::OpenCodeV2),
32        "devin" => Some(Provider::Devin),
33        _ => None,
34    }
35}
36
37/// The configuration name of a provider.
38pub fn provider_name(provider: Provider) -> &'static str {
39    match provider {
40        Provider::Claude => "claude",
41        Provider::Codex => "codex",
42        Provider::OpenCodeV2 => "opencode",
43        Provider::Devin => "devin",
44    }
45}
46
47/// Every provider okbot knows, in the order the setup wizard lists them.
48pub const PROVIDERS: [Provider; 4] = [
49    Provider::Claude,
50    Provider::Codex,
51    Provider::OpenCodeV2,
52    Provider::Devin,
53];