Skip to content

Commit a949ea3

Browse files
committed
Fixed bug where non unicode bytes were in the output the terminal would drastically fail
1 parent e1646cc commit a949ea3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
authors = [{ name = "Aman Rusia", email = "[email protected]" }]
33
name = "wcgw"
4-
version = "2.8.8"
4+
version = "2.8.9"
55
description = "Shell and coding agent on claude and chatgpt"
66
readme = "README.md"
77
requires-python = ">=3.11, <3.13"

src/wcgw/client/tools.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
146146
encoding="utf-8",
147147
timeout=TIMEOUT,
148148
cwd=initial_dir,
149+
codec_errors="backslashreplace",
149150
)
150151
shell.sendline(
151152
f"export PROMPT_COMMAND= PS1={PROMPT_CONST}"
@@ -161,6 +162,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
161162
echo=False,
162163
encoding="utf-8",
163164
timeout=TIMEOUT,
165+
codec_errors="backslashreplace",
164166
)
165167
shell.sendline(f"export PS1={PROMPT_CONST}")
166168
shell.expect(PROMPT_CONST, timeout=TIMEOUT)
@@ -256,7 +258,9 @@ def ensure_env_and_bg_jobs(self) -> Optional[int]:
256258
before = "\n".join(before_lines).strip()
257259
counts += 1
258260
if counts > 100:
259-
raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
261+
raise ValueError(
262+
"Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
263+
)
260264

261265
try:
262266
return int(before)
@@ -273,7 +277,7 @@ def _init_shell(self) -> None:
273277
self._bash_command_mode.bash_mode == "restricted_mode",
274278
self._cwd,
275279
)
276-
280+
277281
self._pending_output = ""
278282

279283
# Get exit info to ensure shell is ready
@@ -414,7 +418,9 @@ def update_repl_prompt(self, command: str) -> bool:
414418
index = self.shell.expect([self._prompt, pexpect.TIMEOUT], timeout=0.2)
415419
counts += 1
416420
if counts > 100:
417-
raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
421+
raise ValueError(
422+
"Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
423+
)
418424
console.print(f"Prompt updated to: {self._prompt}")
419425
return True
420426
return False

0 commit comments

Comments
 (0)