Spaces:
Running
Running
sync: upstream 9194f15 + custom addons (KeyRotator, RotatingChatTransport, sol/terra/luna, ScannerTrap, health, Py3.12 compat)
e99df76 Download src/free_claude_code/cli/managed/diagnostics.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/cli/managed/diagnostics.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/src/free_claude_code/cli/managed/diagnostics.py
-
curl -L -o diagnostics.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/cli/managed/diagnostics.py
1.45 kB
| from __future__ import annotations | |
| """Managed Claude Code diagnostic classification.""" | |
| from dataclasses import dataclass | |
| _BENIGN_STDERR_MARKERS = ("claude.ai connectors are disabled",) | |
| class ManagedClaudeStderrDiagnostics: | |
| """Classified stderr lines from one managed Claude Code invocation.""" | |
| benign_lines: tuple[str, ...] | |
| fatal_lines: tuple[str, ...] | |
| def fatal_text(self) -> str | None: | |
| text = "\n".join(self.fatal_lines).strip() | |
| return text or None | |
| def has_benign(self) -> bool: | |
| return bool(self.benign_lines) | |
| def classify_managed_claude_stderr( | |
| stderr_text: str, | |
| ) -> ManagedClaudeStderrDiagnostics: | |
| """Classify known benign Claude Code diagnostics separately from failures.""" | |
| benign_lines: list[str] = [] | |
| fatal_lines: list[str] = [] | |
| for line in _stderr_lines(stderr_text): | |
| lowered = line.lower() | |
| if any(marker in lowered for marker in _BENIGN_STDERR_MARKERS): | |
| benign_lines.append(line) | |
| else: | |
| fatal_lines.append(line) | |
| return ManagedClaudeStderrDiagnostics( | |
| benign_lines=tuple(benign_lines), | |
| fatal_lines=tuple(fatal_lines), | |
| ) | |
| def _stderr_lines(stderr_text: str) -> tuple[str, ...]: | |
| stripped = stderr_text.strip() | |
| if not stripped: | |
| return () | |
| return tuple(line.strip() for line in stripped.splitlines() if line.strip()) | |