Skip to content

Commit e1eae9b

Browse files
authored
feat: add agent template tui flows (#2113)
1 parent fae141c commit e1eae9b

6 files changed

Lines changed: 591 additions & 10 deletions

File tree

src/client.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,19 @@ impl LocalClient {
592592
}
593593

594594
pub async fn create_agent(&self, agent_id: &str) -> Result<Value> {
595+
self.create_agent_with_template(agent_id, None).await
596+
}
597+
598+
pub async fn create_agent_with_template(
599+
&self,
600+
agent_id: &str,
601+
template: Option<String>,
602+
) -> Result<Value> {
595603
self.post_control_json(
596604
&format!("/control/agents/{agent_id}/create"),
597605
&CreateAgentRequest {
598606
authority_class: Some(AuthorityClass::OperatorInstruction),
599-
template: None,
607+
template,
600608
},
601609
)
602610
.await
@@ -701,6 +709,44 @@ impl LocalClient {
701709
.with_context(|| format!("failed to decode response body for GET {}", path))
702710
}
703711

712+
pub async fn templates_catalog(&self) -> Result<Value> {
713+
let path = api_path("/templates/catalog");
714+
let body = self.send(RequestSpec::get(&path), false).await?;
715+
serde_json::from_slice(&body)
716+
.with_context(|| format!("failed to decode response body for GET {}", path))
717+
}
718+
719+
pub async fn install_template(&self, github_url: impl Into<String>) -> Result<Value> {
720+
self.post_control_json(
721+
"/control/templates/install",
722+
&crate::types::InstallTemplateRequest {
723+
github_url: github_url.into(),
724+
},
725+
)
726+
.await
727+
}
728+
729+
pub async fn remove_template(&self, template_id: &str) -> Result<Value> {
730+
self.post_control_json(
731+
"/control/templates/remove",
732+
&crate::types::RemoveTemplateRequest {
733+
template_id: template_id.to_string(),
734+
},
735+
)
736+
.await
737+
}
738+
739+
pub async fn sync_template_remote_sources(&self) -> Result<Value> {
740+
self.post_json(
741+
"/templates/remote-sources/sync",
742+
&crate::types::SyncTemplateRemoteSourcesRequest {
743+
source_id: None,
744+
force: false,
745+
},
746+
)
747+
.await
748+
}
749+
704750
pub async fn add_skill(&self, kind: crate::types::SkillInstallKind) -> Result<Value> {
705751
self.post_control_json(
706752
"/skills/catalog/add",

src/tui.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use crate::{
1010
system::{workspace_access_mode_label, workspace_projection_label},
1111
tui_markdown::{render_markdown_text, render_markdown_text_spaced},
1212
types::{
13-
AgentListEntry, AgentSummary, AuthorityClass, MessageBody, OperatorMessageRecord,
14-
OperatorMessageStatus, ResolvedModelAvailability, SkillCatalogEntry, SkillScope,
15-
TaskRecord,
13+
AgentListEntry, AgentSummary, AgentTemplateCatalogEntry, AgentTemplateSourceKind,
14+
AuthorityClass, MessageBody, OperatorMessageRecord, OperatorMessageStatus,
15+
ResolvedModelAvailability, SkillCatalogEntry, SkillScope, TaskRecord,
1616
},
1717
};
1818
use anyhow::{anyhow, Result};

0 commit comments

Comments
 (0)