Files
tkmind_go/crates/goose-server/src/state.rs
T
Yingjie He f7f2540287 feat: support goose mode in UI (#1434)
Co-authored-by: Lily Delalande <ldelalande@squareup.com>
2025-02-28 17:00:41 -08:00

26 lines
620 B
Rust

use anyhow::Result;
use goose::agents::Agent;
use serde_json::Value;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::{Mutex, RwLock};
/// Shared application state
#[allow(dead_code)]
#[derive(Clone)]
pub struct AppState {
pub agent: Arc<RwLock<Option<Box<dyn Agent>>>>,
pub secret_key: String,
pub config: Arc<Mutex<HashMap<String, Value>>>,
}
impl AppState {
pub async fn new(secret_key: String) -> Result<Self> {
Ok(Self {
agent: Arc::new(RwLock::new(None)),
secret_key,
config: Arc::new(Mutex::new(HashMap::new())),
})
}
}