Commit Graph
34 Commits
Author SHA1 Message Date
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
Jason Xu d4f1e136ed Merge branch 'pr-98'
# Conflicts:
#	webui/styles.css
2026-10-17 01:11:21 +08:00
WengeLiu101 6c9be9037f fix(webui): make sidebar nav reachable on short viewports and stop overflow on narrow screens 2026-10-16 19:35:31 +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
hanlap0503 6150f7da28 fix(webui): align language flag in toolbar and auto-detect browser language 2026-10-15 10:06:22 +00:00
hanlap0503 1e81532be8 fix(webui): pin login language selector to top-right 2026-10-15 09:55:58 +00:00
hanlap0503 c8501653fd feat(webui): move language selector to far right of toolbar 2026-10-15 09:51:31 +00:00
hanlap0503 184f3127ac feat(webui): borderless flag selector without dropdown arrow 2026-10-15 09:50:13 +00:00
hanlap0503 86ea7dae74 feat(webui): show flag-only language selector aligned with toolbar 2026-10-15 09:46:54 +00:00
hanlap0503 6833a5d7a8 feat(webui): replace language toggle buttons with dropdown selectors 2026-10-15 09:41:14 +00:00
hanlap0503 68e7c1bf3e fix(webui): restore flag button styles after css revert 2026-10-15 09:34:43 +00:00
hanlap0503 0c016a1e36 feat(webui): add Vietnamese interface with a runtime language switch
Translate the whole management console and let the operator pick a language
without replacing the shipped copy.

- webui/i18n.js holds the dictionaries only; the Simplified Chinese text stays
  in index.html and app.js and is the fallback for every untranslated string,
  so a new locale never rewrites the original.
- Static text uses data-i18n / data-i18n-attr hooks, JavaScript text goes
  through t(); a locale switch re-renders both without a reload, and the
  choice persists in localStorage under opencode2api.ui.lang.
- The switcher is a flag button in the toolbar and on the login card that
  opens a menu of every supported locale. Flags are inline SVG, because
  Unicode flag emoji renders as plain letters on Windows.
- Ships 简体中文 (original), English and Tiếng Việt.
- README.vi.md translates the full README; all three READMEs cross-link and
  document how to add a locale.
2026-10-15 09:20:28 +00:00
Jason Xu 25afadd303 feat: split usage by server key (#58)
Usage was only broken down by model and tier, so a gateway shared by
several callers could not tell how much each server key consumed.
authenticate now records the fingerprint of the key that matched, and the
monitor keeps requests and tokens per key in usage.server_keys for both
the lifetime and the last hour; the entries sum to the aggregate totals.
/api/api-keys attaches each key's usage and the WebUI shows it in the key
list. Playground traffic borrows the first enabled key, so it is counted
under "playground" instead. Like the rest of the monitor, the figures
survive hot reloads and reset on restart.

Closes #58.
2026-10-15 08:22:49 +08:00
Jason Xu d04a9c750d feat: add models.free_only to expose only free models (#66)
With Zen or Go keys configured, every paid model was exposed and routable.
models.free_only rejects models that are not free in both routing entry
points, so /v1/models, inference, rotation aliases and diagnostics agree.
Free models keep their key fallback. The WebUI gains a toggle so saving
the form no longer resets the field, and the docs note that free models
never require a Zen key.

Closes #66.
2026-10-15 08:08:01 +08:00
CheerC 1e2702f6e0 fix: preserve manual control of free models (#57)
Keep manually restored free models enabled until automatic control is selected.
Persist the control mode and expose an authenticated per-model toggle in the WebUI and admin API.
Preserve disable evidence, renew expired 24-hour retries after inconclusive probes, and keep mode changes idempotent.

Validation: local regression checks, go vet/build, formatting and WebUI syntax passed; all five GitHub Checks passed. Test files were removed after validation.

Closes #56
2026-10-08 22:12:40 +08:00
Jason Xu ef2df3f056 fix: correct free-model probes and add adaptive reasoning (#54) 2026-10-08 00:19:40 +08:00
Jason Xu df119c48e4 发布准备:合入 #36、#46、#48、#49、#50、#53;修复 #42、#44、#51、#52,并添加 GPL-3.0-or-later。
保留 reasoning 配置,新增免费模型可用性探测 / 手动恢复、首 SSE 事件超时,元数据改用官方地址。按维护者要求,最终文件树排除测试文件。

验证:本地 Go 回归、go vet / build、Prettier、JS / shell 语法及独立实例管理端验收通过。
2026-10-07 19:55:34 +08:00
Jason Xu 31c35704be Merge pull request #36: model rotation, quotas and API key management 2026-10-07 19:37:30 +08:00
Jason Xu 8e776c43b5 style: format webui and documentation 2026-09-21 14:38:30 +08:00
Jason Xu 683b7e9af0 feat: expose configurable reasoning effort 2026-09-21 14:34:00 +08:00
haverainlilili 3440273f43 feat: 新增模型轮转、额度看板和密钥管理 2026-09-21 10:18:21 +08:00
Jason Xu 46def7fedc refactor: organize Go packages and remove test files
Move the command to cmd/opencode2api and group production code into
configuration, gateway, protocol, model, admin, telemetry and helper packages.
Keep shared state private behind context, metrics and runtime interfaces.

Remove the requested test files and replace test-only CI jobs with vet/build
checks. Update Docker and release build paths, preserve version injection and
make the WebUI an explicit embedded asset package.

Add directory trees and source reading guides to both READMEs. Anchor binary
ignore rules so the command package is tracked.
2026-09-15 01:28:44 +08:00
Jason Xu ea29a62eca fix: harden gateway routing and protocol fidelity
Preserve request parameters, tool-call completion reasons and retry session
affinity. Bound upstream header waits, stop expired-context scans and add
opt-in redacted request-body diagnostics.

Isolate Playground diagnostics from production pools, report stream failures
accurately, align readiness with discoverable models and honor Docker listen
configuration.

Split Go and WebUI modules by responsibility, add regression tests and CI,
standardize formatting and rewrite the English and Chinese READMEs.

Refs: #6, #18, #19, #20, #21, #22, #23, #24, #25
2026-09-15 00:43:35 +08:00
Jason Xu 2c87495826 feat: improve stream monitoring and model catalog reliability 2026-09-04 02:22:27 +08:00
Jason Xu 3be4b393c0 feat: show upstream key suffix per request 2026-08-27 21:36:17 +08:00
Jason Xu cc71ba8aff feat: revise free model routing fallback 2026-08-20 04:01:39 +08:00
Jason Xu a4d37a8d3a feat: add usage playground and diagnostic views 2026-08-20 00:39:07 +08:00
Jason Xu af133b8f8c feat: redesign authenticated web console 2026-08-20 00:39:07 +08:00
Jason Xu 8e131dcf3b feat: add anonymous Zen support 2026-08-17 12:40:24 +08:00
Jason Xu fdae1902a0 feat: add authenticated web management console 2026-08-16 04:29:43 +08:00