quantalogic 0.2.29__tar.gz → 0.2.30__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.
- {quantalogic-0.2.29 → quantalogic-0.2.30}/PKG-INFO +1 -1
- {quantalogic-0.2.29 → quantalogic-0.2.30}/pyproject.toml +1 -1
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/main.py +49 -2
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/execute_bash_command_tool.py +80 -13
- {quantalogic-0.2.29 → quantalogic-0.2.30}/LICENSE +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/README.md +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/agent.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/agent_config.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/agent_factory.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/coding_agent.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/console_print_events.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/console_print_token.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/docs_cli.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/event_emitter.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/generative_model.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/get_model_info.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/interactive_text_editor.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/memory.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/model_names.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/prompts.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/search_agent.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/agent_server.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/models.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/routes.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/state.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/static/js/event_visualizer.js +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/static/js/quantalogic.js +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/server/templates/index.html +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/task_file_reader.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/task_runner.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tool_manager.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/agent_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/dalle_e.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/download_http_file_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/duckduckgo_search_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/edit_whole_content_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/elixir_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/generate_database_report_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/grep_app_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/input_question_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/jinja_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/c_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/cpp_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/go_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/java_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/javascript_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/python_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/rust_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/scala_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/typescript_handler.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/list_directory_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/llm_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/llm_vision_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/markitdown_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/nodejs_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/python_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/read_file_block_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/read_file_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/read_html_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/replace_in_file_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/ripgrep_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/search_definition_names.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/serpapi_search_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/sql_query_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/task_complete_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/unified_diff_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/utils/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/utils/create_sample_database.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/utils/generate_database_report.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/wikipedia_search_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/write_file_tool.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/__init__.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/ask_user_validation.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/check_version.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/download_http_file.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/get_coding_environment.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/get_environment.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/get_quantalogic_rules_content.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/git_ls.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/read_file.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/read_http_text_content.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/version.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/version_check.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/welcome_message.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/xml_parser.py +0 -0
- {quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/xml_tool_parser.py +0 -0
@@ -23,9 +23,52 @@ from quantalogic.agent_config import ( # noqa: E402
|
|
23
23
|
)
|
24
24
|
from quantalogic.task_runner import task_runner # noqa: E402
|
25
25
|
|
26
|
+
# Platform-specific imports
|
27
|
+
try:
|
28
|
+
if sys.platform == 'win32':
|
29
|
+
import msvcrt # Built-in Windows module
|
30
|
+
else:
|
31
|
+
import termios
|
32
|
+
import tty
|
33
|
+
except ImportError as e:
|
34
|
+
logger.warning(f"Could not import platform-specific module: {e}")
|
35
|
+
# Fall back to basic terminal handling if imports fail
|
36
|
+
msvcrt = None
|
37
|
+
termios = None
|
38
|
+
tty = None
|
39
|
+
|
26
40
|
AGENT_MODES = ["code", "basic", "interpreter", "full", "code-basic", "search", "search-full"]
|
27
41
|
|
28
42
|
|
43
|
+
def setup_terminal():
|
44
|
+
"""Configure terminal settings based on platform."""
|
45
|
+
if sys.platform == 'win32':
|
46
|
+
if msvcrt:
|
47
|
+
return None # Windows terminal is already configured
|
48
|
+
logger.warning("msvcrt module not available on Windows")
|
49
|
+
return None
|
50
|
+
else:
|
51
|
+
if termios and tty:
|
52
|
+
try:
|
53
|
+
fd = sys.stdin.fileno()
|
54
|
+
old_settings = termios.tcgetattr(fd)
|
55
|
+
tty.setraw(fd)
|
56
|
+
return old_settings
|
57
|
+
except (termios.error, AttributeError) as e:
|
58
|
+
logger.warning(f"Failed to configure terminal: {e}")
|
59
|
+
return None
|
60
|
+
return None
|
61
|
+
|
62
|
+
|
63
|
+
def restore_terminal(old_settings):
|
64
|
+
"""Restore terminal settings based on platform."""
|
65
|
+
if sys.platform != 'win32' and termios and old_settings:
|
66
|
+
try:
|
67
|
+
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, old_settings)
|
68
|
+
except (termios.error, AttributeError) as e:
|
69
|
+
logger.warning(f"Failed to restore terminal settings: {e}")
|
70
|
+
|
71
|
+
|
29
72
|
@click.group(invoke_without_command=True)
|
30
73
|
@click.option(
|
31
74
|
"--compact-every-n-iteration",
|
@@ -181,8 +224,12 @@ def task(
|
|
181
224
|
|
182
225
|
|
183
226
|
def main():
|
184
|
-
"""Main
|
185
|
-
|
227
|
+
"""Main entry point."""
|
228
|
+
old_settings = setup_terminal()
|
229
|
+
try:
|
230
|
+
cli() # type: ignore
|
231
|
+
finally:
|
232
|
+
restore_terminal(old_settings)
|
186
233
|
|
187
234
|
|
188
235
|
if __name__ == "__main__":
|
@@ -1,13 +1,22 @@
|
|
1
1
|
"""Tool for executing bash commands with interactive input support."""
|
2
2
|
|
3
3
|
import os
|
4
|
-
import pty
|
5
4
|
import select
|
6
5
|
import signal
|
7
6
|
import subprocess
|
8
7
|
import sys
|
9
8
|
from typing import Dict, Optional, Union
|
10
9
|
|
10
|
+
from loguru import logger
|
11
|
+
|
12
|
+
# Platform-specific imports
|
13
|
+
try:
|
14
|
+
if sys.platform != 'win32':
|
15
|
+
import pty
|
16
|
+
except ImportError as e:
|
17
|
+
logger.warning(f"Could not import platform-specific module: {e}")
|
18
|
+
pty = None
|
19
|
+
|
11
20
|
from quantalogic.tools.tool import Tool, ToolArgument
|
12
21
|
|
13
22
|
|
@@ -41,20 +50,58 @@ class ExecuteBashCommandTool(Tool):
|
|
41
50
|
),
|
42
51
|
]
|
43
52
|
|
44
|
-
def
|
53
|
+
def _execute_windows(
|
45
54
|
self,
|
46
55
|
command: str,
|
47
|
-
|
48
|
-
|
49
|
-
|
56
|
+
cwd: str,
|
57
|
+
timeout_seconds: int,
|
58
|
+
env_vars: Dict[str, str],
|
50
59
|
) -> str:
|
51
|
-
"""
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
"""Execute command on Windows platform."""
|
61
|
+
try:
|
62
|
+
# On Windows, use subprocess with pipes
|
63
|
+
process = subprocess.Popen(
|
64
|
+
command,
|
65
|
+
shell=True,
|
66
|
+
stdin=subprocess.PIPE,
|
67
|
+
stdout=subprocess.PIPE,
|
68
|
+
stderr=subprocess.PIPE,
|
69
|
+
cwd=cwd,
|
70
|
+
env=env_vars,
|
71
|
+
text=True,
|
72
|
+
encoding='utf-8'
|
73
|
+
)
|
74
|
+
|
75
|
+
try:
|
76
|
+
stdout, stderr = process.communicate(timeout=timeout_seconds)
|
77
|
+
return_code = process.returncode
|
78
|
+
|
79
|
+
if return_code != 0 and stderr:
|
80
|
+
logger.warning(f"Command failed with error: {stderr}")
|
81
|
+
|
82
|
+
formatted_result = (
|
83
|
+
"<command_output>"
|
84
|
+
f" <stdout>{stdout.strip()}</stdout>"
|
85
|
+
f" <returncode>{return_code}</returncode>"
|
86
|
+
f"</command_output>"
|
87
|
+
)
|
88
|
+
return formatted_result
|
89
|
+
|
90
|
+
except subprocess.TimeoutExpired:
|
91
|
+
process.kill()
|
92
|
+
return f"Command timed out after {timeout_seconds} seconds."
|
93
|
+
|
94
|
+
except Exception as e:
|
95
|
+
return f"Unexpected error executing command: {str(e)}"
|
57
96
|
|
97
|
+
def _execute_unix(
|
98
|
+
self,
|
99
|
+
command: str,
|
100
|
+
cwd: str,
|
101
|
+
timeout_seconds: int,
|
102
|
+
env_vars: Dict[str, str],
|
103
|
+
) -> str:
|
104
|
+
"""Execute command on Unix platform."""
|
58
105
|
try:
|
59
106
|
master, slave = pty.openpty()
|
60
107
|
proc = subprocess.Popen(
|
@@ -94,9 +141,7 @@ class ExecuteBashCommandTool(Tool):
|
|
94
141
|
user_input = os.read(sys.stdin.fileno(), 1024)
|
95
142
|
os.write(master, user_input)
|
96
143
|
|
97
|
-
# Check if process completed or EOF received
|
98
144
|
if break_loop or proc.poll() is not None:
|
99
|
-
# Read any remaining output
|
100
145
|
while True:
|
101
146
|
data = os.read(master, 1024).decode()
|
102
147
|
if not data:
|
@@ -127,6 +172,28 @@ class ExecuteBashCommandTool(Tool):
|
|
127
172
|
except Exception as e:
|
128
173
|
return f"Unexpected error executing command: {str(e)}"
|
129
174
|
|
175
|
+
def execute(
|
176
|
+
self,
|
177
|
+
command: str,
|
178
|
+
working_dir: Optional[str] = None,
|
179
|
+
timeout: Union[int, str, None] = 60,
|
180
|
+
env: Optional[Dict[str, str]] = None,
|
181
|
+
) -> str:
|
182
|
+
"""Executes a bash command with interactive input handling."""
|
183
|
+
timeout_seconds = int(timeout) if timeout else 60
|
184
|
+
cwd = working_dir or os.getcwd()
|
185
|
+
env_vars = os.environ.copy()
|
186
|
+
if env:
|
187
|
+
env_vars.update(env)
|
188
|
+
|
189
|
+
if sys.platform == 'win32':
|
190
|
+
return self._execute_windows(command, cwd, timeout_seconds, env_vars)
|
191
|
+
else:
|
192
|
+
if not pty:
|
193
|
+
logger.warning("PTY module not available, falling back to Windows-style execution")
|
194
|
+
return self._execute_windows(command, cwd, timeout_seconds, env_vars)
|
195
|
+
return self._execute_unix(command, cwd, timeout_seconds, env_vars)
|
196
|
+
|
130
197
|
|
131
198
|
if __name__ == "__main__":
|
132
199
|
tool = ExecuteBashCommandTool()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/generate_database_report_tool.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/cpp_handler.py
RENAMED
File without changes
|
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/java_handler.py
RENAMED
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/javascript_handler.py
RENAMED
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/python_handler.py
RENAMED
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/rust_handler.py
RENAMED
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/scala_handler.py
RENAMED
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/language_handlers/typescript_handler.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/tools/utils/generate_database_report.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{quantalogic-0.2.29 → quantalogic-0.2.30}/quantalogic/utils/get_quantalogic_rules_content.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|