ai_env 0.1.1

Detect AI coding agent information from the environment.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::api::{opt_var, self_id, AiAgent, AiEnvironment};

// OpenAI Codex — sets CODEX_SANDBOX (e.g. `seatbelt`) when sandboxing commands,
// and CODEX_THREAD_ID for the active conversation thread
// https://developers.openai.com/codex/environment-variables
pub fn create_environment() -> AiEnvironment {
    AiEnvironment {
        agent: AiAgent::Codex,
        env_prefix: Some("CODEX_".into()),
        id: self_id(),
        sandboxed: opt_var("CODEX_SANDBOX").is_some(),
        session_id: opt_var("CODEX_THREAD_ID"),
    }
}