use serde::Deserialize;
use crate::validation::*;
#[derive(Debug, Deserialize)]
pub struct StartCrawlResponse {
#[serde(deserialize_with = "deserialize_non_empty_string")]
pub crawl_id: String,
}
#[derive(Debug, Deserialize)]
pub struct StartSearchResponse {
#[serde(
alias = "sessionId",
deserialize_with = "deserialize_non_empty_string"
)]
pub session_id: String,
}
#[derive(Debug, Deserialize)]
pub struct SpawnClaudeAgentResponse {
#[serde(deserialize_with = "deserialize_vec_non_empty_strings")]
pub session_ids: Vec<String>,
pub worker_count: u32,
#[serde(default)]
pub agents: Vec<serde_json::Value>,
}
impl Validate for SpawnClaudeAgentResponse {
fn validate(&self) -> Result<(), String> {
if self.session_ids.len() != self.worker_count as usize {
return Err(count_mismatch_error(
"worker_count",
self.worker_count as usize,
self.session_ids.len(),
));
}
Ok(())
}
}
#[derive(Debug, Deserialize)]
pub struct StartTerminalCommandResponse {
#[serde(deserialize_with = "deserialize_positive_i64")]
pub pid: i64,
#[serde(default)]
pub status: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct GetPromptResponse {
pub name: String,
pub metadata: PromptMetadata,
pub content: String,
pub rendered: bool,
}
#[derive(Debug, Deserialize)]
pub struct RenderPromptResponse {
pub name: String,
pub content: String,
pub rendered: bool,
}
#[derive(Debug, Deserialize)]
pub struct PromptMetadata {
pub title: String,
pub description: String,
pub categories: Vec<String>,
pub author: String,
#[serde(default)]
pub parameters: Vec<ParameterDefinition>,
}
#[derive(Debug, Deserialize)]
pub struct ParameterDefinition {
pub name: String,
pub description: String,
#[serde(default)]
pub required: bool,
}
#[derive(Debug, Deserialize)]
pub struct GetConfigResponse {
pub blocked_commands: Vec<String>,
pub default_shell: String,
pub allowed_directories: Vec<String>,
pub denied_directories: Vec<String>,
pub file_read_line_limit: usize,
pub file_write_line_limit: usize,
pub fuzzy_search_threshold: f64,
pub http_connection_timeout_secs: u64,
#[serde(default)]
pub current_client: Option<ClientInfo>,
#[serde(default)]
pub client_history: Vec<ClientRecord>,
pub system_info: SystemInfo,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ClientInfo {
pub name: String,
pub version: String,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ClientRecord {
pub client_info: ClientInfo,
pub connected_at: String,
pub last_seen: String,
}
#[derive(Debug, Deserialize)]
pub struct SystemInfo {
pub platform: String,
pub arch: String,
pub os_version: String,
pub kernel_version: String,
pub hostname: String,
pub rust_version: String,
pub cpu_count: usize,
pub memory: MemoryInfo,
}
#[derive(Debug, Deserialize)]
pub struct MemoryInfo {
pub total_mb: String,
pub available_mb: String,
pub used_mb: String,
}
#[derive(Debug, Deserialize)]
pub struct SequentialThinkingResponse {
#[serde(deserialize_with = "deserialize_non_empty_string")]
pub session_id: String,
pub thought_number: u32,
pub total_thoughts: u32,
pub next_thought_needed: bool,
pub branches: Vec<String>,
pub thought_history_length: usize,
}
#[derive(Debug, Deserialize, Clone)]
pub struct GitHubUser {
#[serde(deserialize_with = "deserialize_positive_u64")]
pub id: u64,
#[serde(deserialize_with = "deserialize_non_empty_string")]
pub login: String,
#[serde(default)]
pub name: Option<String>,
#[serde(default)]
pub email: Option<String>,
pub avatar_url: Option<String>,
pub html_url: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct GitHubRepository {
pub id: u64,
pub name: String,
pub full_name: String,
pub owner: GitHubUser,
#[serde(default)]
pub description: Option<String>,
pub html_url: Option<String>,
#[serde(default)]
pub clone_url: Option<String>,
#[serde(default)]
pub default_branch: Option<String>,
#[serde(default)]
pub stargazers_count: Option<u64>,
#[serde(default)]
pub forks_count: Option<u64>,
#[serde(default)]
pub open_issues_count: Option<u64>,
#[serde(default)]
pub language: Option<String>,
#[serde(default)]
pub created_at: Option<String>,
#[serde(default)]
pub updated_at: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct GitHubLabel {
pub id: u64,
pub name: String,
pub color: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubIssue {
pub id: u64,
pub number: u64,
pub title: String,
#[serde(default)]
pub body: Option<String>,
pub state: String,
pub user: GitHubUser,
#[serde(default)]
pub assignees: Vec<GitHubUser>,
#[serde(default)]
pub labels: Vec<GitHubLabel>,
pub html_url: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubComment {
pub id: u64,
pub body: String,
pub user: GitHubUser,
pub html_url: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Debug, Deserialize, Clone)]
pub struct GitHubBranchRef {
#[serde(rename = "ref")]
pub ref_field: String,
pub sha: String,
pub repo: GitHubRepository,
}
#[derive(Debug, Deserialize)]
pub struct GitHubPullRequest {
pub id: u64,
pub number: u64,
pub title: String,
#[serde(default)]
pub body: Option<String>,
pub state: String,
pub user: GitHubUser,
pub head: GitHubBranchRef,
pub base: GitHubBranchRef,
pub html_url: Option<String>,
#[serde(default)]
pub mergeable: Option<bool>,
pub merged: bool,
pub created_at: String,
pub updated_at: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubReview {
pub id: u64,
pub user: GitHubUser,
#[serde(default)]
pub body: Option<String>,
pub state: String,
pub html_url: Option<String>,
#[serde(default)]
pub submitted_at: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct GitHubPullRequestFile {
pub filename: String,
pub status: String,
pub additions: u64,
pub deletions: u64,
pub changes: u64,
#[serde(default)]
pub patch: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct GitHubBranch {
pub name: String,
pub commit: GitHubCommitRef,
pub protected: bool,
}
#[derive(Debug, Deserialize, Clone)]
pub struct GitHubCommitRef {
pub sha: String,
pub url: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubCommit {
pub sha: String,
pub commit: GitHubCommitDetail,
#[serde(default)]
pub author: Option<GitHubUser>,
#[serde(default)]
pub committer: Option<GitHubUser>,
pub html_url: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct GitHubCommitDetail {
pub message: String,
pub author: GitHubCommitAuthor,
pub committer: GitHubCommitAuthor,
}
#[derive(Debug, Deserialize)]
pub struct GitHubCommitAuthor {
pub name: String,
pub email: String,
pub date: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubMergeResult {
pub sha: String,
pub merged: bool,
pub message: String,
}
#[derive(Debug, Deserialize)]
pub struct GitHubSearchResults<T> {
pub total_count: u64,
pub incomplete_results: bool,
pub items: Vec<T>,
}
#[derive(Debug, Deserialize)]
pub struct GitHubIssuesResponse {
pub count: u64,
pub issues: Vec<GitHubIssue>,
}
impl Validate for GitHubIssuesResponse {
fn validate(&self) -> Result<(), String> {
if self.count as usize != self.issues.len() {
return Err(count_mismatch_error(
"count",
self.count as usize,
self.issues.len(),
));
}
Ok(())
}
}
#[derive(Debug, Deserialize)]
pub struct GitHubCommentsResponse {
pub count: u64,
pub comments: Vec<GitHubComment>,
}
impl Validate for GitHubCommentsResponse {
fn validate(&self) -> Result<(), String> {
if self.count as usize != self.comments.len() {
return Err(count_mismatch_error(
"count",
self.count as usize,
self.comments.len(),
));
}
Ok(())
}
}
#[derive(Debug, Deserialize)]
pub struct GitHubCodeResult {
pub name: String,
pub path: String,
pub sha: String,
pub html_url: Option<String>,
pub repository: GitHubRepository,
}