coding-proxy 0.5.2a7__py3-none-any.whl → 0.5.2a8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -712,5 +712,5 @@ session_policies:
712
712
  # ⚠️ 自定义 yaml 中该字段为整体替换(loader 的 list 合并约定,非追加合并);
713
713
  # 写空列表即关闭豁免。加载时会自动 strip + 去空 + 去重。
714
714
  title_exempt_prefixes:
715
- - "Write the title in the language"
715
+ - "Write the title in the"
716
716
  - "[Session]"
@@ -25,6 +25,7 @@ from .vendor import ( # noqa: F401
25
25
  UsageInfo,
26
26
  VendorCapabilities,
27
27
  VendorResponse,
28
+ decode_error_body,
28
29
  decode_json_body,
29
30
  extract_error_message,
30
31
  sanitize_headers_for_synthetic_response,
@@ -83,6 +84,7 @@ __all__ = [
83
84
  "CopilotModelCatalog",
84
85
  "RequestCapabilities",
85
86
  "UsageInfo",
87
+ "decode_error_body",
86
88
  "decode_json_body",
87
89
  "extract_error_message",
88
90
  "sanitize_headers_for_synthetic_response",
@@ -75,6 +75,20 @@ def extract_error_message(
75
75
  return text[:500] if text else None
76
76
 
77
77
 
78
+ def decode_error_body(raw: bytes, limit: int = 500) -> str:
79
+ """将上游错误响应体(bytes)安全解码为可读文本,供日志展示.
80
+
81
+ 直接以 ``%s`` 格式化 ``bytes`` 会走 ``repr()``,导致非 ASCII 的 UTF-8
82
+ 字节被转义为 ``\\xe6\\x82\\xa8`` 之类的不可读序列(中文乱码)。本函数:
83
+
84
+ - 使用 ``errors="replace"`` 容忍非法字节,非法字节降级为 ``�`` 而非抛异常,
85
+ 确保日志路径绝对健壮;
86
+ - 先整体解码再按字符截断,避免在多字节 UTF-8 边界切断产生乱码
87
+ (因此 ``limit`` 语义为「字符数」而非「字节数」)。
88
+ """
89
+ return raw.decode("utf-8", errors="replace")[:limit]
90
+
91
+
78
92
  # ═══════════════════════════════════════════════════════════════
79
93
  # 供应商核心数据类型
80
94
  # ═══════════════════════════════════════════════════════════════
@@ -229,6 +243,7 @@ __all__ = [
229
243
  "CopilotMisdirectedRequest",
230
244
  "CopilotModelCatalog",
231
245
  # 工具函数
246
+ "decode_error_body",
232
247
  "decode_json_body",
233
248
  "extract_error_message",
234
249
  "sanitize_headers_for_synthetic_response",
@@ -24,6 +24,7 @@ from .base import (
24
24
  VendorCapabilities,
25
25
  VendorResponse,
26
26
  _sanitize_headers_for_synthetic_response,
27
+ decode_error_body,
27
28
  )
28
29
 
29
30
  # GoogleOAuthTokenManager 已从 antigravity_token_manager.py 合并至本文件末尾
@@ -532,14 +533,16 @@ class AntigravityVendor(TokenBackendMixin, BaseVendor):
532
533
  if response.status_code >= 400:
533
534
  self._on_error_status(response.status_code)
534
535
  error_body = await response.aread()
536
+ # 检测用完整解码文本(判定性逻辑不应受日志展示上限影响);
537
+ # 日志展示则用 decode_error_body 的 500 字符截断版本。
535
538
  self._mark_scope_error_if_needed(
536
- error_body.decode("utf-8", errors="ignore"),
539
+ error_body.decode("utf-8", errors="replace"),
537
540
  )
538
541
  logger.warning(
539
542
  "%s stream error: status=%d body=%s",
540
543
  self.get_name(),
541
544
  response.status_code,
542
- error_body[:500],
545
+ decode_error_body(error_body),
543
546
  )
544
547
  raise httpx.HTTPStatusError(
545
548
  f"{self.get_name()} API error: {response.status_code}",
@@ -25,6 +25,7 @@ from ..model.vendor import ( # noqa: F401
25
25
  UsageInfo,
26
26
  VendorCapabilities,
27
27
  VendorResponse,
28
+ decode_error_body,
28
29
  decode_json_body,
29
30
  extract_error_message,
30
31
  sanitize_headers_for_synthetic_response,
@@ -328,7 +329,7 @@ class BaseVendor(ABC):
328
329
  "%s stream error: status=%d body=%s",
329
330
  self.get_name(),
330
331
  response.status_code,
331
- error_body[:500],
332
+ decode_error_body(error_body),
332
333
  )
333
334
  raise httpx.HTTPStatusError(
334
335
  f"{self.get_name()} API error: {response.status_code}",
@@ -25,6 +25,7 @@ from .base import (
25
25
  VendorResponse,
26
26
  _decode_json_body,
27
27
  _extract_error_message,
28
+ decode_error_body,
28
29
  )
29
30
  from .copilot_models import ( # noqa: F401
30
31
  CopilotMisdirectedRequest,
@@ -423,7 +424,7 @@ class CopilotVendor(TokenBackendMixin, BaseVendor):
423
424
  "%s stream error: status=%d body=%s",
424
425
  self.get_name(),
425
426
  response.status_code,
426
- error_body[:500],
427
+ decode_error_body(error_body),
427
428
  )
428
429
  raise httpx.HTTPStatusError(
429
430
  f"{self.get_name()} API error: {response.status_code}",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coding-proxy
3
- Version: 0.5.2a7
3
+ Version: 0.5.2a8
4
4
  Summary: A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code. Support Claude Plans, GitHub Copilot, Google Antigravity, ZAI/GLM, MiniMax, Qwen, Xiaomi, Kimi, Doubao...
5
5
  Project-URL: Source Code, https://github.com/ThreeFish-AI/coding-proxy
6
6
  Project-URL: User Guide, https://github.com/ThreeFish-AI/coding-proxy/blob/master/docs/user-guide.md
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
29
29
 
30
30
  <div align="center">
31
31
 
32
- # ⚡ coding-proxy
32
+ # <img src="assets/logo.svg" alt="coding-proxy" width="32" height="32" align="absmiddle"> coding-proxy
33
33
 
34
34
  **A High-Availability, Transparent, and Smart Multi-Vendor Proxy for Claude Code**
35
35
 
@@ -152,7 +152,7 @@ graph RL
152
152
 
153
153
  Client["💻<br/>Client (Claude Code)"]:::client
154
154
 
155
- subgraph CodingProxy["⚡ coding-proxy"]
155
+ subgraph CodingProxy["coding-proxy"]
156
156
  direction RL
157
157
 
158
158
  Router["RequestRouter<br/><code>routing/router.py</code>"]:::router
@@ -17,7 +17,7 @@ coding/proxy/compat/canonical.py,sha256=-zcuEwZ402xeH3C545RmuYRkT2HDuvFloyFydDv8
17
17
  coding/proxy/compat/session_store.py,sha256=B9IFjjQJnHMg1244m__jG9gnqGWi26-JyEtwopEri6Q,5244
18
18
  coding/proxy/config/__init__.py,sha256=hzgU5noJGecjj13UY38cC_p6jpWO3GO7okSW-A2XkJ0,127
19
19
  coding/proxy/config/auth_schema.py,sha256=LYrJQU_fgW-6AoQdjXt4-MgPJjXjv9HrghlCcZwotnA,696
20
- coding/proxy/config/config.default.yaml,sha256=P0QBPMGrGOlTVFncpC-u6oJ92nPWO_He95BF0ZgBW4g,23726
20
+ coding/proxy/config/config.default.yaml,sha256=TKIHDUb4uS0zc-c-I-ix_fK3MEGuI-PABPoOc-6kPio,23717
21
21
  coding/proxy/config/loader.py,sha256=1J_RBJgjuC8RwB2mwewLMS7vy9WEhUqttZG2igeDm-w,8984
22
22
  coding/proxy/config/resiliency.py,sha256=GnzY-LoyfFqXFM1l6xEru418v-cKlv97-HM0noGPdks,1308
23
23
  coding/proxy/config/routing.py,sha256=MWTUq6QaYDmoXEARN9EBAptC6TSGK2yezNiaVk3kaXY,12196
@@ -36,13 +36,13 @@ coding/proxy/logging/__init__.py,sha256=6zEh2CELMJ5aZvM6PNCOFlZ55De8xoC6QNyMAa9W
36
36
  coding/proxy/logging/db.py,sha256=gXWryj_kuUxRlLXpcvKuK1z9n_da9o-zB8qn9sd3-qg,28234
37
37
  coding/proxy/logging/formatters.py,sha256=8LDqiNAxGcfn9fsHqZzdK9TKGqOGNAOls75B1byBjnM,823
38
38
  coding/proxy/logging/stats.py,sha256=jDQWFiqrj5IXtCM_tt2iykCzOdqq22_HaE8d9e__p30,12316
39
- coding/proxy/model/__init__.py,sha256=E8E59yabP-CF5GIwHE4OEGPLiJj3yTLjFWmCorkQTxc,3947
39
+ coding/proxy/model/__init__.py,sha256=cwGwy35mJzwN_6Q5B9nCUhzJ_Idg97D3G4Nc1PLOEQg,3995
40
40
  coding/proxy/model/auth.py,sha256=NiiIPdLdxPtuHNrsGoxFASUXwJU5pkDuVRorQe_1Z-Q,934
41
41
  coding/proxy/model/compat.py,sha256=D1ngBbtQb39cbtCsmxbMBiH8Hyu3rVU-fZPB_4TBj6M,5120
42
42
  coding/proxy/model/constants.py,sha256=rDCG9kZMkwlfrxlt0HGU-SkC2oxqlVw_Yva6s-lQZmQ,1038
43
43
  coding/proxy/model/pricing.py,sha256=nmwsJK4XRBsKYt_1LQsjMXkA9uIjqev4b5fSJANmPQc,1814
44
44
  coding/proxy/model/token.py,sha256=yCh-66_nFDAk7wKbYy-9ymdgae3SaJ47-fkYfYLO3Oo,1818
45
- coding/proxy/model/vendor.py,sha256=Yg4AYN7tgjHaGWRGEccCs3AdO8vBc-KxIelnqRowpyo,7898
45
+ coding/proxy/model/vendor.py,sha256=1X3a3Z4989c0ejPThNIawQIj53P7Wd0qwtaCL1Y6x-k,8643
46
46
  coding/proxy/native_api/__init__.py,sha256=tnsl69cAolOirVsz7M04duXV9HCVXRDX4DAj6A1Xw-c,3008
47
47
  coding/proxy/native_api/config.py,sha256=oh5jtLRJ2dMqV1d3bNHNQ4wxL-cL3GlFallQMEkuRTM,4266
48
48
  coding/proxy/native_api/handler.py,sha256=Vb4CsO5xl8yoBf_R3aLMfCoTZQuuyKA0mdJfDFArHXk,30016
@@ -78,10 +78,10 @@ coding/proxy/streaming/anthropic_compat.py,sha256=cycYiJ-glN88OmfLTR7FroHRethONl
78
78
  coding/proxy/vendors/__init__.py,sha256=fehSpQ2-kUlZY6N8cNMGVJYMXspQmi3V4e0FgC4Ay4k,1011
79
79
  coding/proxy/vendors/alibaba.py,sha256=vYhvk8hZEeOpqUrtGT-uaK89y6uolrDUAT2BvTD_IQY,876
80
80
  coding/proxy/vendors/anthropic.py,sha256=1l6c4w0OHER0i8a81C9Z74lx1myQ2ut4lRo_58yY1m0,4221
81
- coding/proxy/vendors/antigravity.py,sha256=M1Q2ck0MVHMLwGgSLyLbpwys2D9yOIfyeZOU2k2pzJg,22521
82
- coding/proxy/vendors/base.py,sha256=KFmQEFpIezS3fS0p-OeGE1Etd_LEpGs9_2VmoojJ5rM,15836
81
+ coding/proxy/vendors/antigravity.py,sha256=sjQP6NfpaXrsJs_RcVJW7xhmXBM4tOCIRrQlRZCQBkM,22740
82
+ coding/proxy/vendors/base.py,sha256=hKagGqLKuEUAU74NLAHjNRFvtJEZlGTJXcQTe9IOAKs,15872
83
83
  coding/proxy/vendors/concurrency.py,sha256=KSMlBDTmz--Mf7-i2hBtc16bMLVvrSW_SEpVQKNKzNg,8271
84
- coding/proxy/vendors/copilot.py,sha256=qAFTO2xMqnawaFlvZS2a9-7f_UEkfODIFfDlgOBiQl4,29590
84
+ coding/proxy/vendors/copilot.py,sha256=n-dDCSD6XFbiBq6XjyK66VzhQtSPbLH4NIg25SKWIGU,29626
85
85
  coding/proxy/vendors/copilot_models.py,sha256=UckIQYA4qLyNwEA09koQGBOZ65Nxhuo3ytUuDNqtzRU,15514
86
86
  coding/proxy/vendors/copilot_token_manager.py,sha256=_sZBSFr4sFF2BuP-ZWexQxbN3R8TZs9CJ_d62LvyeBw,6710
87
87
  coding/proxy/vendors/copilot_urls.py,sha256=YxaR6zmPdrySzsotJx6PjNIu2JIGG6N1D8kZs77oUCM,404
@@ -93,8 +93,8 @@ coding/proxy/vendors/native_anthropic.py,sha256=SxtM71PDci0gqLqiwCrFnT410SnSoD7F
93
93
  coding/proxy/vendors/token_manager.py,sha256=s10t4Com0jNnKGkPyJ_HpG5SjHrCEJvfArEOAaPKA_k,4189
94
94
  coding/proxy/vendors/xiaomi.py,sha256=E-GcmJBZh7GOtDFonxZmlf0hKRhrlrXzL0IxHFRYcRo,860
95
95
  coding/proxy/vendors/zhipu.py,sha256=GaLaWssa4c1lcukQL4nOtzji8jxEUJFrZtFgOkXTKaM,11127
96
- coding_proxy-0.5.2a7.dist-info/METADATA,sha256=UrIx1OqNYy0Iuy27Y7Q9ceSRiPMudWxqrxIgRKKw71s,11457
97
- coding_proxy-0.5.2a7.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
98
- coding_proxy-0.5.2a7.dist-info/entry_points.txt,sha256=moIVzt5ho0Wk9B47LOo2SEAbhzuDDHWi-EfM30U0XBg,54
99
- coding_proxy-0.5.2a7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
100
- coding_proxy-0.5.2a7.dist-info/RECORD,,
96
+ coding_proxy-0.5.2a8.dist-info/METADATA,sha256=yiHe5ckvhidUve9t3ztmVQ7Zymy6Ep4vLYeXdXAf3fo,11537
97
+ coding_proxy-0.5.2a8.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
98
+ coding_proxy-0.5.2a8.dist-info/entry_points.txt,sha256=moIVzt5ho0Wk9B47LOo2SEAbhzuDDHWi-EfM30U0XBg,54
99
+ coding_proxy-0.5.2a8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
100
+ coding_proxy-0.5.2a8.dist-info/RECORD,,