fix(codex-bridge): ship zstd for the agent's Python and refuse to link without it
Codex compresses request bodies with zstd. The agent venv is Python 3.11, which has no zstd in its standard library, so every Codex request failed on a fresh install. The matching zstandard build now ships beside the bridge; the status endpoint reports ok=false when bodies cannot be read, and the IDE then leaves Codex's config alone. A running bridge from an older build is replaced, and "Sync now" makes the bridge re-read the IDE session at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRDGW1LiKcDUZYUdKBoWYW
This commit is contained in:
1 parent
dea67fc153
commit
b560950f82
13 files changed
+5317
-10
No files matched your search
@@ -26,9 +26,42 @@ from resim_context import resimleri_sadelestir
|
||||
import ide_catalog
|
||||
import ozet_kopru
|
||||
|
||||
SURUM = "1"
|
||||
SURUM = "2"
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Codex sends request bodies zstd-compressed. Python gained zstd in 3.14; for older
|
||||
# interpreters the matching `zstandard` build ships next to this file.
|
||||
_VENDOR = os.path.join(HERE, "vendor", "cp%d%d-win_amd64" % sys.version_info[:2])
|
||||
if os.path.isdir(_VENDOR):
|
||||
sys.path.insert(0, _VENDOR)
|
||||
|
||||
|
||||
def _zstd_decompress(body):
|
||||
try:
|
||||
from compression import zstd as _z
|
||||
return _z.decompress(body)
|
||||
except ImportError:
|
||||
import zstandard
|
||||
return zstandard.ZstdDecompressor().decompressobj().decompress(body)
|
||||
|
||||
|
||||
def _zstd_ready():
|
||||
try:
|
||||
try:
|
||||
from compression import zstd as _z
|
||||
sample = _z.compress(b"aiturk")
|
||||
except ImportError:
|
||||
import zstandard
|
||||
sample = zstandard.ZstdCompressor().compress(b"aiturk")
|
||||
return _zstd_decompress(sample) == b"aiturk"
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
# Without zstd every Codex request would fail; the status endpoint then reports
|
||||
# ok=false so that the IDE never points Codex at this bridge.
|
||||
ZSTD_OK = _zstd_ready()
|
||||
|
||||
|
||||
def _arg(name, env):
|
||||
"""--name <value> from the command line, else the environment variable."""
|
||||
@@ -468,10 +501,7 @@ def decompress(body, enc):
|
||||
if enc == "deflate":
|
||||
import zlib; return zlib.decompress(body)
|
||||
if enc == "zstd":
|
||||
try:
|
||||
from compression import zstd as _z; return _z.decompress(body)
|
||||
except ImportError:
|
||||
import zstandard; return zstandard.ZstdDecompressor().decompressobj().decompress(body)
|
||||
return _zstd_decompress(body)
|
||||
if enc == "br":
|
||||
import brotli; return brotli.decompress(body)
|
||||
return body
|
||||
@@ -533,9 +563,18 @@ class H(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
def _control(self, path):
|
||||
"""Local status/stop for AITURK IDE. Loopback only; carries no secrets."""
|
||||
if self.command == "POST" and path.rstrip("/").endswith("/refresh"):
|
||||
# The IDE asks for this after a sign-in or a settings change, so the model
|
||||
# list does not wait for the next periodic refresh.
|
||||
try:
|
||||
load_ide_catalog()
|
||||
except Exception as e:
|
||||
log(f"katalog yenileme hatasi: {e}")
|
||||
path = "/aiturk/codex-baglama/status"
|
||||
self.command = "GET"
|
||||
if self.command == "GET" and path.rstrip("/").endswith("/status"):
|
||||
durum, _, sayi = (IDE_DURUM[0] or "kapali, 0 model").partition(", ")
|
||||
return self._send_json(200, {"ok": True, "surum": SURUM, "ide_durum": durum,
|
||||
return self._send_json(200, {"ok": ZSTD_OK, "surum": SURUM, "zstd": ZSTD_OK, "ide_durum": durum,
|
||||
"ide_model": int((sayi.split() or ["0"])[0]),
|
||||
"ozet": bool((CFG.get("ozet_kopru") or {}).get("enabled", False))})
|
||||
if self.command == "POST" and path.rstrip("/").endswith("/stop"):
|
||||
|
||||
Reference in new issue
Block a user