Retrieve output from background bash shells.
| 439 | |
| 440 | |
| 441 | class BashOutputTool(Tool): |
| 442 | """Retrieve output from background bash shells.""" |
| 443 | |
| 444 | @property |
| 445 | def name(self) -> str: |
| 446 | return "bash_output" |
| 447 | |
| 448 | @property |
| 449 | def description(self) -> str: |
| 450 | return """Retrieves output from a running or completed background bash shell. |
| 451 | |
| 452 | - Takes a bash_id parameter identifying the shell |
| 453 | - Always returns only new output since the last check |
| 454 | - Returns stdout and stderr output along with shell status |
| 455 | - Supports optional regex filtering to show only lines matching a pattern |
| 456 | - Use this tool when you need to monitor or check the output of a long-running shell |
| 457 | - Shell IDs can be found using the bash tool with run_in_background=true |
| 458 | |
| 459 | Process status values: |
| 460 | - "running": Still executing |
| 461 | - "completed": Finished successfully |
| 462 | - "failed": Finished with error |
| 463 | - "terminated": Was terminated |
| 464 | - "error": Error occurred |
| 465 | |
| 466 | Example: bash_output(bash_id="abc12345")""" |
| 467 | |
| 468 | @property |
| 469 | def parameters(self) -> dict[str, Any]: |
| 470 | return { |
| 471 | "type": "object", |
| 472 | "properties": { |
| 473 | "bash_id": { |
| 474 | "type": "string", |
| 475 | "description": "The ID of the background shell to retrieve output from. Shell IDs are returned when starting a command with run_in_background=true.", |
| 476 | }, |
| 477 | "filter_str": { |
| 478 | "type": "string", |
| 479 | "description": "Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result. Any lines that do not match will no longer be available to read.", |
| 480 | }, |
| 481 | }, |
| 482 | "required": ["bash_id"], |
| 483 | } |
| 484 | |
| 485 | async def execute( |
| 486 | self, |
| 487 | bash_id: str, |
| 488 | filter_str: str | None = None, |
| 489 | ) -> BashOutputResult: |
| 490 | """Retrieve output from background shell. |
| 491 | |
| 492 | Args: |
| 493 | bash_id: The unique identifier of the background shell |
| 494 | filter_str: Optional regex pattern to filter output lines |
| 495 | |
| 496 | Returns: |
| 497 | BashOutputResult with shell output including stdout, stderr, status, and success flag |
| 498 | """ |
no outgoing calls