(command: str)
| 121 | |
| 122 | |
| 123 | def _validate_bash_command(command: str) -> None: |
| 124 | result = subprocess.run( |
| 125 | ["/bin/bash", "-n"], |
| 126 | input=command, |
| 127 | text=True, |
| 128 | capture_output=True, |
| 129 | encoding="utf-8", |
| 130 | errors="replace", |
| 131 | check=False, |
| 132 | ) |
| 133 | if result.returncode == 0: |
| 134 | return |
| 135 | error = (result.stderr or result.stdout or "bash syntax check failed").strip() |
| 136 | raise ValueError(f"Invalid bash_command syntax: {error}") |
| 137 | |
| 138 | |
| 139 | def text_part(text: str) -> dict[str, Any]: |