Skip to main content

edgecrab_types/
lib.rs

1//! # edgecrab-types
2//!
3//! Shared types for the EdgeCrab agent ecosystem.
4//! This is the leaf crate — no internal dependencies.
5//!
6//! ```text
7//!   edgecrab-types  ←  (all other crates depend on this)
8//!     ├── message.rs    — Message, Role, Content, ContentPart
9//!     ├── tool.rs       — ToolCall, FunctionCall, ToolSchema
10//!     ├── usage.rs      — Usage, Cost, billing normalization
11//!     ├── config.rs     — ApiMode, Platform, constants
12//!     ├── trajectory.rs — Trajectory, reasoning extraction
13//!     └── error.rs      — AgentError, ToolError
14//! ```
15
16#![deny(clippy::unwrap_used)]
17
18pub mod config;
19pub mod error;
20pub mod harness;
21pub mod message;
22pub mod tool;
23pub mod trajectory;
24pub mod usage;
25
26pub use config::{ApiMode, DEFAULT_MODEL, OPENROUTER_BASE_URL, OriginChat, Platform};
27pub use error::{AgentError, ToolError, ToolErrorRecord, ToolErrorResponse};
28pub use harness::{
29    CompletionDecision, ExitReason, ReportedTaskStatus, RunOutcome, TaskStatusKind,
30    VerificationSummary,
31};
32pub use message::{Content, ContentPart, ImageUrl, Message, Role};
33pub use tool::{FunctionCall, ToolCall, ToolSchema};
34pub use trajectory::Trajectory;
35pub use usage::{Cost, Usage};
36
37/// Crate-level Result alias
38pub type Result<T> = std::result::Result<T, AgentError>;
39
40// ─── Termux / Android detection ──────────────────────────────────────
41
42/// Returns `true` if running inside Termux on Android.
43///
44/// Detection checks:
45/// 1. `TERMUX_VERSION` env var is set
46/// 2. `PREFIX` env var contains `com.termux/files/usr`
47pub fn is_termux() -> bool {
48    std::env::var("TERMUX_VERSION").is_ok()
49        || std::env::var("PREFIX")
50            .map(|p| p.contains("com.termux/files/usr"))
51            .unwrap_or(false)
52}
53
54/// Cached result of [`is_termux()`]. Env vars don't change mid-process,
55/// so we evaluate once at first access.
56pub static IS_TERMUX: std::sync::LazyLock<bool> = std::sync::LazyLock::new(is_termux);