kranth 0.1.0

Stress-test ideas against hundreds of AI personas. Adversarial multi-bias debate. API-first.
Documentation
//! Wire-shape types. Kept in lockstep with the api responses + the other
//! SDKs (sdks/python/src/kranth/_models.py, sdks/typescript/src/types.ts,
//! sdks/go/kranth.go).

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum SimStatus {
    Queued,
    Running,
    Complete,
    Failed,
    Canceled,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AuthSource {
    ApiKey,
    Nexus,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelInfo {
    pub id: String,
    pub tier: String,
    pub display_name: String,
    pub provider: String,
    pub credits_per_100_personas: u32,
    pub plan_min: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Me {
    pub user_id: String,
    pub org_id: String,
    pub auth_source: AuthSource,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VerdictReport {
    pub sentiment_score: f64,
    pub hostile_count: u32,
    pub aligned_count: u32,
    pub neutral_count: u32,
    pub themes: Vec<String>,
    pub top_objections: Vec<String>,
    pub representative_quotes: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimSummary {
    pub id: String,
    pub org_id: String,
    pub created_by: String,
    pub status: SimStatus,
    pub idea_text: String,
    pub persona_count: i32,
    pub personas_done: i32,
    pub model_tier: String,
    pub credits_charged: i32,
    pub avg_sentiment: Option<f64>,
    pub error_message: Option<String>,
    pub started_at: Option<String>,
    pub completed_at: Option<String>,
    pub created_at: String,
    #[serde(default)]
    pub report: Option<VerdictReport>,
}

#[derive(Debug, Clone, Serialize)]
pub struct CreateSimRequest {
    pub idea_text: String,
    pub persona_count: u32,
    pub model_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub training_opt_in: Option<bool>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct CreateSimResponse {
    pub sim_id: String,
    pub status: String,
    pub model_tier: String,
    pub credits_charged: u32,
    pub persona_count: u32,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ListSimsResponse {
    pub sims: Vec<SimSummary>,
    pub next_cursor: Option<String>,
}

#[derive(Debug, Default, Clone)]
pub struct ListSimsParams {
    pub status: Option<String>,
    pub cursor: Option<String>,
    pub limit: Option<i64>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ApiKey {
    pub id: String,
    pub name: String,
    pub prefix: String,
    pub last_used_at: Option<String>,
    pub revoked_at: Option<String>,
    pub created_at: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct CreateApiKeyResponse {
    pub id: String,
    pub name: String,
    pub prefix: String,
    pub key: String,
    pub created_at: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct Usage {
    pub plan: String,
    pub monthly_cap: i32,
    pub credits_consumed: i32,
    pub credits_remaining: i64,
    pub period_start: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct SimEvent {
    pub kind: String,
    pub sim_id: String,
    #[serde(default)]
    pub data: serde_json::Value,
}