1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AgentError {
5 #[error("budget exhausted after {0} iterations")]
6 BudgetExhausted(u32),
7 #[error("transport error: {0}")]
8 Transport(#[from] TransportError),
9 #[error("tool error: {0}")]
10 Tool(#[from] ToolError),
11 #[error(transparent)]
12 Other(#[from] anyhow::Error),
13}
14
15#[derive(Debug, Error)]
16pub enum TransportError {
17 #[error("HTTP error {status}: {body}")]
18 Http { status: u16, body: String },
19 #[error("rate limited, retry after {retry_after_secs}s")]
20 RateLimit { retry_after_secs: u64 },
21 #[error("network error: {0}")]
22 Network(String),
23 #[error("authentication failed")]
24 Auth,
25 #[error("stream error: {0}")]
26 Stream(String),
27 #[error("LLM call timed out after {0}s")]
28 Timeout(u64),
29 #[error(transparent)]
30 Other(#[from] anyhow::Error),
31}
32
33#[derive(Debug, Error)]
34pub enum ToolError {
35 #[error("tool not found: {0}")]
36 NotFound(String),
37 #[error("invalid arguments: {0}")]
38 InvalidArgs(String),
39 #[error("execution failed: {0}")]
40 Execution(String),
41 #[error("approval denied")]
42 ApprovalDenied,
43 #[error("tool '{0}' denied by active skill permissions")]
44 PermissionDenied(String),
45 #[error("tool timed out after {0}s")]
46 Timeout(u64),
47 #[error(transparent)]
48 Other(#[from] anyhow::Error),
49}
50
51#[derive(Debug, Error)]
52pub enum PlatformError {
53 #[error("connection error: {0}")]
54 Connection(String),
55 #[error("send failed: {0}")]
56 Send(String),
57 #[error("authentication failed")]
58 Auth,
59 #[error(transparent)]
60 Other(#[from] anyhow::Error),
61}