skill_web/api/
agent.rs

1//! Agent configuration API client
2
3use super::client::ApiClient;
4use super::error::ApiResult;
5use super::types::*;
6
7/// Agent configuration API operations
8#[derive(Clone)]
9pub struct AgentApi {
10    client: ApiClient,
11}
12
13impl AgentApi {
14    /// Create a new agent API client
15    pub fn new(client: ApiClient) -> Self {
16        Self { client }
17    }
18
19    /// Get agent configuration
20    pub async fn get_config(&self) -> ApiResult<GetAgentConfigResponse> {
21        self.client.get("/agent/config").await
22    }
23
24    /// Update agent configuration
25    pub async fn update_config(
26        &self,
27        request: &UpdateAgentConfigRequest,
28    ) -> ApiResult<AgentConfig> {
29        self.client.put("/agent/config", request).await
30    }
31
32    /// Set agent runtime
33    pub async fn set_runtime(&self, runtime: AgentRuntime) -> ApiResult<AgentConfig> {
34        self.update_config(&UpdateAgentConfigRequest {
35            runtime: Some(runtime),
36            ..Default::default()
37        })
38        .await
39    }
40
41    /// Set model configuration
42    pub async fn set_model_config(
43        &self,
44        model_config: AgentModelConfig,
45    ) -> ApiResult<AgentConfig> {
46        self.update_config(&UpdateAgentConfigRequest {
47            model_config: Some(model_config),
48            ..Default::default()
49        })
50        .await
51    }
52
53    /// Set execution timeout
54    pub async fn set_timeout(&self, timeout_secs: u64) -> ApiResult<AgentConfig> {
55        self.update_config(&UpdateAgentConfigRequest {
56            timeout_secs: Some(timeout_secs),
57            ..Default::default()
58        })
59        .await
60    }
61
62    /// Set Claude Code path override
63    pub async fn set_claude_code_path(&self, path: String) -> ApiResult<AgentConfig> {
64        self.update_config(&UpdateAgentConfigRequest {
65            claude_code_path: Some(path),
66            ..Default::default()
67        })
68        .await
69    }
70}