quantalogic 0.2.27__tar.gz → 0.2.29__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {quantalogic-0.2.27 → quantalogic-0.2.29}/PKG-INFO +3 -1
  2. {quantalogic-0.2.27 → quantalogic-0.2.29}/README.md +2 -0
  3. {quantalogic-0.2.27 → quantalogic-0.2.29}/pyproject.toml +1 -1
  4. quantalogic-0.2.29/quantalogic/tools/execute_bash_command_tool.py +133 -0
  5. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/replace_in_file_tool.py +23 -13
  6. quantalogic-0.2.27/quantalogic/tools/execute_bash_command_tool.py +0 -116
  7. {quantalogic-0.2.27 → quantalogic-0.2.29}/LICENSE +0 -0
  8. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/__init__.py +0 -0
  9. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/agent.py +0 -0
  10. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/agent_config.py +0 -0
  11. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/agent_factory.py +0 -0
  12. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/coding_agent.py +0 -0
  13. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/console_print_events.py +0 -0
  14. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/console_print_token.py +0 -0
  15. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/docs_cli.py +0 -0
  16. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/event_emitter.py +0 -0
  17. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/generative_model.py +0 -0
  18. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/get_model_info.py +0 -0
  19. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/interactive_text_editor.py +0 -0
  20. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/main.py +0 -0
  21. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/memory.py +0 -0
  22. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/model_names.py +0 -0
  23. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/prompts.py +0 -0
  24. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/search_agent.py +0 -0
  25. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/__init__.py +0 -0
  26. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/agent_server.py +0 -0
  27. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/models.py +0 -0
  28. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/routes.py +0 -0
  29. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/state.py +0 -0
  30. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/static/js/event_visualizer.js +0 -0
  31. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/static/js/quantalogic.js +0 -0
  32. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/server/templates/index.html +0 -0
  33. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/task_file_reader.py +0 -0
  34. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/task_runner.py +0 -0
  35. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tool_manager.py +0 -0
  36. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/__init__.py +0 -0
  37. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/agent_tool.py +0 -0
  38. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/dalle_e.py +0 -0
  39. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/download_http_file_tool.py +0 -0
  40. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/duckduckgo_search_tool.py +0 -0
  41. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/edit_whole_content_tool.py +0 -0
  42. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/elixir_tool.py +0 -0
  43. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/generate_database_report_tool.py +0 -0
  44. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/grep_app_tool.py +0 -0
  45. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/input_question_tool.py +0 -0
  46. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/jinja_tool.py +0 -0
  47. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/__init__.py +0 -0
  48. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/c_handler.py +0 -0
  49. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/cpp_handler.py +0 -0
  50. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/go_handler.py +0 -0
  51. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/java_handler.py +0 -0
  52. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/javascript_handler.py +0 -0
  53. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/python_handler.py +0 -0
  54. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/rust_handler.py +0 -0
  55. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/scala_handler.py +0 -0
  56. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/language_handlers/typescript_handler.py +0 -0
  57. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/list_directory_tool.py +0 -0
  58. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/llm_tool.py +0 -0
  59. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/llm_vision_tool.py +0 -0
  60. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/markitdown_tool.py +0 -0
  61. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/nodejs_tool.py +0 -0
  62. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/python_tool.py +0 -0
  63. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/read_file_block_tool.py +0 -0
  64. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/read_file_tool.py +0 -0
  65. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/read_html_tool.py +0 -0
  66. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/ripgrep_tool.py +0 -0
  67. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/search_definition_names.py +0 -0
  68. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/serpapi_search_tool.py +0 -0
  69. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/sql_query_tool.py +0 -0
  70. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/task_complete_tool.py +0 -0
  71. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/tool.py +0 -0
  72. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/unified_diff_tool.py +0 -0
  73. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/utils/__init__.py +0 -0
  74. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/utils/create_sample_database.py +0 -0
  75. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/utils/generate_database_report.py +0 -0
  76. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/wikipedia_search_tool.py +0 -0
  77. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/tools/write_file_tool.py +0 -0
  78. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/__init__.py +0 -0
  79. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/ask_user_validation.py +0 -0
  80. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/check_version.py +0 -0
  81. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/download_http_file.py +0 -0
  82. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/get_coding_environment.py +0 -0
  83. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/get_environment.py +0 -0
  84. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/get_quantalogic_rules_content.py +0 -0
  85. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/git_ls.py +0 -0
  86. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/read_file.py +0 -0
  87. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/utils/read_http_text_content.py +0 -0
  88. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/version.py +0 -0
  89. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/version_check.py +0 -0
  90. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/welcome_message.py +0 -0
  91. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/xml_parser.py +0 -0
  92. {quantalogic-0.2.27 → quantalogic-0.2.29}/quantalogic/xml_tool_parser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantalogic
