providers: an Alibaba Token Plan's AccessKey says the grants it needs, in the reader's language (MetalHqa on X)
MetalHqa on X: "阿里云百炼 Token Plan 的额度查询需要的权限不明确,希望能够在里面备注出来". Since456b5c6c7(#6506) the grants were named only in aliRAMHint, in English, on the Usage card after a NotAuthorised refusal, and the editor still said "a RAM user that may use Model Studio is enough", which is wrong: the AliyunBailian*/AliyunModelStudio* policies don't cover the Token Plan. Now: - The editor's AccessKey ID for an Alibaba Token Plan has one line under it (ALI_RAM): a RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none. The Secret's hint loses the wrong sentence. Volcengine and Tencent keys are unchanged. - A card refused with aliRAMHint says the same line in the reader's language (quotaError), the raw refusal still in its tooltip. - zh, zh-TW, ja and de for both strings. - aliRAMHint says "Subscription plan", as Alibaba's English docs do. Checked against Alibaba's docs: Token Plan 权限与使用规范 (RAM 子账号授权: AliyunTokenPlanReadOnlyAccess or FullAccess, AliyunBSSReadOnlyAccess or FullAccess, 账号管理页面 → 管理员或订阅套餐权限), the personal FAQ (个人版 BSS policy is AliyunBSSReadOnlyAccess) and the English page (Account Management, administrator or subscription plan permission). magpie reads the personal plan's usage only, so the read-only policies are named. Core script budget +275 (app.js and total): one string shown in two places, less the wrong clause it replaces; the editor and quotaError draw on every window, so there is no page to move it to. Run on mote ate97271f02+ this change: gofmt -l clean; go vet ./internal/provider ./internal/gui, GOOS=linux and windows go vet ./internal/provider; go test ./internal/provider -run 'TestAli|Alibaba' ok; go test -tags nogui ./internal/gui -run 'TestCoreScriptBudget|Words|I18n|Alibaba|AccessKey' ok; node --test of the new alibaba-ram-grants (20/20, Chromium and WebKit, all five languages, 420px) with every GUI file that draws an access key or a card error, i18n-keys, i18n-en-no-cjk, form-align, editor-advanced-align and quota-name-translated: 253 pass, 7 red, all under load ~70: editor-advanced-align (#6421, a Claude editor) and qianwen-plan's 8s sign-in wait (#6852); both green alone on this tree and on the base. Broken by hand: alibaba-ram-grants on the base's app.js and i18n.js is red in all 20 cases. After the rebase onto1bfc6378c: TestCoreScriptBudget, TestAliGateway, alibaba-ram-grants (20/20), i18n-keys and volc-access-key ok on mote. Not tried: a real RAM user's AccessKey (none here); the whole GUI suite.
This commit is contained in:
@@ -462,7 +462,7 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`.
|
||||
- A sub2api key's windows are fixed: each starts at the key's first request after it was empty, aligned to the relay's day, and a window not started yet says `used 0` with no `reset_at`, so it is taken to renew a span from now. They count this key's spend only, not the relay's accounts behind it. `ForgetBalances` (a key or Balance URL changed) has every key's windows read again at its next ask, a read begun before dropped; until then the last reading stands, fresher than the card's, which routing's reads never write. A key changed is another key (`keyID`), with windows of its own.
|
||||
- A Volcengine Ark provider's access key (`TakesVolcAccessKey`: any of its bases on `ark.<region>.volces.com`) is kept with its keys and never sent to the GUI: `/api/providers` tells the editor its ID and whether a Secret is saved (`accessKey`). A save that leaves the Secret blank keeps it, one that leaves the ID out or sends it blank keeps both (an editor opened before the key was given sends `""`, #1821), and `clearAccessKey` drops both. The ID and Secret go together everywhere the keys go: a copy takes them, also when its form sends the source's ID without the Secret (`AddCopy`), a backup or sync without keys has neither (`withoutKeys`), and a restore, mirror or sync keeps this machine's (`KeepSecrets` in `Restore`, `Mirror`, davsync's `take`) when it came without keys, or with the same key and no access key at all, as a magpie before v0.1.1142 or one the access key was never given on sends it (#1821); another key is another account and brings its own. A copy without keys keeps this machine's secret headers (`SecretHeader`) the same way. A plan endpoint with no provider on it holding the access key is a card that says which to give (`accessKeyCard`, `needsAccessKey`), with a button to the provider's settings, not a card left out. A `providers.json` saved with a UTF-8 BOM is read through it, not taken for a broken file whose `.bak` stands in. The plan read is the endpoint's: `/api/coding` asks `GetCodingPlanUsage`, `/api/plan` asks `GetAFPUsage`, pay-as-you-go (`/api/v3`) has no card; the region is the host's. One card is read for each access key and plan. `GetCodingPlanUsage`'s reply (`QuotaUsage[]` with `Level`, `Percent`, `ResetTimestamp` in seconds) is the one three tools built on it read; `GetAFPUsage`'s buckets are read in each form those tools read (`Used` of `Quota` or `Total`, or `Percent`; `ResetTime` or `ResetTimestamp`), none of them seen from a real account here. A reply none of that reads says so on the card with the reply's head. Changing the access key drops the cached cards (`ForgetPlanQuotas`).
|
||||
- A Tencent Cloud provider's SecretId and SecretKey are kept, listed and saved the same way, in the same fields (`AccessKeyVendor` tells the editor whose: `accessKey.vendor`, the preset's `accessKeyVendor`). Only the Token Plan's endpoints are read with them (`TakesTencentAccessKey`: `/plan` on `tokenhub.tencentmaas.com`, region `ap-guangzhou`, or `tokenhub-intl.tencentmaas.com`, `ap-singapore`). Since 10-22 Tencent serves 个人版 and 企业版 in China at the same `/plan` endpoints with the same `sk-tp-` keys (product/1823/130060, 130659), so they are one region, `plan` (a key saved on `enterprise` is on it, `regionAliases`/`RegionID`); 个人版 has no usage API, so a Guangzhou provider without a SecretId gets no card asking for one (`tcSharedRegion`), while Singapore's does. A Tencent Cloud provider saved at the old personal host `api.lkeap.cloud.tencent.com/plan/...` is moved to TokenHub's at load (`movedEndpoints`, `moveEndpoints` in `normalize`), with Responses added; one of no preset keeps the address its user typed, and an app imported at the old host lands on the plan. TokenHub's pay as you go has no plan and no card. A custom provider (no preset) at a Token Plan's or Ark plan's address is the user's own: its editor and Usage page ask it for no access key (`AsksAccessKey`) until one is saved on it, and its key goes as typed, `Authorization: Bearer` on chat and Responses (ysm119). The preset lists its regions that take one (`accessKeyRegions`, `presetAccessKey`), and the editor shows SecretId and SecretKey at those alone. `DescribeTokenPlanList` gives the account's team plans (a sub-user sees the ones it made); each is asked `DescribeTokenPlan` for its `PackageInfo` and `TokenSummary`, the list's kept for what the reply leaves out. The card's one window is `TotalUsed` of `CycleQuota` (else `TotalQuota`), resetting at `TokenSummary.CycleEndTime`, else counted in months from `StartTime` and never past `ExpireTime`. A plan not `enable` says its status beside the plan's name. Errors come back as 200 with `Response.Error`; an `AuthFailure…` or `UnauthorizedOperation` one says to check the key. Built from the API docs (api/1823/132270 and siblings) and the signing doc's worked example; never seen from a real account here.
|
||||
- An Alibaba Cloud Token Plan provider's AccessKey ID and Secret are kept in the same fields (`AccessKeyVendor` "alibaba"). Only the plan's two hosts at `token-plan.<region>.maas.aliyuncs.com` take them (`TakesAlibabaAccessKey`, `aliPlanSite`: `cn-beijing` is `bailian-token-plan`, `ap-southeast-1` is `alibaba-token-plan`, #2940); Qwen Cloud's plan has no read here (its console takes a browser sign-in, #5829). The Qwen AI platform's plan (`qwen-token-plan`, `token-plan.maas.qianwenaiapi.com`) is read through a sign-in to the platform instead, as the QianWen CLI 1.10.0 reads it (`qianwen_plan.go`, @imthe99galaxy on X): a device sign-in with PKCE at `t.qianwenai.com/cli/device/code` and `/cli/device/token`, the editor's *Sign in to the Qwen AI platform* (`qianwenplan.js`, imported when such a provider's editor opens) opening the approval page and polling it; the session is the provider's own, kept by provider id in `qianwen-auth.json` (0600) and moved or dropped with the provider. From it `cli.qianwenai.com/data/v2/api.json` (`GenerateCLIAccessToken`) mints a console token, kept and minted once more when the gateway answers `NotLogined`; the usage is the same `BroadScopeAspnGateway` call at `cs-data.qianwenai.com` with consoleSite `QIANWENAI` and region `cn-beijing`, read by `aliAskUsage` and `aliReadWindows`. The plan key (`sk-sp-`) is never sent there. Not signed in, the card says so with *Open settings* (`NeedsAccessKey`); a session the platform refuses is signed out. `TestQianwenSignIn`, `TestQianwenPlanQuotas`, `TestQianwenFollowsProvider`, `TestQianwenSignInRoutes`, `qianwen-plan.test.cjs`. Built from the CLI's source and the device endpoint's live replies; never signed in with a real account here. The plan key only authorizes inference. The usage is on the console's gateway behind a console token, which `POST modelstudio.<region>.aliyuncs.com/modelstudio/cli/generateAccessToken` (ACS3-HMAC-SHA256, `aliACSSign`; Action `GenerateCLIAccessToken`, version `2026-02-10`; reply `cliAccessToken`) makes from the AccessKey, as Alibaba's own `bl` CLI does. The token is kept 20 minutes per AccessKey and region and made again once when the gateway answers `BailianGateway.Login.NotLogined`. The gateway call is `POST <console>/cli/api.json?action=BroadScopeAspnGateway|IntlBroadScopeAspnGateway&product=sfm_bailian&api=zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage` with `Bearer` and a form `params`, `region`; the windows are the `per<N><Hour|Day|Week|Month>Percentage` (a share used, 0 to 1) and `ResetTime` (ms) fields of `data.DataV2.data.data`, so 5 hours, Weekly and Month show as the plan has them. A RAM user's key gets `BailianGateway.Team.NotAuthorised` until the main account grants what Alibaba's Token Plan docs ask for RAM users: the `AliyunTokenPlanReadOnlyAccess` and `AliyunBSSReadOnlyAccess` system policies (the `AliyunBailian*` and `AliyunModelStudio*` ones don't cover the Token Plan) and the Administrator or Subscribe Plan permission on Model Studio's Account Management page; the card and the editor's hint name all three (`aliRAMHint`, #6506). The same API serves the main account and RAM users; `bl` has no other route. Another refusal shows the console's `errorMsg`. Team plans (团队版) use other APIs and have no card. The gateway has no public doc: built from the official client's source; never seen from a real account here, and the international gateway host (`bailian-singapore-cs.alibabacloud.com`) is the least certain part.
|
||||
- An Alibaba Cloud Token Plan provider's AccessKey ID and Secret are kept in the same fields (`AccessKeyVendor` "alibaba"). Only the plan's two hosts at `token-plan.<region>.maas.aliyuncs.com` take them (`TakesAlibabaAccessKey`, `aliPlanSite`: `cn-beijing` is `bailian-token-plan`, `ap-southeast-1` is `alibaba-token-plan`, #2940); Qwen Cloud's plan has no read here (its console takes a browser sign-in, #5829). The Qwen AI platform's plan (`qwen-token-plan`, `token-plan.maas.qianwenaiapi.com`) is read through a sign-in to the platform instead, as the QianWen CLI 1.10.0 reads it (`qianwen_plan.go`, @imthe99galaxy on X): a device sign-in with PKCE at `t.qianwenai.com/cli/device/code` and `/cli/device/token`, the editor's *Sign in to the Qwen AI platform* (`qianwenplan.js`, imported when such a provider's editor opens) opening the approval page and polling it; the session is the provider's own, kept by provider id in `qianwen-auth.json` (0600) and moved or dropped with the provider. From it `cli.qianwenai.com/data/v2/api.json` (`GenerateCLIAccessToken`) mints a console token, kept and minted once more when the gateway answers `NotLogined`; the usage is the same `BroadScopeAspnGateway` call at `cs-data.qianwenai.com` with consoleSite `QIANWENAI` and region `cn-beijing`, read by `aliAskUsage` and `aliReadWindows`. The plan key (`sk-sp-`) is never sent there. Not signed in, the card says so with *Open settings* (`NeedsAccessKey`); a session the platform refuses is signed out. `TestQianwenSignIn`, `TestQianwenPlanQuotas`, `TestQianwenFollowsProvider`, `TestQianwenSignInRoutes`, `qianwen-plan.test.cjs`. Built from the CLI's source and the device endpoint's live replies; never signed in with a real account here. The plan key only authorizes inference. The usage is on the console's gateway behind a console token, which `POST modelstudio.<region>.aliyuncs.com/modelstudio/cli/generateAccessToken` (ACS3-HMAC-SHA256, `aliACSSign`; Action `GenerateCLIAccessToken`, version `2026-02-10`; reply `cliAccessToken`) makes from the AccessKey, as Alibaba's own `bl` CLI does. The token is kept 20 minutes per AccessKey and region and made again once when the gateway answers `BailianGateway.Login.NotLogined`. The gateway call is `POST <console>/cli/api.json?action=BroadScopeAspnGateway|IntlBroadScopeAspnGateway&product=sfm_bailian&api=zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage` with `Bearer` and a form `params`, `region`; the windows are the `per<N><Hour|Day|Week|Month>Percentage` (a share used, 0 to 1) and `ResetTime` (ms) fields of `data.DataV2.data.data`, so 5 hours, Weekly and Month show as the plan has them. A RAM user's key gets `BailianGateway.Team.NotAuthorised` until the main account grants what Alibaba's Token Plan docs ask for RAM users: the `AliyunTokenPlanReadOnlyAccess` and `AliyunBSSReadOnlyAccess` system policies (the `AliyunBailian*` and `AliyunModelStudio*` ones don't cover the Token Plan) and the Administrator or Subscription plan permission on Model Studio's Account Management page; the card names all three (`aliRAMHint`, #6506), and the GUI says them in the reader's language: under the editor's AccessKey ID and on a card whose error carries `aliRAMHint` (`ALI_RAM` in app.js, which `quotaError` matches on the hint's opening words). The same API serves the main account and RAM users; `bl` has no other route. Another refusal shows the console's `errorMsg`. Team plans (团队版) use other APIs and have no card. The gateway has no public doc: built from the official client's source; never seen from a real account here, and the international gateway host (`bailian-singapore-cs.alibabacloud.com`) is the least certain part.
|
||||
- Whether a Codex account spends its credits (`CodexNoCredits` in settings, opt-out, by lower-cased email) is the gateway's routing only. It never changes which account Codex is signed in to: `NextLogin` moves off an account at its routing's spent share, 100% at most, credits or not.
|
||||
- Whether a Claude account spends Anthropic's extra usage past its plan (`ClaudeNoExtraUsage` in settings, one switch for every Claude account, opt-out: Spend extra usage in the Claude editor's Advanced, or `magpie settings set claudeNoExtraUsage off`) is the gateway's routing and the warm-up only; a cap on an account's Usage credits window holds that account the same way once its extra usage reaches it (`provider/claude_extra.go`). magpie can't turn extra usage off at Anthropic: a Claude Code signed in on its own, not through magpie, still spends it. `NextLogin` already moves Claude Code off an account on overages, as the Extra usage row reads 100 (`claudeOveragesWindow`, `usedPast`). Claude Code's hidden `/limit-reset` is not driven: it spends or resets limits through a flow Anthropic hasn't made public, and calling its endpoints would be Claude Code's client imitated.
|
||||
- A Vertex AI provider's credentials are read only when a request is signed (`Sign`), so adding, listing and showing one ask Google nothing. With no `credentials` given and no file where Application Default Credentials are looked for, the request fails with `no Google credentials at <file>`, naming `gcloud auth application-default login` and the provider's credentials file as the ways to give it some. A `credentials` file that isn't there fails with the same words, saying to correct it or clear it. When Google refuses a person's sign-in (revoked, or past the organization's session length), the error says how to sign in again for the file used (`signInAgain`): gcloud's Application Default Credentials with `gcloud auth application-default login`, adding `--impersonate-service-account=<account>` when the file impersonates one; a file under gcloud's `legacy_credentials/<account>/` with `gcloud auth login <account>`; any other file by writing it anew or giving the provider another. The new file is read at the next request, with no restart.
|
||||
|
||||
@@ -10144,11 +10144,12 @@ function drawEditor(p, presetID) {
|
||||
pair.append(side);
|
||||
}
|
||||
const rows = [
|
||||
...field(idName, ak, ""),
|
||||
// what a RAM user's key needs (aliRAMHint, MetalHqa on X)
|
||||
...field(idName, ak, access.vendor === "alibaba" ? t(ALI_RAM) : ""),
|
||||
...field(secretName, pair, tc
|
||||
? t("Token Plan Enterprise's usage is told only to the Tencent Cloud account's API key (console → Access management → API keys), not to the plan's API key. Give its SecretId and SecretKey here for the Usage page to show it; a sub-user's key that may read TokenHub is enough. It is used for nothing else.")
|
||||
: access.vendor === "alibaba"
|
||||
? t("The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it; a RAM user that may use Model Studio is enough. It is used for nothing else.")
|
||||
? t("The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.")
|
||||
: t("The plan's 5-hour, weekly and monthly windows are told only to the account's access key (Volcengine console → API Access Keys), not to the plan's API key. Give it here for the Usage page to show them; it is used for nothing else.")),
|
||||
];
|
||||
ed.append(...rows);
|
||||
@@ -14056,6 +14057,8 @@ function redrawAccounts(agent) {
|
||||
// quotaError says why an allowance can't be read, the raw error in the tooltip.
|
||||
// SIGN_IN_GONE: a read saying the sign-in is gone (signInGone)
|
||||
const SIGN_IN_GONE = /sign-in has (expired|lapsed)|sign in again/i;
|
||||
// the grants Alibaba's Token Plan asks of a RAM user's AccessKey (aliRAMHint): the editor's note and its card's refusal
|
||||
const ALI_RAM = "A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none";
|
||||
|
||||
function quotaError(err, q) {
|
||||
if (/^Claude Code: claude-tui: .{0,40}(stays on its first-run screens|shows its first-run notes)/.test(err)) return t("Finish Claude Code's first-run setup, then refresh. Run magpie claude-code to find its executable.");
|
||||
@@ -14075,6 +14078,7 @@ function quotaError(err, q) {
|
||||
// a Volcengine or Tencent plan with no access key (#1821)
|
||||
if (/^this plan's usage is read with the account's access key: give its SecretId/.test(err)) return t("This plan's usage needs the account's SecretId and SecretKey — give them in the provider's settings");
|
||||
if (/^this plan's usage is read with the account's access key/.test(err)) return t("This plan's usage needs the account's AccessKey ID and Secret — give them in the provider's settings");
|
||||
if (/a RAM user's AccessKey needs/.test(err)) return t(ALI_RAM);
|
||||
// a Qwen AI platform plan (qianwen_plan.go)
|
||||
if (/^(this plan's usage is told only to a sign-in on|signed out of) the Qwen AI platform/.test(err)) return t("This plan's usage needs a sign-in to the Qwen AI platform — sign in in the provider's settings");
|
||||
// a Baidu Qianfan Token Plan Personal (qianfan_plan.go)
|
||||
|
||||
@@ -3946,7 +3946,8 @@ const I18N = {
|
||||
"SecretId": "SecretId",
|
||||
"SecretKey": "SecretKey",
|
||||
"Token Plan Enterprise's usage is told only to the Tencent Cloud account's API key (console → Access management → API keys), not to the plan's API key. Give its SecretId and SecretKey here for the Usage page to show it; a sub-user's key that may read TokenHub is enough. It is used for nothing else.": "Token Plan 企业版的用量只对腾讯云账号的 API 密钥开放(控制台 → 访问管理 → API 密钥管理),套餐的 API Key 查不到。在这里填入它的 SecretId 和 SecretKey,用量页就会显示;有 TokenHub 读权限的子用户密钥即可。仅用于查询用量。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it; a RAM user that may use Model Studio is enough. It is used for nothing else.": "套餐的用量只对阿里云账号的 AccessKey 开放(控制台 → AccessKey 管理),套餐的 API Key 查不到。在这里填入它的 AccessKey ID 和 Secret,用量页就会显示;有百炼使用权限的 RAM 子账号即可。仅用于查询用量。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.": "套餐的用量只对阿里云账号的 AccessKey 开放(控制台 → AccessKey 管理),套餐的 API Key 查不到。在这里填入它的 AccessKey ID 和 Secret,用量页就会显示。仅用于查询用量。",
|
||||
"A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none": "RAM 子账号的 AccessKey 需要 AliyunTokenPlanReadOnlyAccess 和 AliyunBSSReadOnlyAccess 两个系统策略,并在百炼控制台的账号管理页给它管理员或订阅套餐权限;主账号的 AccessKey 无需额外授权",
|
||||
"This plan's usage needs the account's AccessKey ID and Secret — give them in the provider's settings": "此套餐的用量需要账号的 AccessKey ID 和 Secret 才能读取,请在服务商设置里填写",
|
||||
"Open settings": "打开设置",
|
||||
"This plan's usage needs the account's SecretId and SecretKey — give them in the provider's settings": "此套餐的用量需要账号的 SecretId 和 SecretKey 才能读取,请在服务商设置里填写",
|
||||
@@ -9283,7 +9284,8 @@ const I18N = {
|
||||
"SecretId": "SecretId",
|
||||
"SecretKey": "SecretKey",
|
||||
"Token Plan Enterprise's usage is told only to the Tencent Cloud account's API key (console → Access management → API keys), not to the plan's API key. Give its SecretId and SecretKey here for the Usage page to show it; a sub-user's key that may read TokenHub is enough. It is used for nothing else.": "Token Plan 企業版的用量只對騰訊雲帳號的 API 金鑰開放(主控台 → 存取管理 → API 金鑰管理),套餐的 API Key 查不到。在這裡填入它的 SecretId 和 SecretKey,用量頁就會顯示;有 TokenHub 讀取權限的子使用者金鑰即可。僅用於查詢用量。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it; a RAM user that may use Model Studio is enough. It is used for nothing else.": "套餐的用量只對阿里雲帳號的 AccessKey 開放(主控台 → AccessKey 管理),套餐的 API Key 查不到。在這裡填入它的 AccessKey ID 和 Secret,用量頁就會顯示;有百鍊使用權限的 RAM 子帳號即可。僅用於查詢用量。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.": "套餐的用量只對阿里雲帳號的 AccessKey 開放(主控台 → AccessKey 管理),套餐的 API Key 查不到。在這裡填入它的 AccessKey ID 和 Secret,用量頁就會顯示。僅用於查詢用量。",
|
||||
"A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none": "RAM 子帳號的 AccessKey 需要 AliyunTokenPlanReadOnlyAccess 和 AliyunBSSReadOnlyAccess 兩個系統策略,並在百鍊主控台的帳號管理頁給它管理員或訂閱套餐權限;主帳號的 AccessKey 無需額外授權",
|
||||
"This plan's usage needs the account's AccessKey ID and Secret — give them in the provider's settings": "此方案的用量需要帳號的 AccessKey ID 和 Secret 才能讀取,請在服務商設定中填寫",
|
||||
"Open settings": "開啟設定",
|
||||
"This plan's usage needs the account's SecretId and SecretKey — give them in the provider's settings": "此方案的用量需要帳號的 SecretId 和 SecretKey 才能讀取,請在服務商設定中填寫",
|
||||
@@ -14628,7 +14630,8 @@ const I18N = {
|
||||
"SecretId": "SecretId",
|
||||
"SecretKey": "SecretKey",
|
||||
"Token Plan Enterprise's usage is told only to the Tencent Cloud account's API key (console → Access management → API keys), not to the plan's API key. Give its SecretId and SecretKey here for the Usage page to show it; a sub-user's key that may read TokenHub is enough. It is used for nothing else.": "Token Plan Enterprise の使用量は、Tencent Cloud アカウントの API キー(コンソール → アクセス管理 → API キー)にだけ返され、プランの API キーでは取得できません。ここに SecretId と SecretKey を入力すると使用量ページに表示されます。TokenHub を読み取れるサブユーザーのキーで十分です。それ以外には使いません。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it; a RAM user that may use Model Studio is enough. It is used for nothing else.": "プランの使用量は、Alibaba Cloud アカウントの AccessKey(コンソール → AccessKey 管理)にだけ返され、プランの API キーでは取得できません。ここに AccessKey ID と Secret を入力すると使用量ページに表示されます。Model Studio を利用できる RAM ユーザーで十分です。それ以外には使いません。",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.": "プランの使用量は、Alibaba Cloud アカウントの AccessKey(コンソール → AccessKey 管理)にだけ返され、プランの API キーでは取得できません。ここに AccessKey ID と Secret を入力すると使用量ページに表示されます。それ以外には使いません。",
|
||||
"A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none": "RAM ユーザーの AccessKey には、AliyunTokenPlanReadOnlyAccess と AliyunBSSReadOnlyAccess のシステムポリシー、および Model Studio の Account Management ページでの Administrator または Subscription plan 権限が必要です。メインアカウントの AccessKey には追加の権限は要りません",
|
||||
"This plan's usage needs the account's AccessKey ID and Secret — give them in the provider's settings": "このプランの使用量を読むにはアカウントの AccessKey ID と Secret が必要です。プロバイダの設定で入力してください",
|
||||
"Open settings": "設定を開く",
|
||||
"This plan's usage needs the account's SecretId and SecretKey — give them in the provider's settings": "このプランの使用量を読むにはアカウントの SecretId と SecretKey が必要です。プロバイダの設定で入力してください",
|
||||
@@ -19982,7 +19985,8 @@ const I18N = {
|
||||
"SecretId": "SecretId",
|
||||
"SecretKey": "SecretKey",
|
||||
"Token Plan Enterprise's usage is told only to the Tencent Cloud account's API key (console → Access management → API keys), not to the plan's API key. Give its SecretId and SecretKey here for the Usage page to show it; a sub-user's key that may read TokenHub is enough. It is used for nothing else.": "Die Nutzung des Token Plan Enterprise gibt Tencent Cloud nur dem API-Schlüssel des Kontos (Konsole → Zugriffsverwaltung → API-Schlüssel), nicht dem API-Schlüssel des Plans. Geben Sie hier dessen SecretId und SecretKey an, damit die Seite „Nutzung“ sie zeigt; der Schlüssel eines Unterbenutzers, der TokenHub lesen darf, genügt. Er wird für nichts anderes verwendet.",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it; a RAM user that may use Model Studio is enough. It is used for nothing else.": "Die Nutzung des Plans gibt Alibaba Cloud nur dem AccessKey des Kontos (Konsole → AccessKey), nicht dem API-Schlüssel des Plans. Geben Sie hier dessen AccessKey ID und Secret an, damit die Seite „Nutzung“ sie zeigt; ein RAM-Benutzer, der Model Studio nutzen darf, genügt. Er wird für nichts anderes verwendet.",
|
||||
"The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.": "Die Nutzung des Plans gibt Alibaba Cloud nur dem AccessKey des Kontos (Konsole → AccessKey), nicht dem API-Schlüssel des Plans. Geben Sie hier dessen AccessKey ID und Secret an, damit die Seite „Nutzung“ sie zeigt. Er wird für nichts anderes verwendet.",
|
||||
"A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none": "Der AccessKey eines RAM-Benutzers braucht die Systemrichtlinien AliyunTokenPlanReadOnlyAccess und AliyunBSSReadOnlyAccess und in Model Studio unter Account Management die Berechtigung Administrator oder Subscription plan; der AccessKey des Hauptkontos braucht nichts weiter",
|
||||
"This plan's usage needs the account's AccessKey ID and Secret — give them in the provider's settings": "Die Nutzung dieses Tarifs wird mit der AccessKey ID und dem Secret des Kontos gelesen – geben Sie sie in den Einstellungen des Anbieters an",
|
||||
"Open settings": "Einstellungen öffnen",
|
||||
"This plan's usage needs the account's SecretId and SecretKey — give them in the provider's settings": "Die Nutzung dieses Tarifs wird mit der SecretId und dem SecretKey des Kontos gelesen – geben Sie sie in den Einstellungen des Anbieters an",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2676,6 +2676,22 @@ node --test internal/gui/tests/tencent-access-key.test.cjs
|
||||
go test -tags nogui ./internal/gui -run TestProviderListTellsTencentAccessKey
|
||||
```
|
||||
|
||||
## Alibaba Cloud Token Plan AccessKey grants
|
||||
|
||||
`alibaba-ram-grants.test.cjs` covers MetalHqa's report on X: what an
|
||||
Alibaba Cloud Token Plan's AccessKey needs to read the plan's usage is said
|
||||
under the editor's AccessKey ID (`ALI_RAM`), in the reader's language, and
|
||||
the Secret's hint no longer says any Model Studio RAM user will do. A card
|
||||
refused with `aliRAMHint`, read from `alibaba_usage.go` itself, says the
|
||||
same grants in the reader's language with the raw refusal in its tooltip.
|
||||
Volcengine's editor has no such note. 420px with no sideways scroll; all
|
||||
five languages, Chromium and WebKit.
|
||||
|
||||
```sh
|
||||
node --test internal/gui/tests/alibaba-ram-grants.test.cjs
|
||||
go test ./internal/provider -run TestAliGatewayRAMNotAuthorised
|
||||
```
|
||||
|
||||
`plugin-kernel.test.cjs` holds the window's plugin kernel (`kernel.js`) to
|
||||
its error boundary, with the Gateway page, the first page a plugin draws
|
||||
(`assets/plugins/gateway/`). With the page's drawing made to throw, the page
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// MetalHqa on X: what an Alibaba Cloud Token Plan's AccessKey needs to read
|
||||
// the plan's usage wasn't said where the key is given. The editor said "a
|
||||
// RAM user that may use Model Studio is enough", which is wrong (#6506),
|
||||
// and the grants Alibaba's docs list (aliRAMHint) were said only in
|
||||
// English, on the card, after a refusal. Now the editor says them under
|
||||
// the AccessKey ID, in the reader's language, and a card refused with
|
||||
// aliRAMHint says them in the reader's language too, the raw error in its
|
||||
// tooltip. The refusal is read from alibaba_usage.go itself, so a change of
|
||||
// its words that quotaError no longer matches is red here. A 420px window,
|
||||
// both engines, every language.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const GRANTS = "A RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in Model Studio → Account Management; the main account's needs none";
|
||||
const HINT = "The plan's usage is told only to the Alibaba Cloud account's AccessKey (console → AccessKey), not to the plan's API key. Give its AccessKey ID and Secret here for the Usage page to show it. It is used for nothing else.";
|
||||
const plan = { chat: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", anthropic: "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic" };
|
||||
const ali = {
|
||||
id: "bailian-token-plan", name: "Bailian Token Plan", icon: "alibabacloud-color", preset: "bailian-token-plan", ...plan, responses: "", catalog: "",
|
||||
models: [{ id: "qwen3.6-plus", name: "qwen3.6-plus", on: true }], agents: [], fallback: [], headers: {},
|
||||
key: { set: true, masked: "sk-sp-…ab12" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",
|
||||
accessKey: { vendor: "alibaba", id: "LTAIsaved", secretSet: true },
|
||||
};
|
||||
const volc = {
|
||||
id: "volcengine", name: "Volcengine Ark", icon: "volcengine", preset: "volcengine", chat: "https://ark.cn-beijing.volces.com/api/coding/v3", responses: "", anthropic: "", catalog: "",
|
||||
models: [], agents: [], fallback: [], headers: {}, key: { set: true, masked: "ark-…key" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",
|
||||
accessKey: { vendor: "volcengine", id: "", secretSet: false },
|
||||
};
|
||||
|
||||
// the card's error as aliAskUsage words it on BailianGateway.Team.NotAuthorised
|
||||
async function refusal() {
|
||||
const src = await fs.readFile(path.resolve(__dirname, "../../provider/alibaba_usage.go"), "utf8");
|
||||
const hint = /\baliRAMHint\s*=\s*"((?:[^"\\]|\\.)*)"/.exec(src);
|
||||
assert.ok(hint, "aliRAMHint is in alibaba_usage.go");
|
||||
return `Alibaba Cloud's console: BailianGateway.Team.NotAuthorised: ${JSON.parse(`"${hint[1]}"`)}`;
|
||||
}
|
||||
|
||||
function serve(lang, quotas) {
|
||||
const settings = { theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd" };
|
||||
const providers = { providers: [ali, volc], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (body) => route.fulfill({ json: body });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings });
|
||||
if (url.pathname === "/api/settings") return json(settings);
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/usage/quotas") return json(quotas);
|
||||
if (url.pathname === "/api/usage/quotas/history") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
const start = async (t, view, quotas) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width: 420, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, quotas));
|
||||
await page.goto(`http://magpie.test/?view=${view}`);
|
||||
const said = lang === "en" ? [GRANTS, HINT] : await page.evaluate(([l, keys]) => keys.map((k) => I18N[l][k]), [lang, [GRANTS, HINT]]);
|
||||
return { page, errors, said };
|
||||
};
|
||||
const fits = async (page) => {
|
||||
const over = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
||||
assert(over <= 0, `the page scrolls sideways by ${over}px`);
|
||||
};
|
||||
|
||||
test(`${engine} ${lang}: the editor says what an Alibaba Token Plan's AccessKey needs, under its AccessKey ID`, async (t) => {
|
||||
const { page, errors, said: [grants, hint] } = await start(t, "providers", []);
|
||||
if (lang !== "en") {
|
||||
const missing = await page.evaluate(([l, keys]) => keys.filter((k) => !I18N[l][k]), [lang, [GRANTS, HINT]]);
|
||||
assert.deepEqual(missing, [], "said in this language");
|
||||
}
|
||||
assert.ok(grants && hint);
|
||||
await page.locator(".row.provider", { hasText: "Bailian Token Plan" }).click();
|
||||
const ak = page.locator(".editor .volc-ak");
|
||||
await ak.waitFor();
|
||||
// the note sits right under the AccessKey ID, and its input reads it
|
||||
const note = ak.locator("xpath=following-sibling::div[contains(@class,'hint')]");
|
||||
assert.equal((await note.textContent()).trim(), grants);
|
||||
assert.equal(await ak.getAttribute("aria-describedby"), await note.getAttribute("id"));
|
||||
for (const name of ["AliyunTokenPlanReadOnlyAccess", "AliyunBSSReadOnlyAccess"]) assert.ok(grants.includes(name), `${grants} names ${name}`);
|
||||
const tips = await page.locator(".editor .hint").allTextContents();
|
||||
assert.ok(tips.includes(hint), tips.join(" | "));
|
||||
assert.ok(!tips.some((x) => /Model Studio is enough|百炼使用权限|百鍊使用權限|利用できる RAM|nutzen darf/.test(x)), "the wrong 'any Model Studio RAM user' is gone");
|
||||
await fits(page);
|
||||
|
||||
// another vendor's access key has no such note
|
||||
await page.keyboard.press("Escape");
|
||||
await page.locator(".row.provider", { hasText: "Volcengine Ark" }).click();
|
||||
const vak = page.locator(".editor .volc-ak");
|
||||
await vak.waitFor();
|
||||
assert.equal(await vak.locator("xpath=following-sibling::div[contains(@class,'hint')]").count(), 0);
|
||||
assert.ok(!(await page.locator(".editor").textContent()).includes("AliyunTokenPlan"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: a card refused for a RAM user's grants says them in the reader's language`, async (t) => {
|
||||
const raw = await refusal();
|
||||
const quotas = [
|
||||
{ provider: "bailian-token-plan", name: "Bailian Token Plan", icon: "alibabacloud-color", plan: "Token Plan", error: raw, windows: [] },
|
||||
];
|
||||
const { page, errors, said: [grants] } = await start(t, "usage", quotas);
|
||||
const err = page.locator(".subscription-card", { hasText: "Bailian Token Plan" }).locator(".subscription-error");
|
||||
await err.waitFor();
|
||||
assert.equal(await err.getAttribute("title"), raw, "the raw refusal in the tooltip");
|
||||
assert.ok((await err.textContent()).includes(grants), await err.textContent());
|
||||
if (lang !== "en") assert.ok(!(await err.textContent()).includes("from the main account"), "not the English refusal");
|
||||
await fits(page);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ const (
|
||||
// two system policies the Bailian and ModelStudio ones don't include,
|
||||
// and a permission given in Model Studio's own console. Without the
|
||||
// last the console answers BailianGateway.Team.NotAuthorised (#6506).
|
||||
aliRAMHint = "a RAM user's AccessKey needs, from the main account: the AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess system policies in the RAM console (AliyunBailian* and AliyunModelStudio* policies don't cover the Token Plan), and the Administrator or Subscribe Plan permission for this RAM user on the Account Management page of the Model Studio (Bailian) console. Or use the main account's own AccessKey"
|
||||
aliRAMHint = "a RAM user's AccessKey needs, from the main account: the AliyunTokenPlanReadOnlyAccess and AliyunBSSReadOnlyAccess system policies in the RAM console (AliyunBailian* and AliyunModelStudio* policies don't cover the Token Plan), and the Administrator or Subscription plan permission for this RAM user on the Account Management page of the Model Studio (Bailian) console. Or use the main account's own AccessKey"
|
||||
// aliTokenTTL is how long a console token is kept before a new one is
|
||||
// made; one the console refuses is made again at once
|
||||
aliTokenTTL = 20 * time.Minute
|
||||
|
||||
@@ -213,7 +213,7 @@ func TestAliGatewayRAMNotAuthorised(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("no error")
|
||||
}
|
||||
for _, want := range []string{"BailianGateway.Team.NotAuthorised", "AliyunTokenPlanReadOnlyAccess", "AliyunBSSReadOnlyAccess", "Account Management", "Administrator or Subscribe Plan", "main account's own AccessKey"} {
|
||||
for _, want := range []string{"BailianGateway.Team.NotAuthorised", "AliyunTokenPlanReadOnlyAccess", "AliyunBSSReadOnlyAccess", "Account Management", "Administrator or Subscription plan", "main account's own AccessKey"} {
|
||||
if !strings.Contains(err.Error(), want) {
|
||||
t.Errorf("%q doesn't say %q", err, want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user