Commit Graph
16 Commits
Author SHA1 Message Date
Jason Xu 14faec7654 fix(gateway): harden free-tier retries and client compatibility
Preserve upstream HTTP failures across transport retries, classify title requests before shaping, and rename legacy functions exactly once.

Keep adjacent Responses assistant items together, including interleaved text and calls. Add opt-in prompt environment overrides with matching shell descriptions, strict validation, and WebUI round-trip preservation.

Document compatibility boundaries and retain existing defaults. Include the requested test/ ignore rule. Offline zz_ regressions passed and were removed after validation as requested; vet and Windows/Linux builds passed.

Refs #173, #175, #176, #178, #179, #181
2026-11-17 01:00:29 +08:00
Ray b296a61d0e feat(diagnostics): pin a Playground request to one relay (#167)
Resolved against #170 so a relay pin clears the per-attempt WARP choice
(attemptUseWARP). The relay list is now credential-redacted, and a pin may
name a relay by its redacted URL.
2026-11-05 12:56:56 +08:00
NEKOMYAandNekomyaDev cee32f7047 feat(models): add passive availability tracking and opt-in probes (#171)
* feat(models): add passive availability tracking and opt-in probes

* test(models): harden passive availability telemetry and catalog refresh overlap protection

---------

Co-authored-by: NekomyaDev <neko@nekomya.dev>
2026-11-05 11:41:52 +08:00
Jason Xu 58f56676ba feat(webui): theme toggle, paged ledger, working refresh status, and collapsed proxy chips
- Dark theme: an auto/light/dark cycle in the topbar, persisted per
  browser and applied before first paint by an inline head script; the
  dark palette moves behind data-theme so the runtime choice wins over
  the media query (#122).
- Request routing and upstream attempts tables are paged (50/100/200/500
  rows per page) instead of a hard last-100 cap, with translated pager
  controls (#122).
- Free-model refresh status now calls POST /api/models/probe, which
  marks every automatic model due and wakes the probe loop, then reloads
  the snapshot; the button re-probes instead of only rereading the cache
  (#122).
- The config page renders long key/proxy lists collapsed behind a
  100-chip cap with an expand toggle, so a large proxy pool no longer
  freezes the page (#146).
- New strings translated for en/vi/it; READMEs document the new
  admin endpoint.
2026-10-30 04:16:18 +08:00
Jason Xu 3136a5c4ab feat(warp): preload half the pool and register without a fixed gap
Registrations were paced by a fixed 12-second gap, which made a cold pool
and a 429 replacement wait minutes for capacity. Remove the gap: the
registrar now issues registrations back to back in the background,
serialized by the pool's create mutex, and only a rejected attempt backs
off (doJSON still honours Retry-After).

Keep half of warp.pool_size (at least one) hot as a preload: the first
exit still gates readiness, the rest register in the background, and
desiredLocked/scaleDown treat the preload as a floor so idle surplus is
still retired after 60 seconds but the warm bench survives. A 429 or 403
removes the exit from the ring and the next request uses a preloaded exit
immediately.

/healthz reports warp.preload, and the WebUI and all four READMEs
describe the behaviour.
2026-10-27 18:58:53 +08:00
Jason Xu b8b1454a0e fix(warp): rotate exits on a live pool and size it to concurrency
The WARP pool could never rotate: its lifetime context was derived from the
startup deadline, so every standby registration and replacement died with
"context canceled" and requests stayed on the first egress forever. Give the
first registration the caller's deadline and the pool a context that only
Close cancels.

- warp.pool_size is an upper bound. The active ring follows concurrency (one
  exit per lease, one per queued request, plus a spare) and trims idle surplus
  after 60 seconds, so a burst expands it and quiet periods shrink it.
- An IPv6 exit is deduplicated and cooled by its /64 for 30 minutes (IPv4 by
  its /32), since the free quota is scoped to that block.
- 429/403 retires an exit immediately and re-registers right away; a free
  model request keeps switching exits and only returns the last 429 after
  retry.max_attempts, on both the anonymous and the Zen-key lane. 429s no
  longer trip the anonymous breaker or cool the key.
- Pin HTTP/1.1 ALPN and TLSNextProto on the WARP transport: a clone of
  DefaultTransport made after its first dial negotiated h2 and fed SETTINGS
  frames to the HTTP/1.x reader, breaking catalog refresh.
- Default to the IPv6 stack and, with warp.source_ipv6, let each exit bind its
  own outer source from a routed prefix via IPV6_FREEBIND. Endpoints try IPv6
  first and fall back to IPv4, so IPv4-only hosts keep working.
- WebUI, config example and all READMEs describe the new pool and rotation
  behaviour.
2026-10-25 06:49:00 +08:00
Jason Xu 4438acb8e7 feat(egress): route free-model traffic through userspace WARP
Free-tier requests now optionally leave through a Cloudflare WARP tunnel that runs inside the gateway process: WireGuard over UDP plus a gVisor netstack, so no TUN device, root, NET_ADMIN, or route changes are needed. Adapted from github.com/sudogeeker/ai-route (MIT).

- warp.enabled/pool_size/stack in config, the WebUI, config.example.json and all READMEs; startup and hot reload fail closed when WARP cannot initialize.
- Anonymous lane, free-model Zen-key fallback, free-model probes and the anonymous catalog refresh send no proxy traffic while enabled; Go keys and paid models keep their proxies.
- Per-attempt leases feed 403/429 rotation and broken-tunnel failures back into the pool; /healthz and /api/monitor expose the pool state and readiness requires an active exit.
- errWARPUnavailable maps to a 503 warp_unavailable response.
2026-10-25 05:51:00 +08:00
Jason Xu 56a789d560 feat: add Italian WebUI localization
Repairs the Italian README documentation and includes all four README translations in release archives.
2026-10-23 07:02:00 +08:00
croccio fee095680f fix(webui): address PR #144 review — auto-detect Italian, wire API-key card, polish Italian copy 2026-10-22 13:57:48 +02:00
croccio 22d584f34c feat: add Italian localization for the WebUI
Extend the WebUI internationalization module with Italian (it) support,
including locale metadata (flag, label, date formats) and comprehensive
translation strings covering the operator manual, dashboard, configuration
center, diagnostics, quotas, and logs.
2026-10-21 10:23:41 +02:00
Jason Xu 81ad2842c7 refactor: drop new prefixes, unify v1/v2 lane naming, audit comments
- Remove the new/New prefix from constructors; rename the colliding
  types semantically (ModelCatalog, RuntimeController, Metrics,
  LogBroker, Redactor, proxyTransports, upstreamNodes, ...).
- Unify upstream lane naming on v1 (/zen, OpenCode 1.x shape) and v2
  (/inference and /zen/go, 2.x CLI shape); add models.IsV1Upstream and
  drop the duplicated lane detection.
- Fix inaccurate, truncated and stale comments across all packages and
  document exported symbols plus non-obvious internals.
- Fix anthropicThinking passing "enabled"/"adaptive" through as an
  effort; derive the level from the budget instead.
- Delete dead code (identity.StableID, unused protocol decoders and
  stream parser wrappers).
- Export EffectiveListeners, rename modelsDev* metadata constants, and
  describe the metadata source as the OpenCode endpoint.
- Rename the forced-collapse log event to stream_collapse_failed and
  add an anonymous field.
- Correct the README upstream.zen default and add upstream.anonymous.
2026-10-19 03:46:09 +08:00
Jason Xu 83d623d541 fix(webui): prevent duplicate v prefix in version and link to GitHub repo 2026-10-17 19:45:45 +08:00
Jason Xu 260211cd9e feat(proxy): support rotating proxy pools via #pool marker
An endpoint that already rotates exit IPs (Resin and similar gateways) was
handled like a static proxy, which defeated the rotation in three ways:

- the cloned transport kept HTTP/2 and keep-alive enabled, so every request
  reused one CONNECT tunnel and therefore one exit IP, drawing 429s;
- a single slow exit marked the whole entry unhealthy and keys were rebound,
  with scheduled recovery only every 15 minutes;
- any 429/5xx put the anonymous node into a 15s-120s cooldown, and that lane
  has no earliest-expiry fallback, so the request failed with
  "no healthy anonymous proxies available" (HTTP 502).

Mark an entry with a "#pool" fragment (or a "pool+" scheme prefix) to declare
it a rotating pool. Pool entries then open a fresh connection per attempt
(DisableKeepAlives, no HTTP/2, plus Connection: close on the request), are
excluded from cooldown, health eviction, and proxy rebinding, and may be
retried up to retry.max_attempts on the anonymous lane instead of once.

Config validation and redaction work on the clean URL, the marker stays
visible in the operator UI, and deduplication keeps a pool entry next to a
static proxy that dials the same endpoint since they are different routes.
2026-10-17 03:30:25 +08:00
Jason Xu a46de6fe29 Merge branch 'pr-89'
# Conflicts:
#	.github/workflows/checks.yml
#	README.md
#	README.zh-CN.md
#	docs/management.zh-CN.md
#	webui/app.js
#	webui/embed.go
#	webui/index.html
#	webui/styles.css
2026-10-17 01:54:21 +08:00
michaelliunsky e6797dab22 fix(webui): drop the zero timestamp from the quota catalog line
An unset catalog timestamp is the Go zero time; format it as a "not
ready" placeholder instead of rendering 0001-01-01.
2026-10-16 18:34:03 +08:00
michaelliunsky a0da31ed08 feat(webui): rebuild console with tabbed pages
Replace the single-file frontend (app.js, styles.css) with a multi-file
ES module structure served from go:embed, and reorganize the 13 pages
into 8 tabbed pages under 4 navigation groups: runtime (overview,
diagnostics), integrations (access guide, API keys), models (quotas,
rotation), and system (configuration, account).

The redesign adopts a monochrome light/dark design system driven by
prefers-color-scheme, replaces prompt()/confirm() flows with in-page
dialogs, and keeps every management API call and deep link (old hashes
alias to the new pages).

Behavior changes: the log SSE connection now spans the whole console
session and buffers while the stream tab is hidden; quota polling runs
only while its tab is active; the first-run checklist appears on the
overview page and hides once ready.

Also fixes a crash on the rotation page: the persisted state serializes
empty orders and maps as JSON null, which is now normalized before
rendering, with the same defensive handling in the quota and API key
pages.

CI now syntax-checks the ES modules via node --input-type=module, and
the README structure notes are updated.
2026-10-16 18:09:42 +08:00