Skip to content

feat: add WorkBuddy GLOBAL (workbuddy.ai) region support + refreshed model catalog - #23

Open
bimapopo345 wants to merge 1 commit into
Sliverkiss:masterfrom
bimapopo345:feat/global-region-and-model-catalog
Open

feat: add WorkBuddy GLOBAL (workbuddy.ai) region support + refreshed model catalog#23
bimapopo345 wants to merge 1 commit into
Sliverkiss:masterfrom
bimapopo345:feat/global-region-and-model-catalog

Conversation

@bimapopo345

Copy link
Copy Markdown

Summary

Adds WorkBuddy Global (workbuddy.ai) support alongside the existing CN realm, and refreshes the static model catalog to match the current WorkBuddy Global UI.

Motivation

The login tool was hardcoded to the CN realm (copilot.tencent.com, "CN realm only"), while the server itself already supports both regions via ChatBaseGlobal. Users holding Global accounts had no way to log in through this tool — the OAuth flow would always send them to codebuddy.cn.

Changes

cmd/login (region-aware OAuth)

  • login url [cn|global] and login poll [cn|global]global is the default
  • Global base: https://www.workbuddy.ai with identical /v2/plugin/auth/state|token|login/account?platform=CLI endpoints (verified against Maquer/workbuddy-checkin login.sh, which documents the Global realm)
  • Origin/Referer headers switch per region (codebuddy.cn vs workbuddy.ai)
  • Per-region state files stored in the repo directory instead of /tmp (Windows has no /tmp; this bit me on Windows Server RDP)
  • domain defaults to www.workbuddy.ai for global when upstream omits it, so auth.Region() classifies correctly

internal/server (model catalog)

  • Static fallback catalog refreshed from the current WorkBuddy Global UI (20 models): hy4-preview (free tier, ~1M ctx), hy3/hy3-preview/hy3-preview-agent, gpt-5.6-sol/terra/luna, gpt-5.5, gpt-5.4, gpt-5.3-codex, gemini-3.5-flash, glm-5.3, kimi-k3, plus the existing ones

Testing (Windows Server RDP, Go 1.26)

  • login url global → valid authUrl from workbuddy.ai ✅
  • Browser login → login poll global → token JSON with domain: www.workbuddy.ai
  • Converted credential loaded into pool (healthy: 1) ✅
  • /v1/chat/completions through the proxy: glm-5.1 ✅ 200, hy3 ✅ 200, hy4-preview ✅ 200, minimax-m3 ✅ 200
  • kimi-k2.7 / deepseek-v4-flash currently return upstream 503 (code 11134/11102, "service unavailable / service info not found") — upstream-side, unrelated to this PR
  • Note: the Global upstream requires a system message first (code 11128: first message is not system prompt) — worth documenting

Notes

  • The CN flow is untouched (default headers/URLs identical to before when cn is passed)
  • Context lengths in the catalog are approximated from public model info; happy to adjust

Copilot AI lite review requested due to automatic review settings September 7, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The login tool currently hard-codes state file paths to a machine-specific Windows location and accepts invalid region values silently, both of which can break or misroute logins in real usage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds WorkBuddy GLOBAL (workbuddy.ai) support to the CLI OAuth login flow and refreshes the server’s static fallback model catalog to reflect the current Global UI, improving usability for non-CN accounts when dynamic model discovery fails.

Changes:

  • Add region-aware OAuth login to cmd/login with login url [cn|global] / login poll [cn|global] (default: global), switching base URLs and Origin/Referer per region.
  • Refresh internal/server static fallback model catalog with additional Global models.
File summaries
File Description
cmd/login/main.go Makes the CLI login flow region-aware (CN vs Global) and adjusts state/token/account requests accordingly.
internal/server/handler.go Updates the static fallback model list used when dynamic model fetch fails.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/login/main.go
Comment on lines +31 to +32
stateFileCN = "C:/Users/Administrator/Desktop/Mod/workbuddy2api/.wb2api-login-state-cn.json"
stateFileGlobal = "C:/Users/Administrator/Desktop/Mod/workbuddy2api/.wb2api-login-state-global.json"
Comment thread cmd/login/main.go
Comment on lines +103 to +107
region := "global"
if len(os.Args) >= 3 {
region = os.Args[2]
}
// 每个流程独立 cookie jar(oauth.go:22-29:多账号登录互不串会话)
base, origin, stateFile := bases(region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants