(&mut self, os: &Os, tool_index: usize, trusted: bool)
| 3502 | } |
| 3503 | |
| 3504 | async fn print_tool_description(&mut self, os: &Os, tool_index: usize, trusted: bool) -> Result<(), ChatError> { |
| 3505 | let tool_use = &self.tool_uses[tool_index]; |
| 3506 | |
| 3507 | if self.stderr.should_send_structured_event { |
| 3508 | let tool_call_start = ToolCallStart { |
| 3509 | tool_call_id: tool_use.id.clone(), |
| 3510 | tool_call_name: tool_use.name.clone(), |
| 3511 | mcp_server_name: if let Tool::Custom(ref tool) = tool_use.tool { |
| 3512 | Some(tool.server_name.clone()) |
| 3513 | } else { |
| 3514 | None |
| 3515 | }, |
| 3516 | is_trusted: trusted, |
| 3517 | parent_message_id: None, |
| 3518 | }; |
| 3519 | self.stdout.send(Event::ToolCallStart(tool_call_start))?; |
| 3520 | } else { |
| 3521 | queue!( |
| 3522 | self.stdout, |
| 3523 | StyledText::emphasis_fg(), |
| 3524 | style::Print(format!( |
| 3525 | "🛠️ Using tool: {}{}", |
| 3526 | tool_use.tool.display_name(), |
| 3527 | if trusted { " (trusted)".dark_green() } else { "".reset() } |
| 3528 | )), |
| 3529 | StyledText::reset(), |
| 3530 | )?; |
| 3531 | if let Tool::Custom(ref tool) = tool_use.tool { |
| 3532 | queue!( |
| 3533 | self.stdout, |
| 3534 | StyledText::reset(), |
| 3535 | style::Print(" from mcp server "), |
| 3536 | StyledText::emphasis_fg(), |
| 3537 | style::Print(&tool.server_name), |
| 3538 | StyledText::reset(), |
| 3539 | )?; |
| 3540 | } |
| 3541 | |
| 3542 | execute!( |
| 3543 | self.stdout, |
| 3544 | style::Print("\n"), |
| 3545 | style::Print(CONTINUATION_LINE), |
| 3546 | style::Print("\n"), |
| 3547 | style::Print(TOOL_BULLET) |
| 3548 | )?; |
| 3549 | } |
| 3550 | |
| 3551 | tool_use |
| 3552 | .tool |
| 3553 | .queue_description(os, &mut self.stdout) |
| 3554 | .await |
| 3555 | .map_err(|e| ChatError::Custom(format!("failed to print tool, `{}`: {}", tool_use.name, e).into()))?; |
| 3556 | |
| 3557 | self.stdout.flush()?; |
| 3558 | |
| 3559 | Ok(()) |
| 3560 | } |
| 3561 |
no test coverage detected