fix: review fixes, GitHub Releases update check (0.1.1)

- Wallet/subscription/window exhaustion skips a key for 10 minutes instead
  of disabling it; a balance read showing money brings it back. Only the
  gateway's own key refusals and a used-up key cap still disable a key.
- Classify by sub2api's exact wording; a bare 401 or upstream text no
  longer retires a key; 'No available accounts' is capacity, not coverage.
- Hosts keep only an https origin (no doubled /v1); timeouts and HTTP
  answers no longer set a host aside; hand edits are re-probed.
- Balance: inactive subscriptions, per-plan subscription pooling, key caps
  kept out of the total, rate windows shown.
- Endpoint editor no longer empties itself after Save.
- Update check reads GitHub Releases and installs the release tarball;
  release workflow replaces npm publishing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
大阔andClaude Opus 5.5 committed 2026-10-15 01:15:24 +08:00
1 parent 86b8e4d24f
commit f4f4ce55b3
34 files changed
+953 -521

No files matched your search

+19 -5
View File
@@ -23,7 +23,13 @@ import {
} from './constants.js'
import { ambientFetch, boundedFetch, TransportError } from './request.js'
/** Accept an absolute http(s) origin and drop a trailing slash. */
const LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]'])
/**
* Accept an https origin, keeping only the origin: a pasted `/v1` (the base
* URL OpenAI clients use) would otherwise double every path. Plain http is
* refused outside loopback, because the key travels in a header.
*/
export function normalizeHost(value, fallback) {
const text = typeof value === 'string' ? value.trim() : ''
if (text === '') return fallback
@@ -33,8 +39,9 @@ export function normalizeHost(value, fallback) {
} catch {
return fallback
}
if (url.protocol !== 'https:' && url.protocol !== 'http:') return fallback
return `${url.origin}${url.pathname.replace(/\/+$/u, '')}`
if (url.protocol === 'https:') return url.origin
if (url.protocol === 'http:' && LOOPBACK.has(url.hostname)) return url.origin
return fallback
}
/**
@@ -49,10 +56,16 @@ export function normalizeHostList(value) {
return hosts.length === 0 ? [...DEFAULT_API_HOSTS] : hosts
}
/** Whether a failure means the host never answered. */
/**
* Whether a failure means the host never answered. A timeout is not: the
* host accepted the connection and the gateway behind it is slow, which every
* host would be. Text that carries an HTTP status is the gateway's answer,
* whatever words it uses.
*/
export function isTransportFailure(error) {
if (error instanceof TransportError) return error.aborted !== true
if (error instanceof TransportError) return error.aborted !== true && error.timedOut !== true
const text = error instanceof Error ? error.message : typeof error === 'string' ? error : ''
if (/^\s*\d{3}\b|\(\d{3}\)|status code \d{3}|HTTP \d{3}/u.test(text)) return false
return /fetch failed|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|UND_ERR_|socket hang up|network error|other side closed|certificate|TLS|connect timeout|Connection error|ConnectTimeout|getaddrinfo/iu.test(text)
}
@@ -186,6 +199,7 @@ export function createHostPool({
return configured().map(host => ({
host,
current: host === best,
probed: probedAt !== 0,
...(latency.has(host) ? { latencyMs: latency.get(host) } : {}),
...(isCooling(host) ? { coolingUntil: cooling.get(host) } : {}),
}))