feat: startup git clone for template repo + pass config through
- ensure_repo_ready() at startup: clone if missing, fetch if exists - TemplateRepoConfig gains local_path field - list_all_templates/select_template/extract_repo_template accept repo config - Remove hardcoded repo_dir(), use config.local_path
This commit is contained in:
13
src/agent.rs
13
src/agent.rs
@@ -73,11 +73,17 @@ pub struct AgentManager {
|
||||
next_port: AtomicU16,
|
||||
pool: SqlitePool,
|
||||
llm_config: LlmConfig,
|
||||
template_repo: Option<crate::TemplateRepoConfig>,
|
||||
kb: Option<Arc<crate::kb::KbManager>>,
|
||||
}
|
||||
|
||||
impl AgentManager {
|
||||
pub fn new(pool: SqlitePool, llm_config: LlmConfig, kb: Option<Arc<crate::kb::KbManager>>) -> Arc<Self> {
|
||||
pub fn new(
|
||||
pool: SqlitePool,
|
||||
llm_config: LlmConfig,
|
||||
template_repo: Option<crate::TemplateRepoConfig>,
|
||||
kb: Option<Arc<crate::kb::KbManager>>,
|
||||
) -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
agents: RwLock::new(HashMap::new()),
|
||||
broadcast: RwLock::new(HashMap::new()),
|
||||
@@ -85,6 +91,7 @@ impl AgentManager {
|
||||
next_port: AtomicU16::new(9100),
|
||||
pool,
|
||||
llm_config,
|
||||
template_repo,
|
||||
kb,
|
||||
})
|
||||
}
|
||||
@@ -211,7 +218,7 @@ async fn agent_loop(
|
||||
tracing::info!("Using forced template: {:?}", forced_template);
|
||||
forced_template
|
||||
} else {
|
||||
template::select_template(&llm, &requirement).await
|
||||
template::select_template(&llm, &requirement, mgr.template_repo.as_ref()).await
|
||||
};
|
||||
let loaded_template = if let Some(ref tid) = template_id {
|
||||
tracing::info!("Template selected for workflow {}: {}", workflow_id, tid);
|
||||
@@ -219,7 +226,7 @@ async fn agent_loop(
|
||||
|
||||
if template::is_repo_template(tid) {
|
||||
// Repo template: extract from git then load
|
||||
match template::extract_repo_template(tid).await {
|
||||
match template::extract_repo_template(tid, mgr.template_repo.as_ref()).await {
|
||||
Ok(template_dir) => {
|
||||
if let Err(e) = template::apply_template(&template_dir, &workdir).await {
|
||||
tracing::error!("Failed to apply repo template {}: {}", tid, e);
|
||||
|
||||
Reference in New Issue
Block a user