use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Default)]
pub enum OutputFormat {
#[default]
Text,
Json,
StreamJson,
}
impl OutputFormat {
pub(crate) fn as_arg(&self) -> &'static str {
match self {
Self::Text => "text",
Self::Json => "json",
Self::StreamJson => "stream-json",
}
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum PermissionMode {
#[default]
Default,
AcceptEdits,
BypassPermissions,
DontAsk,
Plan,
Auto,
}
impl PermissionMode {
pub(crate) fn as_arg(&self) -> &'static str {
match self {
Self::Default => "default",
Self::AcceptEdits => "acceptEdits",
Self::BypassPermissions => "bypassPermissions",
Self::DontAsk => "dontAsk",
Self::Plan => "plan",
Self::Auto => "auto",
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub enum InputFormat {
#[default]
Text,
StreamJson,
}
impl InputFormat {
pub(crate) fn as_arg(&self) -> &'static str {
match self {
Self::Text => "text",
Self::StreamJson => "stream-json",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Effort {
Low,
Medium,
High,
Max,
}
impl Effort {
pub(crate) fn as_arg(&self) -> &'static str {
match self {
Self::Low => "low",
Self::Medium => "medium",
Self::High => "high",
Self::Max => "max",
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub enum Scope {
#[default]
Local,
User,
Project,
}
impl Scope {
pub(crate) fn as_arg(&self) -> &'static str {
match self {
Self::Local => "local",
Self::User => "user",
Self::Project => "project",
}
}
}
#[cfg(feature = "json")]
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthStatus {
#[serde(default)]
pub logged_in: bool,
#[serde(default)]
pub auth_method: Option<String>,
#[serde(default)]
pub api_provider: Option<String>,
#[serde(default)]
pub email: Option<String>,
#[serde(default)]
pub org_id: Option<String>,
#[serde(default)]
pub org_name: Option<String>,
#[serde(default)]
pub subscription_type: Option<String>,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}
#[cfg(feature = "json")]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct QueryMessage {
#[serde(default)]
pub role: String,
#[serde(default)]
pub content: serde_json::Value,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}
#[cfg(feature = "json")]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct QueryResult {
#[serde(default)]
pub result: String,
#[serde(default)]
pub session_id: String,
#[serde(default)]
pub cost_usd: Option<f64>,
#[serde(default)]
pub duration_ms: Option<u64>,
#[serde(default)]
pub is_error: bool,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}