3
- Version: 0.2.27
3
+ Version: 0.2.29
4
4
  Summary: QuantaLogic ReAct Agents
5
5
  Author: Raphaël MANSUY
6
6
  Author-email: raphael.mansuy@gmail.com
@@ -63,8 +63,10 @@ Description-Content-Type: text/markdown
63
63
  [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://quantalogic.github.io/quantalogic/)
64
64
 
65
65
 
66
+
66
67
  QuantaLogic is a ReAct (Reasoning & Action) framework for building advanced AI agents.
67
68
 
69
+
68
70
  It seamlessly integrates large language models (LLMs) with a robust tool system, enabling agents to understand, reason about, and execute complex tasks through natural language interaction.
69
71
 
70
72
  The `cli` version include coding capabilities comparable to Aider.
@@ -5,8 +5,10 @@
5
5
  [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://quantalogic.github.io/quantalogic/)
6
6
 
7
7
 
8
+
8
9
  QuantaLogic is a ReAct (Reasoning & Action) framework for building advanced AI agents.
9
10
 
11
+
10
12
  It seamlessly integrates large language models (LLMs) with a robust tool system, enabling agents to understand, reason about, and execute complex tasks through natural language interaction.
11
13
 
12
14
  The `cli` version include coding capabilities comparable to Aider.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "quantalogic"
3
- version = "0.2.27"
3
+ version = "0.2.29"
4
4
  description = "QuantaLogic ReAct Agents"
5
5
  authors = ["Raphaël MANSUY <raphael.mansuy@gmail.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,133 @@
1
+ """Tool for executing bash commands with interactive input support."""
2
+
3
+ import os
4
+ import pty
5
+ import select
6
+ import signal
7
+ import subprocess
8
+ import sys
9
+ from typing import Dict, Optional, Union
10
+
11
+ from quantalogic.tools.tool import Tool, ToolArgument
12
+
13
+
14
+ class ExecuteBashCommandTool(Tool):
15
+ """Tool for executing bash commands with real-time I/O handling."""
16
+
17
+ name: str = "execute_bash_tool"
18
+ description: str = "Executes a bash command and returns its output."
19
+ need_validation: bool = True
20
+ arguments: list = [
21
+ ToolArgument(
22
+ name="command",
23
+ arg_type="string",
24
+ description="The bash command to execute.",
25
+ required=True,
26
+ example="ls -la",
27
+ ),
28
+ ToolArgument(
29
+ name="working_dir",
30
+ arg_type="string",
31
+ description="The working directory where the command will be executed. Defaults to the current directory.",
32
+ required=False,
33
+ example="/path/to/directory",
34
+ ),
35
+ ToolArgument(
36
+ name="timeout",
37
+ arg_type="int",
38
+ description="Maximum time in seconds to wait for the command to complete. Defaults to 60 seconds.",
39
+ required=False,
40
+ example="60",
41
+ ),
42
+ ]
43
+
44
+ def execute(
45
+ self,
46
+ command: str,
47
+ working_dir: Optional[str] = None,
48
+ timeout: Union[int, str, None] = 60,
49
+ env: Optional[Dict[str, str]] = None,
50
+ ) -> str:
51
+ """Executes a bash command with interactive input handling."""
52
+ timeout_seconds = int(timeout) if timeout else 60
53
+ cwd = working_dir or os.getcwd()
54
+ env_vars = os.environ.copy()
55
+ if env:
56
+ env_vars.update(env)
57
+
58
+ try:
59
+ master, slave = pty.openpty()
60
+ proc = subprocess.Popen(
61
+ command,
62
+ shell=True,
63
+ stdin=slave,
64
+ stdout=slave,
65
+ stderr=subprocess.STDOUT,
66
+ cwd=cwd,
67
+ env=env_vars,
68
+ preexec_fn=os.setsid,
69
+ close_fds=True,
70
+ )
71
+ os.close(slave)
72
+
73
+ stdout_buffer = []
74
+ break_loop = False
75
+
76
+ try:
77
+ while True:
78
+ rlist, _, _ = select.select([master, sys.stdin], [], [], timeout_seconds)
79
+ if not rlist:
80
+ if proc.poll() is not None:
81
+ break # Process completed but select timed out
82
+ raise subprocess.TimeoutExpired(command, timeout_seconds)
83
+
84
+ for fd in rlist:
85
+ if fd == master:
86
+ data = os.read(master, 1024).decode()
87
+ if not data:
88
+ break_loop = True
89
+ break
90
+ stdout_buffer.append(data)
91
+ sys.stdout.write(data)
92
+ sys.stdout.flush()
93
+ elif fd == sys.stdin:
94
+ user_input = os.read(sys.stdin.fileno(), 1024)
95
+ os.write(master, user_input)
96
+
97
+ # Check if process completed or EOF received
98
+ if break_loop or proc.poll() is not None:
99
+ # Read any remaining output
100
+ while True:
101
+ data = os.read(master, 1024).decode()
102
+ if not data:
103
+ break
104
+ stdout_buffer.append(data)
105
+ sys.stdout.write(data)
106
+ sys.stdout.flush()
107
+ break
108
+
109
+ except subprocess.TimeoutExpired:
110
+ os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
111
+ return f"Command timed out after {timeout_seconds} seconds."
112
+ except EOFError:
113
+ pass # Process exited normally
114
+ finally:
115
+ os.close(master)
116
+ proc.wait()
117
+
118
+ stdout_content = ''.join(stdout_buffer)
119
+ return_code = proc.returncode
120
+ formatted_result = (
121
+ "<command_output>"
122
+ f" <stdout>{stdout_content.strip()}</stdout>"
123
+ f" <returncode>{return_code}</returncode>"
124
+ f"</command_output>"
125
+ )
126
+ return formatted_result
127
+ except Exception as e:
128
+ return f"Unexpected error executing command: {str(e)}"
129
+
130
+
131
+ if __name__ == "__main__":
132
+ tool = ExecuteBashCommandTool()
133
+ print(tool.to_markdown())
@@ -65,7 +65,6 @@ class ReplaceInFileTool(Tool):
65
65
  )
66
66
  need_validation: bool = True
67
67
 
68
- # Adjust this threshold to allow more or less approximate matching
69
68
  SIMILARITY_THRESHOLD: float = 0.85
70
69
 
71
70
  arguments: list[ToolArgument] = [
@@ -124,6 +123,15 @@ class ReplaceInFileTool(Tool):
124
123
  ),
125
124
  ]
126
125
 
126
+ def normalize_whitespace(self, text: str) -> str:
127
+ """Normalize leading whitespace by converting tabs to spaces."""
128
+ return '\n'.join([self._normalize_line(line) for line in text.split('\n')])
129
+
130
+ def _normalize_line(self, line: str) -> str:
131
+ """Normalize leading whitespace in a single line."""
132
+ leading_ws = len(line) - len(line.lstrip())
133
+ return line.replace('\t', ' ', leading_ws) # Convert tabs to 4 spaces only in leading whitespace
134
+
127
135
  def parse_diff(self, diff: str) -> list[SearchReplaceBlock]:
128
136
  """Parses the diff string into a list of SearchReplaceBlock instances."""
129
137
  if not diff or not diff.strip():
@@ -250,6 +258,7 @@ class ReplaceInFileTool(Tool):
250
258
  except Exception as e:
251
259
  return f"Error: Failed to write changes to '{path}': {str(e) or 'Unknown error'}"
252
260
 
261
+ # Maintain original success message format
253
262
  message = [f"Successfully modified '{path}'"]
254
263
  for idx, block in enumerate(blocks, 1):
255
264
  status = "Exact match" if block.similarity is None else f"Similar match ({block.similarity:.1%})"
@@ -267,26 +276,27 @@ class ReplaceInFileTool(Tool):
267
276
  return f"Error: Unexpected error occurred - {error_msg or 'Unknown error'}"
268
277
 
269
278
  def find_similar_match(self, search: str, content: str) -> Tuple[float, str]:
270
- """Finds the most similar substring in content compared to search."""
271
- if not search or not content:
272
- return 0.0, ""
273
-
274
- search_lines = search.splitlines()
275
- content_lines = content.splitlines()
279
+ """Finds the most similar substring in content compared to search with whitespace normalization."""
280
+ norm_search = self.normalize_whitespace(search)
281
+ content_lines = content.split('\n')
282
+ norm_content = self.normalize_whitespace(content)
283
+ norm_content_lines = norm_content.split('\n')
276
284
 
277
- if len(search_lines) > len(content_lines):
285
+ if len(norm_content_lines) < len(norm_search.split('\n')):
278
286
  return 0.0, ""
279
287
 
280
288
  max_similarity = 0.0
281
289
  best_match = ""
290
+ search_line_count = len(norm_search.split('\n'))
282
291
 
283
- for i in range(len(content_lines) - len(search_lines) + 1):
284
- candidate = "\n".join(content_lines[i : i + len(search_lines)])
285
- similarity = difflib.SequenceMatcher(None, search, candidate).ratio()
292
+ for i in range(len(norm_content_lines) - search_line_count + 1):
293
+ candidate_norm = '\n'.join(norm_content_lines[i:i+search_line_count])
294
+ similarity = difflib.SequenceMatcher(None, norm_search, candidate_norm).ratio()
286
295
 
287
296
  if similarity > max_similarity:
288
297
  max_similarity = similarity
289
- best_match = candidate
298
+ # Get original lines (non-normalized) for accurate replacement
299
+ best_match = '\n'.join(content_lines[i:i+search_line_count])
290
300
 
291
301
  return max_similarity, best_match
292
302
 
@@ -297,4 +307,4 @@ class ReplaceInFileTool(Tool):
297
307
 
298
308
  if __name__ == "__main__":
299
309
  tool = ReplaceInFileTool()
300
- print(tool.to_markdown())
310
+ print(tool.to_markdown())
@@ -1,116 +0,0 @@
1
- """Tool for executing bash commands and capturing their output."""
2
-
3
- import os
4
- import subprocess
5
- from typing import Dict, Optional, Union
6
-
7
- from quantalogic.tools.tool import Tool, ToolArgument
8
-
9
-
10
- class ExecuteBashCommandTool(Tool):
11
- """Tool for executing bash commands and capturing their output."""
12
-
13
- name: str = "execute_bash_tool"
14
- description: str = "Executes a bash command and returns its output."
15
- need_validation: bool = True
16
- arguments: list = [
17
- ToolArgument(
18
- name="command",
19
- arg_type="string",
20
- description="The bash command to execute.",
21
- required=True,
22
- example="ls -la",
23
- ),
24
- ToolArgument(
25
- name="working_dir",
26
- arg_type="string",
27
- description="The working directory where the command will be executed. Defaults to the current directory.",
28
- required=False,
29
- example="/path/to/directory",
30
- ),
31
- ToolArgument(
32
- name="timeout",
33
- arg_type="int",
34
- description="Maximum time in seconds to wait for the command to complete. Defaults to 60 seconds.",
35
- required=False,
36
- example="60",
37
- ),
38
- # Removed the `env` argument from ToolArgument since it doesn't support `dict` type
39
- ]
40
-
41
- def execute(
42
- self,
43
- command: str,
44
- working_dir: Optional[str] = None,
45
- timeout: Union[int, str, None] = 60,
46
- env: Optional[Dict[str, str]] = None,
47
- ) -> str:
48
- """Executes a bash command and returns its output.
49
-
50
- Args:
51
- command (str): The bash command to execute.
52
- working_dir (str, optional): Working directory for command execution. Defaults to the current directory.
53
- timeout (int or str, optional): Maximum execution time in seconds. Defaults to 60 seconds.
54
- env (dict, optional): Environment variables to set for the command execution. Defaults to the current environment.
55
-
56
- Returns:
57
- str: The command output or error message.
58
-
59
- Raises:
60
- subprocess.TimeoutExpired: If the command execution exceeds the timeout.
61
- subprocess.CalledProcessError: If the command returns a non-zero exit status.
62
- ValueError: If the timeout cannot be converted to an integer.
63
- """
64
- # Convert timeout to integer, defaulting to 60 if None or invalid
65
- try:
66
- timeout_seconds = int(timeout) if timeout else 60
67
- except (ValueError, TypeError):
68
- timeout_seconds = 60
69
-
70
- # Use the current working directory if no working directory is specified
71
- cwd = working_dir if working_dir else os.getcwd()
72
-
73
- # Use the current environment if no custom environment is specified
74
- env_vars = os.environ.copy()
75
- if env:
76
- env_vars.update(env)
77
-
78
- try:
79
- # Execute the command with specified timeout, working directory, and environment
80
- result = subprocess.run(
81
- command,
82
- shell=True,
83
- cwd=cwd,
84
- capture_output=True,
85
- text=True,
86
- timeout=timeout_seconds,
87
- env=env_vars,
88
- )
89
-
90
- formated_result = (
91
- "<command_output>"
92
- f" <stdout>"
93
- f"{result.stdout.strip()}"
94
- f" </stdout>"
95
- f" <stderr>"
96
- f"{result.stderr.strip()}"
97
- f" </stderr>"
98
- f" <returncode>"
99
- f" {result.returncode}"
100
- f" </returncode>"
101
- f"</command_output>"
102
- )
103
-
104
- return formated_result
105
-
106
- except subprocess.TimeoutExpired:
107
- return f"Command timed out after {timeout_seconds} seconds."
108
- except subprocess.CalledProcessError as e:
109
- return f"Command failed with error: {e.stderr.strip()}"
110
- except Exception as e:
111
- return f"Unexpected error executing command: {str(e)}"
112
-
113
-
114
- if __name__ == "__main__":
115
- tool = ExecuteBashCommandTool()
116
- print(tool.to_markdown())
File without changes