mslxdff 0.1.81 → 0.1.83
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.
package/package.json
CHANGED
package/src/bench/report.js
CHANGED
|
@@ -91,7 +91,15 @@ export function formatViaReport(results, { peers = [], meta = {}, json = false }
|
|
|
91
91
|
const isDirectBest = bestKey === "direct";
|
|
92
92
|
const directCell = pad(`${directTxt}${isDirectBest ? "★" : ""}`, colW, "right");
|
|
93
93
|
const viaCells = peerIds.map((pid) => {
|
|
94
|
-
|
|
94
|
+
// via keys 可能存为完整 url(如 http://172...)而 peerIds 已短化,兼容两者
|
|
95
|
+
let v = r.via?.[pid];
|
|
96
|
+
if (!v) {
|
|
97
|
+
// 尝试完整 url 变体
|
|
98
|
+
const full = Object.keys(r.via || {}).find((k) => {
|
|
99
|
+
try { const u = new URL(k); return (u.hostname + (u.port ? `:${u.port}` : "")) === pid; } catch { return false; }
|
|
100
|
+
});
|
|
101
|
+
if (full) v = r.via[full];
|
|
102
|
+
}
|
|
95
103
|
if (!v) return pad("—", colW, "right");
|
|
96
104
|
if (v.ok) {
|
|
97
105
|
const txt = `${v.ttfbMs ?? v.totalMs ?? "—"}ms`;
|
package/src/bench/via.js
CHANGED
|
@@ -101,8 +101,10 @@ export async function orchestrateVia({
|
|
|
101
101
|
for (const peer of peers) {
|
|
102
102
|
const raw = String(peer.name || peer.id || peer.url || "peer");
|
|
103
103
|
let peerId = raw;
|
|
104
|
-
//
|
|
105
|
-
if (
|
|
104
|
+
// 组员 name 可能存为完整 url(如 http://172.93...),统一短化为 host:port,防止 report 端 peerIds 与 via keys 不一致导致表格空白
|
|
105
|
+
if (raw.includes("://")) {
|
|
106
|
+
try { const u = new URL(raw); const host = u.hostname; const port = u.port ? `:${u.port}` : ""; if (host) peerId = `${host}${port}`; else peerId = raw.slice(-16); } catch { peerId = raw.slice(-16); }
|
|
107
|
+
}
|
|
106
108
|
const peerToken = peer.token || token || "";
|
|
107
109
|
try {
|
|
108
110
|
const r = await viaProbeFn({ peerUrl: peer.url, token: peerToken, providerId: provider, model, prompt: "hi", maxTokens: 5, timeoutMs, clock });
|
|
@@ -29,11 +29,10 @@ async function clineBenchOne({ baseUrl, model, accessToken, prompt, maxTokens, t
|
|
|
29
29
|
const reader = res.body.getReader();
|
|
30
30
|
const decoder = new TextDecoder();
|
|
31
31
|
let buf = "";
|
|
32
|
-
const firstChunkAt = performance.now();
|
|
33
32
|
for (;;) {
|
|
34
33
|
const { done, value } = await reader.read();
|
|
35
34
|
if (done) break;
|
|
36
|
-
if (ttfbMs === null) ttfbMs = Math.round(performance.now() -
|
|
35
|
+
if (ttfbMs === null) ttfbMs = Math.round(performance.now() - t0);
|
|
37
36
|
buf += decoder.decode(value, { stream: true });
|
|
38
37
|
let idx;
|
|
39
38
|
while ((idx = buf.indexOf("\n")) >= 0) {
|
|
@@ -199,8 +198,18 @@ async function handleVia({ providerId, opts, fetchImpl, loadConfigs, loadKeys, l
|
|
|
199
198
|
const auth = auths[aIdx] || auths[0] || null;
|
|
200
199
|
const cKeys = keys.filter((k) => isRefreshToken(k, p));
|
|
201
200
|
if (cKeys.length) {
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
const normBase = String(baseUrl).replace(/\/+$/, "");
|
|
202
|
+
const chatBase = normBase.endsWith("/api/v1") ? normBase.slice(0, -7) : normBase;
|
|
203
|
+
const rt = cKeys[0];
|
|
204
|
+
const at = await refreshTokenForBase({ refreshToken: rt, baseUrl: normBase, fetchImpl });
|
|
205
|
+
if (!at) return { ok: false, label: "鉴权失败", error: "refresh failed", ttfbMs: null, totalMs: 0 };
|
|
206
|
+
const targetUrl = `${chatBase}/api/v1/chat/completions`;
|
|
207
|
+
const headers = clineHeaders(`sess_bench_via_${Date.now()}`, at);
|
|
208
|
+
const rawModel = String(model).startsWith(`${p}/`) ? String(model).slice(p.length + 1) : String(model);
|
|
209
|
+
const body = { model: rawModel, messages: [{ role: "user", content: "hi" }], stream: true, max_tokens: 5, session_id: `sess_bench_via_${Date.now()}`, reasoning_effort: "high" };
|
|
210
|
+
const peer = peers.find((pe) => pe.url === peerUrl || (pe.name || pe.id) === peerUrl);
|
|
211
|
+
const peerToken = peer?.token || token;
|
|
212
|
+
return viaProbe({ peerUrl, token: peerToken, relayTarget: targetUrl, relayHeaders: headers, relayBody: body, timeoutMs: opts.timeoutMs, fetchImpl });
|
|
204
213
|
}
|
|
205
214
|
const rawModel = String(model).startsWith(`${p}/`) ? String(model).slice(p.length + 1) : String(model);
|
|
206
215
|
const targetUrl = p === "opencode" ? `${process.env.UPSTREAM_BASE_URL || "https://opencode.ai"}/zen/v1/chat/completions` : `${String(baseUrl).replace(/\/+$/, "")}${chatPath}`;
|