feat: add WorkBuddy GLOBAL (workbuddy.ai) region support + refreshed model catalog - #23
Open
bimapopo345 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟡 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/loginwithlogin url [cn|global]/login poll [cn|global](default: global), switching base URLs and Origin/Referer per region. - Refresh
internal/serverstatic 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 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 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaChatBaseGlobal. 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]andlogin poll [cn|global]—globalis the defaulthttps://www.workbuddy.aiwith identical/v2/plugin/auth/state|token|login/account?platform=CLIendpoints (verified against Maquer/workbuddy-checkinlogin.sh, which documents the Global realm)codebuddy.cnvsworkbuddy.ai)/tmp(Windows has no/tmp; this bit me on Windows Server RDP)domaindefaults towww.workbuddy.aifor global when upstream omits it, soauth.Region()classifies correctlyinternal/server (model catalog)
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 onesTesting (Windows Server RDP, Go 1.26)
login url global→ valid authUrl from workbuddy.ai ✅login poll global→ token JSON withdomain: www.workbuddy.ai✅healthy: 1) ✅/v1/chat/completionsthrough the proxy:glm-5.1✅ 200,hy3✅ 200,hy4-preview✅ 200,minimax-m3✅ 200kimi-k2.7/deepseek-v4-flashcurrently return upstream 503 (code 11134/11102, "service unavailable / service info not found") — upstream-side, unrelated to this PRcode 11128: first message is not system prompt) — worth documentingNotes
cnis passed)