mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix: fileops on mac
Co-authored-by: Dean Kerr <dean.kerr@gmail.com>
This commit is contained in:
parent
b281ecd50a
commit
0cce536fb2
1 changed files with 6 additions and 6 deletions
|
|
@ -441,8 +441,8 @@ class ShellFileOperations(FileOperations):
|
||||||
# Clamp limit
|
# Clamp limit
|
||||||
limit = min(limit, MAX_LINES)
|
limit = min(limit, MAX_LINES)
|
||||||
|
|
||||||
# Check if file exists and get metadata
|
# Check if file exists and get size (wc -c is POSIX, works on Linux + macOS)
|
||||||
stat_cmd = f"stat -c '%s' {self._escape_shell_arg(path)} 2>/dev/null"
|
stat_cmd = f"wc -c < {self._escape_shell_arg(path)} 2>/dev/null"
|
||||||
stat_result = self._exec(stat_cmd)
|
stat_result = self._exec(stat_cmd)
|
||||||
|
|
||||||
if stat_result.exit_code != 0:
|
if stat_result.exit_code != 0:
|
||||||
|
|
@ -518,8 +518,8 @@ class ShellFileOperations(FileOperations):
|
||||||
|
|
||||||
def _read_image(self, path: str) -> ReadResult:
|
def _read_image(self, path: str) -> ReadResult:
|
||||||
"""Read an image file, returning base64 content."""
|
"""Read an image file, returning base64 content."""
|
||||||
# Get file size
|
# Get file size (wc -c is POSIX, works on Linux + macOS)
|
||||||
stat_cmd = f"stat -c '%s' {self._escape_shell_arg(path)} 2>/dev/null"
|
stat_cmd = f"wc -c < {self._escape_shell_arg(path)} 2>/dev/null"
|
||||||
stat_result = self._exec(stat_cmd)
|
stat_result = self._exec(stat_cmd)
|
||||||
try:
|
try:
|
||||||
file_size = int(stat_result.stdout.strip())
|
file_size = int(stat_result.stdout.strip())
|
||||||
|
|
@ -648,8 +648,8 @@ class ShellFileOperations(FileOperations):
|
||||||
if write_result.exit_code != 0:
|
if write_result.exit_code != 0:
|
||||||
return WriteResult(error=f"Failed to write file: {write_result.stdout}")
|
return WriteResult(error=f"Failed to write file: {write_result.stdout}")
|
||||||
|
|
||||||
# Get bytes written
|
# Get bytes written (wc -c is POSIX, works on Linux + macOS)
|
||||||
stat_cmd = f"stat -c '%s' {self._escape_shell_arg(path)} 2>/dev/null"
|
stat_cmd = f"wc -c < {self._escape_shell_arg(path)} 2>/dev/null"
|
||||||
stat_result = self._exec(stat_cmd)
|
stat_result = self._exec(stat_cmd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue