saya-cli 0.3.2

Database-aware AI agent for the terminal: full-screen TUI, schema discovery, and bounded read-only SQL over PostgreSQL, MySQL, SQLite, DuckDB, and Snowflake.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::config::runtime::{RuntimeConfig, RuntimeError};

impl RuntimeConfig {
    pub fn secret_resolver(&self) -> saya_config::MapSecretResolver {
        saya_config::MapSecretResolver::new(self.secret_values.clone())
    }

    pub fn named_profile(&self, name: &str) -> Result<&saya_types::DatabaseProfile, RuntimeError> {
        if self.resolved.profile_name.as_deref() == Some(name)
            && let Some(profile) = self.resolved.profile.as_ref()
        {
            return Ok(profile);
        }
        self.connections.profiles.get(name).ok_or_else(|| {
            RuntimeError::Config(saya_config::ConfigError::UnknownProfile(name.into()))
        })
    }
}