diff --git a/config.agent.example.yaml b/config.agent.example.yaml index ce663d8..c6fe438 100644 --- a/config.agent.example.yaml +++ b/config.agent.example.yaml @@ -5,13 +5,13 @@ # - _MODEL # - _TEMPERATURE # - _TOP_P -# - _AGENT_PRELUDE +# - _AGENT_SESSION # - _VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]') model: openai:gpt-4o # Specify the LLM to use temperature: null # Set default temperature parameter, range (0, 1) top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model -agent_prelude: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_prelude +agent_session: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_session name: # Name of the agent, used in the UI and logs description: # Description of the agent, used in the UI version: 1 # Version of the agent @@ -66,4 +66,4 @@ documents: # Optional documents to load for the agent - ~/some-file.txt # File in the user's home directory - /absolute/path/to/some-file.md # File with absolute path - /absolute/path/**/NAME.txt # Find all NAME.txt files in the specified directory and all its subdirectories - - /absolute/path/to/*/README.md # Find all README.md files in all immediate subdirectories of the specified directory (depth=1) \ No newline at end of file + - /absolute/path/to/*/README.md # Find all README.md files in all immediate subdirectories of the specified directory (depth=1) diff --git a/config.example.yaml b/config.example.yaml index 87b8082..046df36 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -21,7 +21,7 @@ use_tools: null # Which tools to use by default. (e.g. 'fs,web_ # ---- prelude ---- repl_prelude: null # Set a default role or session for REPL mode (e.g. role:, session:, :) cmd_prelude: null # Set a default role or session for CMD mode (e.g. role:, session:, :) -agent_prelude: null # Set a session to use when starting an agent (e.g. temp, default) +agent_session: null # Set a session to use when starting an agent (e.g. temp, default) # ---- session ---- # Controls the persistence of the session. if true, auto save; if false, not save; if null, asking the user diff --git a/src/config/agent.rs b/src/config/agent.rs index df27da9..e9d8bc0 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -2,11 +2,11 @@ use super::*; use crate::{ client::Model, - function::{run_llm_function, Functions}, + function::{Functions, run_llm_function}, }; use anyhow::{Context, Result}; -use inquire::{validator::Validation, Text}; +use inquire::{Text, validator::Validation}; use rust_embed::Embed; use serde::{Deserialize, Serialize}; use std::{fs::read_to_string, path::Path}; @@ -283,8 +283,8 @@ impl Agent { output } - pub fn agent_prelude(&self) -> Option<&str> { - self.config.agent_prelude.as_deref() + pub fn agent_session(&self) -> Option<&str> { + self.config.agent_session.as_deref() } pub fn variables(&self) -> &AgentVariables { @@ -446,7 +446,7 @@ pub struct AgentConfig { #[serde(skip_serializing_if = "Option::is_none")] pub top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub agent_prelude: Option, + pub agent_session: Option, #[serde(default)] pub description: String, #[serde(default)] @@ -481,8 +481,8 @@ impl AgentConfig { let name = &self.name; let with_prefix = |v: &str| normalize_env_name(&format!("{name}_{v}")); - if self.agent_prelude.is_none() { - self.agent_prelude = config.agent_prelude.clone(); + if self.agent_session.is_none() { + self.agent_session = config.agent_session.clone(); } if let Some(v) = read_env_value::(&with_prefix("model")) { @@ -494,8 +494,8 @@ impl AgentConfig { if let Some(v) = read_env_value::(&with_prefix("top_p")) { self.top_p = v; } - if let Some(v) = read_env_value::(&with_prefix("agent_prelude")) { - self.agent_prelude = v; + if let Some(v) = read_env_value::(&with_prefix("agent_session")) { + self.agent_session = v; } if let Ok(v) = env::var(with_prefix("variables")) { if let Ok(v) = serde_json::from_str(&v) { diff --git a/src/config/mod.rs b/src/config/mod.rs index d4e794a..f6309e4 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -3,17 +3,17 @@ mod input; mod role; mod session; -pub use self::agent::{complete_agent_variables, list_agents, Agent, AgentVariables}; +pub use self::agent::{Agent, AgentVariables, complete_agent_variables, list_agents}; pub use self::input::Input; pub use self::role::{ - Role, RoleLike, CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, SHELL_ROLE, + CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, Role, RoleLike, SHELL_ROLE, }; use self::session::Session; use mem::take; use crate::client::{ - create_client_config, list_client_types, list_models, ClientConfig, MessageContentToolCalls, - Model, ModelType, ProviderModels, OPENAI_COMPATIBLE_PROVIDERS, + ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS, + ProviderModels, create_client_config, list_client_types, list_models, }; use crate::function::{FunctionDeclaration, Functions, ToolResult}; use crate::rag::Rag; @@ -22,11 +22,11 @@ use crate::repl::{run_repl_command, split_args_text}; use crate::utils::*; use crate::mcp::{ - McpRegistry, MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX, + MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX, McpRegistry, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use indexmap::IndexMap; -use inquire::{list_option::ListOption, validator::Validation, Confirm, MultiSelect, Select, Text}; +use inquire::{Confirm, MultiSelect, Select, Text, list_option::ListOption, validator::Validation}; use log::LevelFilter; use parking_lot::RwLock; use serde::{Deserialize, Serialize}; @@ -35,7 +35,7 @@ use std::collections::{HashMap, HashSet}; use std::{ env, fs::{ - create_dir_all, read_dir, read_to_string, remove_dir_all, remove_file, File, OpenOptions, + File, OpenOptions, create_dir_all, read_dir, read_to_string, remove_dir_all, remove_file, }, io::Write, mem, @@ -44,7 +44,7 @@ use std::{ sync::{Arc, OnceLock}, }; use syntect::highlighting::ThemeSet; -use terminal_colorsaurus::{color_scheme, ColorScheme, QueryOptions}; +use terminal_colorsaurus::{ColorScheme, QueryOptions, color_scheme}; use tokio::runtime::Handle; pub const TEMP_ROLE_NAME: &str = "temp"; @@ -131,7 +131,7 @@ pub struct Config { pub repl_prelude: Option, pub cmd_prelude: Option, - pub agent_prelude: Option, + pub agent_session: Option, pub save_session: Option, pub compress_threshold: usize, @@ -213,7 +213,7 @@ impl Default for Config { repl_prelude: None, cmd_prelude: None, - agent_prelude: None, + agent_session: None, save_session: None, compress_threshold: 4000, @@ -1629,7 +1629,7 @@ impl Config { if config.read().macro_flag { None } else { - agent.agent_prelude().map(|v| v.to_string()) + agent.agent_session().map(|v| v.to_string()) } }); config.write().rag = agent.rag(); @@ -2557,8 +2557,8 @@ impl Config { if let Some(v) = read_env_value::(&get_env_name("cmd_prelude")) { self.cmd_prelude = v; } - if let Some(v) = read_env_value::(&get_env_name("agent_prelude")) { - self.agent_prelude = v; + if let Some(v) = read_env_value::(&get_env_name("agent_session")) { + self.agent_session = v; } if let Some(v) = read_env_bool(&get_env_name("save_session")) {