Queues up a tool's intention in a human readable format
(&self, os: &Os, output: &mut ControlEnd<DestinationStdout>)
| 168 | |
| 169 | /// Queues up a tool's intention in a human readable format |
| 170 | pub async fn queue_description(&self, os: &Os, output: &mut ControlEnd<DestinationStdout>) -> Result<()> { |
| 171 | if output.should_send_structured_event { |
| 172 | let mut buf = Vec::<u8>::new(); |
| 173 | |
| 174 | match self { |
| 175 | Tool::FsRead(fs_read) => fs_read.queue_description(os, &mut buf).await, |
| 176 | Tool::FsWrite(fs_write) => fs_write.queue_description(os, &mut buf), |
| 177 | Tool::ExecuteCommand(execute_command) => execute_command.queue_description(&mut buf), |
| 178 | Tool::UseAws(use_aws) => use_aws.queue_description(&mut buf), |
| 179 | Tool::Custom(custom_tool) => custom_tool.queue_description(&mut buf), |
| 180 | Tool::GhIssue(gh_issue) => gh_issue.queue_description(&mut buf), |
| 181 | Tool::Introspect(_) => Introspect::queue_description(&mut buf), |
| 182 | Tool::Knowledge(knowledge) => knowledge.queue_description(os, &mut buf).await, |
| 183 | Tool::Thinking(thinking) => thinking.queue_description(&mut buf), |
| 184 | Tool::Todo(_) => Ok(()), |
| 185 | Tool::Delegate(delegate) => delegate.queue_description(&mut buf), |
| 186 | }?; |
| 187 | |
| 188 | let tool_call_args = ToolCallArgs { |
| 189 | // We'll ignore this for now |
| 190 | tool_call_id: Default::default(), |
| 191 | delta: { |
| 192 | let sanitized = strip_ansi_escapes::strip_str(String::from_utf8_lossy(&buf)); |
| 193 | serde_json::Value::String(sanitized) |
| 194 | }, |
| 195 | }; |
| 196 | |
| 197 | output.send(Event::ToolCallArgs(tool_call_args))?; |
| 198 | } else { |
| 199 | match self { |
| 200 | Tool::FsRead(fs_read) => fs_read.queue_description(os, output).await, |
| 201 | Tool::FsWrite(fs_write) => fs_write.queue_description(os, output), |
| 202 | Tool::ExecuteCommand(execute_command) => execute_command.queue_description(output), |
| 203 | Tool::UseAws(use_aws) => use_aws.queue_description(output), |
| 204 | Tool::Custom(custom_tool) => custom_tool.queue_description(output), |
| 205 | Tool::GhIssue(gh_issue) => gh_issue.queue_description(output), |
| 206 | Tool::Introspect(_) => Introspect::queue_description(output), |
| 207 | Tool::Knowledge(knowledge) => knowledge.queue_description(os, output).await, |
| 208 | Tool::Thinking(thinking) => thinking.queue_description(output), |
| 209 | Tool::Todo(_) => Ok(()), |
| 210 | Tool::Delegate(delegate) => delegate.queue_description(output), |
| 211 | }?; |
| 212 | }; |
| 213 | |
| 214 | Ok(()) |
| 215 | } |
| 216 | |
| 217 | /// Validates the tool with the arguments supplied |
| 218 | pub async fn validate(&mut self, os: &Os) -> Result<()> { |
no test coverage detected