ysm119 (Discord) showed Tencent's docs: Token Plan's OpenAI base is now https://tokenhub.tencentmaas.com/plan/v3 and the Anthropic one on tokenhub.tencentmaas.com is the recommended one, with api.lkeap.cloud.tencent.com marked as going away. Tencent's current pages (product/1823/130060 个人版 overview, 130070 Claude Code, 130071 Codex, 130119 quickstart, 136601 CC Switch, all updated 10-15 to 10-22) give 个人版 the same endpoints as 企业版 China (130659): chat/responses at https://tokenhub.tencentmaas.com/plan/v3, messages at https://tokenhub.tencentmaas.com/plan/anthropic, one sk-tp- key for 通用 and Hy plans. - The tencent-cloud preset's plan region (and the preset default) are at those endpoints, with Responses added (Codex's page uses wire_api "responses"). magpie tells regions apart by endpoint, so the personal and China enterprise regions, now one address, are one: "plan", models the union of both lists. "enterprise" stays an alias (regionAliases, RegionID): a key saved on it, an import link with region=enterprise and `region=enterprise` on the CLI land on plan. Singapore 企业版 (enterprise-intl) is unchanged. - A Tencent Cloud provider saved at the old lkeap /plan/v3 or /plan/anthropic is moved to TokenHub at load (moveEndpoints in normalize), and gains the Responses endpoint when it had chat. A Responses address the user set stays. A provider of no preset (a custom one the user typed lkeap into) keeps its address: that is the user's value, and lkeap still answers today. - An app config still at lkeap (Tencent's OpenClaw page, 130062, still gives it) imports as tencent-cloud at the new endpoints. - Usage: DescribeTokenPlan is 企业版's API (api/1823/132270 lists enterprise products only), and Guangzhou's endpoint now serves 个人版 too, so a Guangzhou provider with no SecretId no longer gets the card asking for one (tcSharedRegion); Singapore's still does. The editor shows the optional SecretId/SecretKey at the plan region, so a personal user sees them too. - docs/subsystems/providers-accounts.md says all of this. Run at the pushed head's basef3551387con mote (rebased ontod29f02d65, which only touches internal/agent's omp; provider and cli re-run after the rebase): - go test -timeout 45m ./...: every package ok except three filed reds that touch nothing here: cli TestEveryRouteHasACommandOrIsNamed (#4826), gateway TestCodexPoolSaysTheClientsVersion (#4807), gui TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949). - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: nothing. - GUI tencent-cloud, tencent-access-key, i18n-keys (chromium+webkit, en/zh): 24 pass, 4 fail, all "a region clicked right after the strip scrolled" (#4321/#4399/#4625; app.js is unchanged here). Broken by hand, each red then green again: - normalize without moveEndpoints: TestTencentCloudOldPresetsKeepWorking and TestTencentPlanMovedFromLkeap fail. - the import's movedEndpoints lookup: TestTencentPlanMovedFromLkeap. - the Guangzhou card skip: TestPlanCardWithoutAccessKey. - RegionID in ParseImport: TestTencentPlanMovedFromLkeap; in the CLI: TestTencentOldRegionAtCLI. Not tried: no real Tencent key here, so no request reached either host and no real usage read. Tencent's international personal plan (CodeBuddy page tencentcloud.com/document/product/1300/81035) is at tokenhub-intl.tencentcloudmaas.com, a host magpie has no region for; not added. The 即将下线 label in ysm119's screenshot is not on the pages fetched, and no retirement date was found (FAQ 130076). The site's import-link builder still offers "Enterprise plan · China", which now adds the plan through the alias.
115 lines
3.4 KiB
Go
115 lines
3.4 KiB
Go
package gui
|
|
|
|
// Tencent Cloud's Token Plan 企业版 is read with the account's SecretId and
|
|
// SecretKey (#1574): the listing tells the editor the Tencent Cloud preset
|
|
// takes one at its plan regions alone (China's, which Token Plan 个人版
|
|
// shares with 企业版 since Tencent moved it there, ysm119; and 企业版's
|
|
// in Singapore), not at pay as you go, and whose it is, and a
|
|
// provider of it, at whatever region, its SecretId and whether a
|
|
// SecretKey is saved, never the SecretKey. Volcengine Ark's take one at
|
|
// all of theirs; another vendor's at none.
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
func TestProviderListTellsTencentAccessKey(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
mux := http.NewServeMux()
|
|
providerRoutes(mux, nil)
|
|
|
|
at := func(region string) provider.Provider {
|
|
t.Helper()
|
|
p, err := provider.FromPreset("tencent-cloud")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
pr := provider.Preset("tencent-cloud")
|
|
for _, r := range pr.Regions {
|
|
if r.ID == region {
|
|
p.Chat, p.Responses, p.Anthropic = r.Chat, r.Responses, r.Anthropic
|
|
}
|
|
}
|
|
return p
|
|
}
|
|
team := at("enterprise-intl")
|
|
team.Key, team.AccessKeyID, team.SecretAccessKey = "sk-tp-1", "AKID-1", "SK-1"
|
|
if err := provider.Save(team); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
personal := at("plan")
|
|
personal.ID, personal.Name, personal.Key = "tc-personal", "Tencent personal", "sk-tp-2"
|
|
if err := provider.Save(personal); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
w := httptest.NewRecorder()
|
|
mux.ServeHTTP(w, httptest.NewRequest("GET", "/api/providers", nil))
|
|
if w.Code != 200 {
|
|
t.Fatalf("%d %s", w.Code, w.Body)
|
|
}
|
|
if strings.Contains(w.Body.String(), "SK-1") {
|
|
t.Error("the listing told the SecretKey")
|
|
}
|
|
var got struct {
|
|
Providers []struct {
|
|
ID string `json:"id"`
|
|
AccessKey *accessKeyJSON `json:"accessKey"`
|
|
} `json:"providers"`
|
|
Presets []struct {
|
|
ID string `json:"id"`
|
|
AccessKey bool `json:"accessKey"`
|
|
AccessKeyVendor string `json:"accessKeyVendor"`
|
|
AccessKeyRegions []string `json:"accessKeyRegions"`
|
|
} `json:"presets"`
|
|
}
|
|
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ps := map[string]*accessKeyJSON{}
|
|
for _, x := range got.Providers {
|
|
ps[x.ID] = x.AccessKey
|
|
}
|
|
if a := ps["tencent-cloud"]; a == nil || a.Vendor != "tencent" || a.ID != "AKID-1" || !a.SecretSet {
|
|
t.Errorf("enterprise: %+v", a)
|
|
}
|
|
// at China's plan, 个人版's and 企业版's both, it takes one too
|
|
if a := ps["tc-personal"]; a == nil || a.Vendor != "tencent" || a.ID != "" || a.SecretSet {
|
|
t.Errorf("personal: %+v", a)
|
|
}
|
|
seen := 0
|
|
for _, pr := range got.Presets {
|
|
switch pr.ID {
|
|
case "tencent-cloud":
|
|
seen++
|
|
if !pr.AccessKey || pr.AccessKeyVendor != "tencent" || !slices.Equal(pr.AccessKeyRegions, []string{"plan", "enterprise-intl"}) {
|
|
t.Errorf("tencent-cloud preset: %+v", pr)
|
|
}
|
|
case "volcengine":
|
|
seen++
|
|
if !pr.AccessKey || pr.AccessKeyVendor != "volcengine" || pr.AccessKeyRegions != nil {
|
|
t.Errorf("volcengine preset: %+v", pr)
|
|
}
|
|
case "deepseek":
|
|
seen++
|
|
if pr.AccessKey || pr.AccessKeyVendor != "" {
|
|
t.Errorf("deepseek preset: %+v", pr)
|
|
}
|
|
}
|
|
}
|
|
if seen != 3 {
|
|
t.Errorf("presets seen: %d", seen)
|
|
}
|
|
}
|