coding-proxy 0.5.2a3__py3-none-any.whl → 0.5.2a4__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.
- coding/proxy/config/config.default.yaml +4 -3
- coding/proxy/server/dashboard.py +127 -1
- coding/proxy/server/routes.py +48 -0
- {coding_proxy-0.5.2a3.dist-info → coding_proxy-0.5.2a4.dist-info}/METADATA +1 -1
- {coding_proxy-0.5.2a3.dist-info → coding_proxy-0.5.2a4.dist-info}/RECORD +8 -8
- {coding_proxy-0.5.2a3.dist-info → coding_proxy-0.5.2a4.dist-info}/WHEEL +0 -0
- {coding_proxy-0.5.2a3.dist-info → coding_proxy-0.5.2a4.dist-info}/entry_points.txt +0 -0
- {coding_proxy-0.5.2a3.dist-info → coding_proxy-0.5.2a4.dist-info}/licenses/LICENSE +0 -0
|
@@ -534,9 +534,9 @@ pricing:
|
|
|
534
534
|
# ── 智谱 GLM ──
|
|
535
535
|
- vendor: zhipu
|
|
536
536
|
model: glm-5.2 # 待区分长短上下文定价
|
|
537
|
-
input_cost_per_mtok: ¥
|
|
538
|
-
output_cost_per_mtok: ¥
|
|
539
|
-
cache_read_cost_per_mtok: ¥
|
|
537
|
+
input_cost_per_mtok: ¥8.00
|
|
538
|
+
output_cost_per_mtok: ¥28.00
|
|
539
|
+
cache_read_cost_per_mtok: ¥2.00
|
|
540
540
|
- vendor: zhipu
|
|
541
541
|
model: glm-5.1 # 待区分长短上下文定价
|
|
542
542
|
input_cost_per_mtok: ¥6.00
|
|
@@ -713,3 +713,4 @@ session_policies:
|
|
|
713
713
|
# 写空列表即关闭豁免。加载时会自动 strip + 去空 + 去重。
|
|
714
714
|
title_exempt_prefixes:
|
|
715
715
|
- "Write the title in the language"
|
|
716
|
+
- "[Session]"
|
coding/proxy/server/dashboard.py
CHANGED
|
@@ -411,6 +411,20 @@ _DASHBOARD_HTML = """<!DOCTYPE html>
|
|
|
411
411
|
height: 100%; border-radius: 2px;
|
|
412
412
|
transition: width .6s cubic-bezier(.4,0,.2,1);
|
|
413
413
|
}
|
|
414
|
+
/* ── 供应商状态:拖拽排序 ── */
|
|
415
|
+
.vendor-item[draggable="true"] { cursor: grab; }
|
|
416
|
+
.vendor-item[draggable="true"]:active { cursor: grabbing; }
|
|
417
|
+
.vendor-item.dragging { opacity: .4; }
|
|
418
|
+
.drag-handle {
|
|
419
|
+
display: flex; align-items: center; flex-shrink: 0;
|
|
420
|
+
color: var(--text-tertiary); font-size: 15px; line-height: 1;
|
|
421
|
+
cursor: grab; user-select: none; padding: 0 2px;
|
|
422
|
+
opacity: 0; transition: opacity .2s ease;
|
|
423
|
+
}
|
|
424
|
+
.vendor-item:hover .drag-handle { opacity: .55; }
|
|
425
|
+
.drag-handle:hover { opacity: 1 !important; color: var(--text-secondary); }
|
|
426
|
+
.vendor-item.drag-over-before { box-shadow: inset 0 2px 0 0 var(--accent-blue); }
|
|
427
|
+
.vendor-item.drag-over-after { box-shadow: inset 0 -2px 0 0 var(--accent-blue); }
|
|
414
428
|
/* ── 故障转移表 ── */
|
|
415
429
|
.ft-table-wrap { overflow-x: auto; }
|
|
416
430
|
table { width: 100%; border-collapse: collapse; }
|
|
@@ -1332,12 +1346,15 @@ function renderQuotaBar(qg) {
|
|
|
1332
1346
|
}
|
|
1333
1347
|
|
|
1334
1348
|
function updateVendorStatus(status) {
|
|
1349
|
+
// 拖拽进行中 / 重排序 POST 未决时跳过重渲染,避免抢占正在操作的 DOM
|
|
1350
|
+
if (_tierDrag.active || _tierDrag.inFlight) return;
|
|
1335
1351
|
const tiers = status.tiers || [];
|
|
1336
1352
|
const list = document.getElementById('vendor-list');
|
|
1337
1353
|
if (!tiers.length) {
|
|
1338
1354
|
list.innerHTML = '<div class="empty"><div class="empty-icon">🔌</div>无供应商数据</div>';
|
|
1339
1355
|
return;
|
|
1340
1356
|
}
|
|
1357
|
+
const draggable = tiers.length >= 2;
|
|
1341
1358
|
list.innerHTML = tiers.map(tier => {
|
|
1342
1359
|
const cb = tier.circuit_breaker || {};
|
|
1343
1360
|
const cbClass = cbStateClass(cb.state);
|
|
@@ -1351,8 +1368,12 @@ function updateVendorStatus(status) {
|
|
|
1351
1368
|
const rlInfo = tier.rate_limit || {};
|
|
1352
1369
|
const rlHtml = rlInfo.limited ? `<span class="status-badge sb-warn">限速中</span>` : '';
|
|
1353
1370
|
|
|
1354
|
-
|
|
1371
|
+
const dragAttrs = ` data-vendor="${tier.name}"` + (draggable ? ` draggable="true"` : '');
|
|
1372
|
+
const handle = draggable ? `<div class="drag-handle" title="拖拽调整优先级">⠿</div>` : '';
|
|
1373
|
+
|
|
1374
|
+
return `<div class="vendor-item"${dragAttrs}>
|
|
1355
1375
|
<div class="vendor-info">
|
|
1376
|
+
${handle}
|
|
1356
1377
|
<div class="vendor-avatar">${initial}</div>
|
|
1357
1378
|
<span class="vendor-name">${tier.name}</span>
|
|
1358
1379
|
</div>
|
|
@@ -1365,6 +1386,110 @@ function updateVendorStatus(status) {
|
|
|
1365
1386
|
}).join('');
|
|
1366
1387
|
}
|
|
1367
1388
|
|
|
1389
|
+
// ── 供应商状态:拖拽调整优先级(运行时重排,不重置配额) ────
|
|
1390
|
+
const _tierDrag = { active: false, srcName: null, inFlight: false };
|
|
1391
|
+
|
|
1392
|
+
function _tierDragClearIndicators() {
|
|
1393
|
+
document.querySelectorAll('#vendor-list .drag-over-before, #vendor-list .drag-over-after')
|
|
1394
|
+
.forEach(function(el) { el.classList.remove('drag-over-before', 'drag-over-after'); });
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
function _tierDragPosition(item, clientY) {
|
|
1398
|
+
// 鼠标相对目标行中点的位置 → 插入到上方或下方
|
|
1399
|
+
const rect = item.getBoundingClientRect();
|
|
1400
|
+
return clientY < rect.top + rect.height / 2 ? 'before' : 'after';
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function initTierDrag() {
|
|
1404
|
+
// 事件委托绑定在静态容器 #vendor-list 上一次;子节点重渲染后仍生效
|
|
1405
|
+
const list = document.getElementById('vendor-list');
|
|
1406
|
+
if (!list || list.dataset.dndBound === '1') return;
|
|
1407
|
+
list.dataset.dndBound = '1';
|
|
1408
|
+
|
|
1409
|
+
list.addEventListener('dragstart', function(e) {
|
|
1410
|
+
const item = e.target && e.target.closest && e.target.closest('.vendor-item');
|
|
1411
|
+
if (!item || !item.draggable) return;
|
|
1412
|
+
_tierDrag.active = true;
|
|
1413
|
+
_tierDrag.srcName = item.dataset.vendor;
|
|
1414
|
+
item.classList.add('dragging');
|
|
1415
|
+
if (e.dataTransfer) {
|
|
1416
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
1417
|
+
try { e.dataTransfer.setData('text/plain', _tierDrag.srcName || ''); } catch (_) {}
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1421
|
+
list.addEventListener('dragover', function(e) {
|
|
1422
|
+
if (!_tierDrag.active) return;
|
|
1423
|
+
e.preventDefault(); // 允许 drop(无论是否命中某一行)
|
|
1424
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
|
|
1425
|
+
const item = e.target && e.target.closest && e.target.closest('.vendor-item');
|
|
1426
|
+
_tierDragClearIndicators();
|
|
1427
|
+
if (!item || item.dataset.vendor === _tierDrag.srcName) return;
|
|
1428
|
+
item.classList.add(_tierDragPosition(item, e.clientY) === 'before' ? 'drag-over-before' : 'drag-over-after');
|
|
1429
|
+
});
|
|
1430
|
+
|
|
1431
|
+
list.addEventListener('drop', function(e) {
|
|
1432
|
+
if (!_tierDrag.active) return;
|
|
1433
|
+
e.preventDefault();
|
|
1434
|
+
const listEl = document.getElementById('vendor-list');
|
|
1435
|
+
const dragged = listEl.querySelector('.vendor-item.dragging');
|
|
1436
|
+
if (!dragged) return;
|
|
1437
|
+
let target = e.target && e.target.closest && e.target.closest('.vendor-item');
|
|
1438
|
+
if (!target) {
|
|
1439
|
+
// 落在容器空白处 → 移到末尾
|
|
1440
|
+
if (listEl.lastElementChild !== dragged) listEl.appendChild(dragged);
|
|
1441
|
+
} else if (target !== dragged) {
|
|
1442
|
+
const ref = _tierDragPosition(target, e.clientY) === 'before' ? target : target.nextElementSibling;
|
|
1443
|
+
if (ref !== dragged) listEl.insertBefore(dragged, ref);
|
|
1444
|
+
}
|
|
1445
|
+
_tierDragClearIndicators();
|
|
1446
|
+
const order = Array.from(listEl.children)
|
|
1447
|
+
.filter(function(el) { return el.classList.contains('vendor-item'); })
|
|
1448
|
+
.map(function(el) { return el.dataset.vendor; })
|
|
1449
|
+
.filter(Boolean);
|
|
1450
|
+
persistTierOrder(order);
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
list.addEventListener('dragend', function() {
|
|
1454
|
+
_tierDrag.active = false;
|
|
1455
|
+
_tierDrag.srcName = null;
|
|
1456
|
+
_tierDragClearIndicators();
|
|
1457
|
+
document.querySelectorAll('#vendor-list .dragging')
|
|
1458
|
+
.forEach(function(el) { el.classList.remove('dragging'); });
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
function persistTierOrder(names) {
|
|
1463
|
+
if (_tierDrag.inFlight) return; // 防并发:上一次未决则忽略
|
|
1464
|
+
if (!Array.isArray(names) || names.length < 2) return;
|
|
1465
|
+
_tierDrag.inFlight = true;
|
|
1466
|
+
fetch('/api/tier-order', {
|
|
1467
|
+
method: 'PUT',
|
|
1468
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1469
|
+
body: JSON.stringify({ vendors: names })
|
|
1470
|
+
}).then(function(res) {
|
|
1471
|
+
_tierDrag.inFlight = false; // 先清守卫,允许随后的 refreshOverview 重渲染
|
|
1472
|
+
if (res.ok) {
|
|
1473
|
+
// 服务端已更新顺序;刷新以同步请求趋势图等的排序
|
|
1474
|
+
if (!_tierDrag.active) refreshOverview().catch(function() {});
|
|
1475
|
+
} else {
|
|
1476
|
+
console.error('tier-order rejected:', res.status);
|
|
1477
|
+
_tierRevertToList();
|
|
1478
|
+
}
|
|
1479
|
+
}).catch(function(e) {
|
|
1480
|
+
_tierDrag.inFlight = false;
|
|
1481
|
+
console.error('tier-order failed:', e);
|
|
1482
|
+
_tierRevertToList();
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
function _tierRevertToList() {
|
|
1487
|
+
// 回滚到服务端真实顺序(PUT 失败 → 服务端顺序未变)
|
|
1488
|
+
fetchJSON('/api/status').then(function(status) {
|
|
1489
|
+
updateVendorStatus(status);
|
|
1490
|
+
}).catch(function() {});
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1368
1493
|
// ── Model Calling 实时状态 ────────────────────────────────
|
|
1369
1494
|
function updateModelCalling(status) {
|
|
1370
1495
|
var wrap = document.getElementById('model-calling-wrap');
|
|
@@ -2200,6 +2325,7 @@ function switchTab(name) {
|
|
|
2200
2325
|
fetchJSON('/api/dashboard/summary?days=7').then(function(s) {
|
|
2201
2326
|
if (s && s.version) document.getElementById('version-badge').textContent = 'v' + s.version;
|
|
2202
2327
|
}).catch(function(){});
|
|
2328
|
+
initTierDrag(); // 绑定供应商列表拖拽(事件委托,幂等)
|
|
2203
2329
|
refresh(); // 仅加载初始页签的数据
|
|
2204
2330
|
setInterval(refresh, 600000); // 每 10 分钟刷新当前页签
|
|
2205
2331
|
if (initial === 'overview') startModelCallingPoll();
|
coding/proxy/server/routes.py
CHANGED
|
@@ -386,6 +386,53 @@ def register_admin_routes(app: Any, router: Any) -> None:
|
|
|
386
386
|
)
|
|
387
387
|
|
|
388
388
|
|
|
389
|
+
def register_tier_order_route(app: Any, router: Any) -> None:
|
|
390
|
+
"""注册运行时 N-tier 链路顺序调整路由(纯重排序,不重置熔断器/配额守卫)."""
|
|
391
|
+
|
|
392
|
+
@app.put("/api/tier-order")
|
|
393
|
+
async def update_tier_order(request: Request) -> Response:
|
|
394
|
+
"""替换整个 N-tier 链路顺序.
|
|
395
|
+
|
|
396
|
+
JSON body: ``{"vendors": ["v1", "v2", ...]}``(需覆盖所有当前启用的 vendor)。
|
|
397
|
+
与 ``/api/reset`` 的重排序语义一致,但**不会**重置熔断器/配额守卫/rate limit,
|
|
398
|
+
以保留当日用量统计(供 Web 拖拽调整优先级使用)。
|
|
399
|
+
"""
|
|
400
|
+
try:
|
|
401
|
+
body = await request.json()
|
|
402
|
+
except Exception:
|
|
403
|
+
return json_error_response(
|
|
404
|
+
400, error_type="invalid_request_error", message="body must be JSON"
|
|
405
|
+
)
|
|
406
|
+
if not isinstance(body, dict):
|
|
407
|
+
return json_error_response(
|
|
408
|
+
400,
|
|
409
|
+
error_type="invalid_request_error",
|
|
410
|
+
message="body must be a JSON object",
|
|
411
|
+
)
|
|
412
|
+
raw = body.get("vendors")
|
|
413
|
+
if not isinstance(raw, list) or not raw:
|
|
414
|
+
return json_error_response(
|
|
415
|
+
400,
|
|
416
|
+
error_type="invalid_request_error",
|
|
417
|
+
message="requires non-empty 'vendors' list",
|
|
418
|
+
)
|
|
419
|
+
vendor_names = [str(v) for v in raw]
|
|
420
|
+
try:
|
|
421
|
+
router.reorder_tiers(vendor_names)
|
|
422
|
+
except ValueError as exc:
|
|
423
|
+
return json_error_response(
|
|
424
|
+
400, error_type="invalid_request_error", message=str(exc)
|
|
425
|
+
)
|
|
426
|
+
return Response(
|
|
427
|
+
content=json.dumps(
|
|
428
|
+
{"ok": True, "tier_order": router.get_vendor_names()},
|
|
429
|
+
ensure_ascii=False,
|
|
430
|
+
).encode(),
|
|
431
|
+
status_code=200,
|
|
432
|
+
media_type="application/json",
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
|
|
389
436
|
def register_session_vendor_routes(app: Any, router: Any) -> None:
|
|
390
437
|
"""注册 Session-Vendor 运行时绑定路由."""
|
|
391
438
|
|
|
@@ -518,6 +565,7 @@ def register_all_routes(
|
|
|
518
565
|
register_concurrency_route(app, router)
|
|
519
566
|
register_copilot_routes(app, router)
|
|
520
567
|
register_admin_routes(app, router)
|
|
568
|
+
register_tier_order_route(app, router)
|
|
521
569
|
register_session_vendor_routes(app, router)
|
|
522
570
|
if reauth_coordinator:
|
|
523
571
|
register_reauth_routes(app, reauth_coordinator)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: coding-proxy
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2a4
|
|
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
|
|
@@ -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=
|
|
20
|
+
coding/proxy/config/config.default.yaml,sha256=P0QBPMGrGOlTVFncpC-u6oJ92nPWO_He95BF0ZgBW4g,23726
|
|
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
|
|
@@ -69,10 +69,10 @@ coding/proxy/routing/usage_parser.py,sha256=ZwPuMGtXAwdIOKrXLpdtA4nCmc83ViF6kw5J
|
|
|
69
69
|
coding/proxy/routing/usage_recorder.py,sha256=PHUHotCt3VaKkdJizMpPGsUOAj-f5qz9JKeiLEnFNgA,8779
|
|
70
70
|
coding/proxy/server/__init__.py,sha256=KeH7mEu36v9v27m3VgeSxSeFz9sLTJrxS_EVATJ7Vks,20
|
|
71
71
|
coding/proxy/server/app.py,sha256=3MYE8-Vsxpt1SVqTKReMKNREBsh_LHKIFq1B4jhfeL8,7121
|
|
72
|
-
coding/proxy/server/dashboard.py,sha256=
|
|
72
|
+
coding/proxy/server/dashboard.py,sha256=317gxNGlgFDXiRJjZ3q-AsGCkkuLwWPL5uibAmbavvA,102136
|
|
73
73
|
coding/proxy/server/factory.py,sha256=L0d0AA0fpkV-gynM85u1l5dXY1OQ5A_p_-PV0XlFGQs,10272
|
|
74
74
|
coding/proxy/server/responses.py,sha256=i0ugnLRNOdRYGHEWxkwsxR35ChmdMQsSaD8AjRluTn4,2167
|
|
75
|
-
coding/proxy/server/routes.py,sha256=
|
|
75
|
+
coding/proxy/server/routes.py,sha256=5f9ONVckM3LG2AftBW6YahelhjkP6XlgaYSH7MvXUp4,22362
|
|
76
76
|
coding/proxy/streaming/__init__.py,sha256=0al5TC-zJt8Bz0CibTmd8WPza-Cs-qcuZWvT2fKPqHI,23
|
|
77
77
|
coding/proxy/streaming/anthropic_compat.py,sha256=cycYiJ-glN88OmfLTR7FroHRethONlEcK0PT78KqGbA,21202
|
|
78
78
|
coding/proxy/vendors/__init__.py,sha256=fehSpQ2-kUlZY6N8cNMGVJYMXspQmi3V4e0FgC4Ay4k,1011
|
|
@@ -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.
|
|
97
|
-
coding_proxy-0.5.
|
|
98
|
-
coding_proxy-0.5.
|
|
99
|
-
coding_proxy-0.5.
|
|
100
|
-
coding_proxy-0.5.
|
|
96
|
+
coding_proxy-0.5.2a4.dist-info/METADATA,sha256=R8dbE0fCB_GW0vLHSO_D2-7N91Od6wdcwCldIX0ZUOE,11346
|
|
97
|
+
coding_proxy-0.5.2a4.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
98
|
+
coding_proxy-0.5.2a4.dist-info/entry_points.txt,sha256=moIVzt5ho0Wk9B47LOo2SEAbhzuDDHWi-EfM30U0XBg,54
|
|
99
|
+
coding_proxy-0.5.2a4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
100
|
+
coding_proxy-0.5.2a4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|