Spaces:
Build error
Build error
Commit ·
8f8e56d
1
Parent(s): 0537b2c
Fix Windows Unicode crash and Bedrock Claude 4.6 model IDs
Browse filesWindows (fixes #65):
- Reconfigure stdout/stderr to UTF-8 on Windows in wrap.py (cp1252 can't
encode box-drawing characters in CLI banner)
- Pass PYTHONIOENCODING=utf-8 to proxy subprocess env
- Add encoding="utf-8", errors="replace" to subprocess.run() calls in
rtk/installer.py
Bedrock (fixes #64):
- Fix Claude 4.6 model IDs in static fallback map:
anthropic.claude-opus-4-6-v1:0 → anthropic.claude-opus-4-6-v1
anthropic.claude-sonnet-4-6-v1:0 → anthropic.claude-sonnet-4-6
- headroom/backends/litellm.py +2 -2
- headroom/cli/wrap.py +12 -0
- headroom/rtk/installer.py +4 -0
headroom/backends/litellm.py
CHANGED
|
@@ -96,8 +96,8 @@ def _build_bedrock_fallback_map(region: str) -> dict[str, str]:
|
|
| 96 |
# Base model IDs without region prefix
|
| 97 |
_CLAUDE_MODELS = [
|
| 98 |
# Claude 4.6
|
| 99 |
-
("claude-opus-4-6", "anthropic.claude-opus-4-6-v1
|
| 100 |
-
("claude-sonnet-4-6", "anthropic.claude-sonnet-4-6
|
| 101 |
# Claude 4.5
|
| 102 |
("claude-sonnet-4-5-20250929", "anthropic.claude-sonnet-4-5-20250929-v1:0"),
|
| 103 |
("claude-opus-4-5-20251101", "anthropic.claude-opus-4-5-20251101-v1:0"),
|
|
|
|
| 96 |
# Base model IDs without region prefix
|
| 97 |
_CLAUDE_MODELS = [
|
| 98 |
# Claude 4.6
|
| 99 |
+
("claude-opus-4-6", "anthropic.claude-opus-4-6-v1"),
|
| 100 |
+
("claude-sonnet-4-6", "anthropic.claude-sonnet-4-6"),
|
| 101 |
# Claude 4.5
|
| 102 |
("claude-sonnet-4-5-20250929", "anthropic.claude-sonnet-4-5-20250929-v1:0"),
|
| 103 |
("claude-opus-4-5-20251101", "anthropic.claude-opus-4-5-20251101-v1:0"),
|
headroom/cli/wrap.py
CHANGED
|
@@ -12,6 +12,7 @@ Usage:
|
|
| 12 |
|
| 13 |
from __future__ import annotations
|
| 14 |
|
|
|
|
| 15 |
import os
|
| 16 |
import shutil
|
| 17 |
import signal
|
|
@@ -22,6 +23,12 @@ import time
|
|
| 22 |
from pathlib import Path
|
| 23 |
from typing import Any
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
import click
|
| 26 |
|
| 27 |
from .main import main
|
|
@@ -68,10 +75,15 @@ def _start_proxy(port: int, *, learn: bool = False) -> subprocess.Popen:
|
|
| 68 |
log_path = _get_log_path()
|
| 69 |
log_file = open(log_path, "a") # noqa: SIM115
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
proc = subprocess.Popen(
|
| 72 |
cmd,
|
| 73 |
stdout=log_file,
|
| 74 |
stderr=log_file,
|
|
|
|
| 75 |
)
|
| 76 |
|
| 77 |
# Wait for proxy to be ready (up to 15 seconds)
|
|
|
|
| 12 |
|
| 13 |
from __future__ import annotations
|
| 14 |
|
| 15 |
+
import io
|
| 16 |
import os
|
| 17 |
import shutil
|
| 18 |
import signal
|
|
|
|
| 23 |
from pathlib import Path
|
| 24 |
from typing import Any
|
| 25 |
|
| 26 |
+
# Fix Windows cp1252 encoding — box-drawing characters require UTF-8
|
| 27 |
+
if sys.platform == "win32" and hasattr(sys.stdout, "buffer"):
|
| 28 |
+
if sys.stdout.encoding and sys.stdout.encoding.lower().replace("-", "") != "utf8":
|
| 29 |
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
| 30 |
+
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
|
| 31 |
+
|
| 32 |
import click
|
| 33 |
|
| 34 |
from .main import main
|
|
|
|
| 75 |
log_path = _get_log_path()
|
| 76 |
log_file = open(log_path, "a") # noqa: SIM115
|
| 77 |
|
| 78 |
+
# Ensure proxy subprocess uses UTF-8 (Windows defaults to cp1252)
|
| 79 |
+
proxy_env = os.environ.copy()
|
| 80 |
+
proxy_env["PYTHONIOENCODING"] = "utf-8"
|
| 81 |
+
|
| 82 |
proc = subprocess.Popen(
|
| 83 |
cmd,
|
| 84 |
stdout=log_file,
|
| 85 |
stderr=log_file,
|
| 86 |
+
env=proxy_env,
|
| 87 |
)
|
| 88 |
|
| 89 |
# Wait for proxy to be ready (up to 15 seconds)
|
headroom/rtk/installer.py
CHANGED
|
@@ -125,6 +125,8 @@ def download_rtk(version: str | None = None) -> Path:
|
|
| 125 |
[str(RTK_BIN_PATH), "--version"],
|
| 126 |
capture_output=True,
|
| 127 |
text=True,
|
|
|
|
|
|
|
| 128 |
timeout=5,
|
| 129 |
)
|
| 130 |
if result.returncode != 0:
|
|
@@ -153,6 +155,8 @@ def register_claude_hooks(rtk_path: Path | None = None) -> bool:
|
|
| 153 |
[str(rtk_path), "init", "--global", "--auto-patch"],
|
| 154 |
capture_output=True,
|
| 155 |
text=True,
|
|
|
|
|
|
|
| 156 |
timeout=10,
|
| 157 |
)
|
| 158 |
if result.returncode == 0:
|
|
|
|
| 125 |
[str(RTK_BIN_PATH), "--version"],
|
| 126 |
capture_output=True,
|
| 127 |
text=True,
|
| 128 |
+
encoding="utf-8",
|
| 129 |
+
errors="replace",
|
| 130 |
timeout=5,
|
| 131 |
)
|
| 132 |
if result.returncode != 0:
|
|
|
|
| 155 |
[str(rtk_path), "init", "--global", "--auto-patch"],
|
| 156 |
capture_output=True,
|
| 157 |
text=True,
|
| 158 |
+
encoding="utf-8",
|
| 159 |
+
errors="replace",
|
| 160 |
timeout=10,
|
| 161 |
)
|
| 162 |
if result.returncode == 0:
|