ai_env 0.1.3

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

// GitHub Copilot CLI — sets COPILOT_MODEL / COPILOT_ALLOW_ALL / COPILOT_GITHUB_TOKEN.
// The cloud agent variant also sets COPILOT_AGENT_SESSION_ID, and its egress
// firewall announces itself via COPILOT_AGENT_FIREWALL_* variables, which
// `detect_network_policy` reports as `Filtered`.
pub fn create_environment() -> AiEnvironment {
    AiEnvironment {
        agent: AiAgent::GithubCopilot,
        env_prefix: Some("COPILOT_".into()),
        id: self_id(),
        network: detect_network_policy(AiAgent::GithubCopilot),
        sandboxed: false,
        session_id: opt_var("COPILOT_AGENT_SESSION_ID"),
    }
}