MCPcopy Create free account
hub / github.com/enowdev/enowX-Coder / run_agent

Function run_agent

src-tauri/src/commands/agent.rs:45–81  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    app_handle: AppHandle,
    request: RunAgentRequest,
    on_token: Channel<String>,
)

Source from the content-addressed store, hash-verified

43
44#[tauri::command]
45pub async fn run_agent(
46 state: State<'_, AppState>,
47 app_handle: AppHandle,
48 request: RunAgentRequest,
49 on_token: Channel<String>,
50) -> AppResult<()> {
51 let cancel_token = state.cancellations.register(format!("agent:{}", request.session_id));
52
53 let runner = AgentRunner::new(
54 state.pool().clone(),
55 app_handle,
56 state.permissions.clone(),
57 cancel_token,
58 );
59
60 let params = AgentRunParams {
61 session_id: &request.session_id,
62 agent_type: &request.agent_type,
63 task: &request.task,
64 project_path: &request.project_path,
65 provider_id: request.provider_id.as_deref(),
66 model_id: request.model_id.as_deref(),
67 flux_enabled: request.flux_enabled,
68 };
69
70 let result = runner.run(params, on_token).await;
71
72 // Cleanup
73 state.cancellations.remove(&format!("agent:{}", request.session_id));
74
75 // Swallow Cancelled errors — they are expected when user stops generation
76 match result {
77 Ok(_) => Ok(()),
78 Err(crate::error::AppError::Cancelled) => Ok(()),
79 Err(e) => Err(e),
80 }
81}
82
83#[tauri::command]
84pub async fn cancel_agent(state: State<'_, AppState>, id: String) -> AppResult<()> {

Callers

nothing calls this directly

Calls 4

registerMethod · 0.80
poolMethod · 0.80
runMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected