-
Notifications
You must be signed in to change notification settings - Fork 1.8k
update terminal toolkit with shell_wait & shell_write_content_to_file toolkits #3668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Michaelsqj , left some comments below, also one enhance PR to review: #3669
| "too frequently)" | ||
| ) | ||
|
|
||
| def shell_wait(self, id: str, wait_seconds: float = 5.0) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is shell_wait necessary? The existing _collect_output_until_idle() method already provides similar functionality with better efficiency (uses condition variables instead of polling with time.sleep(0.2))
| if self.use_docker_backend: | ||
| try: | ||
| # Write content to a temporary file on the host inside log_dir | ||
| temp_host_path = os.path.join(self.log_dir, f"temp_{uuid.uuid4().hex}.txt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to import uuid
| # Copy the temporary file into the Docker container | ||
| dest_path_in_container = file_path | ||
| result = subprocess.run([ | ||
| 'docker', 'cp', temp_host_path, f"{self.docker_container_name}:{dest_path_in_container}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.docker_container_name is never set
| """ | ||
| if self.safe_mode and self.working_dir: | ||
| abs_file_path = os.path.abspath(file_path) | ||
| if not abs_file_path.startswith(self.working_dir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using startswith() for path validation can be bypassed (e.g., /workspace/../etc/passwd), let's use os.path.commonpath() instead
update terminal toolkit with shell_wait & shell_write_content_to_file toolkits
Description
Describe your changes in detail (optional if the linked issue already contains a detailed description of the changes).
Checklist
Go over all the following points, and put an
xin all the boxes that apply.Fixes #issue-numberin the PR description (required)pyproject.tomlanduv lockIf you are unsure about any of these, don't hesitate to ask. We are here to help!