MCPcopy Create free account
hub / github.com/GCWing/BitFun / run_external_client

Function run_external_client

src/apps/cli/src/acp_cli.rs:340–418  ·  view source on GitHub ↗
(
    client: ExternalAcpClient,
    prompt: String,
    workspace: Option<String>,
    timeout: u64,
    permission: CliAcpPermissionMode,
)

Source from the content-addressed store, hash-verified

338}
339
340pub async fn run_external_client(
341 client: ExternalAcpClient,
342 prompt: String,
343 workspace: Option<String>,
344 timeout: u64,
345 permission: CliAcpPermissionMode,
346) -> Result<()> {
347 if matches!(permission, CliAcpPermissionMode::Ask) {
348 bail!(
349 "`--permission ask` is not available for non-interactive `acp run`; use allow-once or reject-once."
350 );
351 }
352
353 let prompt = prompt.trim().to_string();
354 if prompt.is_empty() {
355 bail!("Prompt cannot be empty");
356 }
357
358 let service = create_client_service().await?;
359 let client_id = client.id();
360 let base_config_json = update_client_config_json(
361 load_client_config_json(&service).await?,
362 client_id,
363 Some(client.config()),
364 true,
365 None,
366 )?;
367 save_client_config_json(&service, &base_config_json).await?;
368
369 let run_config_json = update_client_config_json(
370 base_config_json.clone(),
371 client_id,
372 None,
373 true,
374 Some(permission.to_config_mode()),
375 )?;
376 if run_config_json != base_config_json {
377 save_client_config_json(&service, &run_config_json).await?;
378 }
379
380 let workspace_path = match workspace {
381 Some(path) => path,
382 None => std::env::current_dir()
383 .context("Failed to resolve current directory")?
384 .to_string_lossy()
385 .to_string(),
386 };
387 let session_id = format!("cli_acp_{}_{}", client_id, uuid::Uuid::new_v4());
388
389 eprintln!(
390 "Starting external ACP agent '{}' in {}",
391 client_id, workspace_path
392 );
393 let result = service
394 .prompt_agent(
395 client_id,
396 prompt,
397 Some(workspace_path),

Callers 1

run_cliFunction · 0.85

Calls 13

create_client_serviceFunction · 0.85
load_client_config_jsonFunction · 0.85
save_client_config_jsonFunction · 0.85
trimMethod · 0.80
to_config_modeMethod · 0.80
contextMethod · 0.80
prompt_agentMethod · 0.80
stop_clientMethod · 0.80
is_emptyMethod · 0.45
idMethod · 0.45
configMethod · 0.45

Tested by

no test coverage detected