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.
99 lines
3.3 KiB
Go
99 lines
3.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// Bailian's decision model is added with its workspace or plan, and a
|
|
// System One API of another vendor with decide= (#647).
|
|
func TestProviderDecidePairs(t *testing.T) {
|
|
p, err := provider.FromPreset("bailian-decision")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := applyPairs(&p, []string{"workspace=ws-1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p.Decide != "https://ws-1.cn-beijing.maas.aliyuncs.com/compatible-mode/v1" {
|
|
t.Fatalf("workspace: %s", p.Decide)
|
|
}
|
|
p, _ = provider.FromPreset("bailian-decision")
|
|
if err := applyPairs(&p, []string{"workspace=ws-2", "region=ap-southeast-1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p.Decide != "https://ws-2.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1" {
|
|
t.Fatalf("Singapore: %s", p.Decide)
|
|
}
|
|
p, _ = provider.FromPreset("bailian-decision")
|
|
if err := applyPairs(&p, []string{"plan=token-plan"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p.Decide != "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1" || !strings.Contains(p.KeysURL, "token-plan") {
|
|
t.Fatalf("Token Plan: %s %s", p.Decide, p.KeysURL)
|
|
}
|
|
if err := applyPairs(&p, []string{"workspace=ws-3"}); err == nil {
|
|
t.Fatal("a workspace taken for the Token Plan")
|
|
}
|
|
if err := applyPairs(&p, []string{"region=mars"}); err == nil || !strings.Contains(err.Error(), "token-plan") {
|
|
t.Fatalf("unknown region: %v", err)
|
|
}
|
|
c := provider.Provider{Name: "My Decider"}
|
|
if err := applyPairs(&c, []string{"decide=https://decide.example.com/v1", "models=my-decision-model", "key=sk-1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !c.DecideOnly() || c.Jev() != "my-decision-model" || !c.DecidesModel("my-decision-model") {
|
|
t.Fatalf("custom: %+v asked as %s", c, c.Jev())
|
|
}
|
|
}
|
|
|
|
func TestRemoteMagpieAddReportsModels(t *testing.T) {
|
|
for _, tc := range []struct{ name, list, want string }{
|
|
{"unreachable", "", "no models exposed yet"},
|
|
{"chat only", `{"data":[{"id":"lib/m1"}]}`, "1 models in the catalog"},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
groupsHome(t)
|
|
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
io.WriteString(w, tc.list)
|
|
}))
|
|
t.Cleanup(up.Close)
|
|
if tc.list == "" {
|
|
up.Close()
|
|
}
|
|
out, err := stdoutOf(t, func() error {
|
|
return providerCmd([]string{"provider", "add", "remote-magpie", "remote-key", "url=" + up.URL, "id=office"})
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(out, tc.want) || strings.Contains(out, "classifier=office/") {
|
|
t.Errorf("remote add said %q; want %q and no empty classifier", out, tc.want)
|
|
}
|
|
if tc.list == "" && !strings.Contains(out, "refused") {
|
|
t.Errorf("remote list error hidden: %q", out)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// region=enterprise on Tencent Cloud, from before Token Plan 个人版 and
|
|
// 企业版 in China were served at one endpoint (ysm119), is the plan's.
|
|
func TestTencentOldRegionAtCLI(t *testing.T) {
|
|
p, _ := provider.FromPreset("tencent-cloud")
|
|
if err := applyPairs(&p, []string{"region=intl"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := applyPairs(&p, []string{"region=enterprise"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p.Chat != "https://tokenhub.tencentmaas.com/plan/v3" || p.Anthropic != "https://tokenhub.tencentmaas.com/plan/anthropic" {
|
|
t.Fatalf("region=enterprise: %s %s", p.Chat, p.Anthropic)
|
|
}
|
|
}
|