@huaqiu/dsh-auth 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +6 -31
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +31 -1
- package/lib/index.mjs +20 -1
- package/package.json +2 -2
- package/src/client/i18n.ts +0 -4
- package/src/client/ui/turn-error-cta.tsx +11 -44
- package/src/index.ts +73 -1
package/lib/client.js
CHANGED
|
@@ -642,7 +642,6 @@ window.__ModuleLoader__.load({
|
|
|
642
642
|
"turnError.aiQuotaCta": "升级获取更多 AI 额度",
|
|
643
643
|
"turnError.aiQuotaSignIn": "登录后升级",
|
|
644
644
|
"turnError.aiQuotaOpenFailed": "无法打开订阅页面,请稍后重试。",
|
|
645
|
-
"turnError.aiCredentialSignIn": "登录以恢复 AI 服务",
|
|
646
645
|
"card.title": "华秋 EDA AI(eda.cn)登录",
|
|
647
646
|
"card.desc": "工具「{tool}」需要登录华秋 EDA AI 账号才能继续。请在下方的登录框完成登录(或点击左侧「华秋EDA AI登录」按钮);登录完成后,回复助手「已登录,请重试」,助手会自动重新调用该工具。",
|
|
648
647
|
"card.loggedIn": "✓ 已登录{nickname} —— 现在可以回复助手「已登录,请重试」,助手会重新调用工具。",
|
|
@@ -684,7 +683,6 @@ window.__ModuleLoader__.load({
|
|
|
684
683
|
"turnError.aiQuotaCta": "Upgrade for more AI tokens",
|
|
685
684
|
"turnError.aiQuotaSignIn": "Sign in to upgrade",
|
|
686
685
|
"turnError.aiQuotaOpenFailed": "Could not open the subscription page. Please try again later.",
|
|
687
|
-
"turnError.aiCredentialSignIn": "Sign in to restore AI access",
|
|
688
686
|
"card.title": "Huaqiu EDA AI (eda.cn) login",
|
|
689
687
|
"card.desc": "Tool \"{tool}\" needs a Huaqiu EDA AI account. Complete the login below (or use the Huaqiu EDA AI button in the sidebar), then reply \"I have logged in, please retry\" so the assistant can retry the tool.",
|
|
690
688
|
"card.loggedIn": "✓ Logged in{nickname} — reply \"I have logged in, please retry\" and the assistant will retry the tool.",
|
|
@@ -2398,11 +2396,10 @@ window.__ModuleLoader__.load({
|
|
|
2398
2396
|
* auth client (`openSubscriptionDialog`), which is the same path the sidebar
|
|
2399
2397
|
* upgrade entry uses.
|
|
2400
2398
|
*
|
|
2401
|
-
* A
|
|
2402
|
-
*
|
|
2403
|
-
*
|
|
2404
|
-
*
|
|
2405
|
-
* (never the subscription dialog), even when the host session is authenticated.
|
|
2399
|
+
* A `huaqiu` `MISSING_CREDENTIAL` failure is handled on the backend by the
|
|
2400
|
+
* `agent/request-error` hook (which opens the native login dialog for a live
|
|
2401
|
+
* failure), so this entry deliberately renders nothing for it — a historical
|
|
2402
|
+
* error card must not reopen the dialog.
|
|
2406
2403
|
*
|
|
2407
2404
|
* Fallbacks stay inside the card: no host dialog service → the existing
|
|
2408
2405
|
* "host provides no dialog service" copy; transport failure → retry copy; no
|
|
@@ -2413,8 +2410,6 @@ window.__ModuleLoader__.load({
|
|
|
2413
2410
|
const QUOTA_PROVIDER = "huaqiu";
|
|
2414
2411
|
/** The gateway's own code for a token balance that can be topped up. */
|
|
2415
2412
|
const HUAQIU_QUOTA_SIGNATURE = "insufficient_user_quota";
|
|
2416
|
-
/** The harness code for a provider whose credential reference did not resolve. */
|
|
2417
|
-
const HUAQIU_MISSING_CREDENTIAL = "MISSING_CREDENTIAL";
|
|
2418
2413
|
/**
|
|
2419
2414
|
* Whether a durable failure is the huaqiu gateway's exhausted token balance.
|
|
2420
2415
|
*
|
|
@@ -2434,19 +2429,6 @@ window.__ModuleLoader__.load({
|
|
|
2434
2429
|
if (node.providerErrorCode === HUAQIU_QUOTA_SIGNATURE) return true;
|
|
2435
2430
|
return node.provider === QUOTA_PROVIDER && node.code === "QUOTA";
|
|
2436
2431
|
}
|
|
2437
|
-
/**
|
|
2438
|
-
* Whether a durable failure is huaqiu's unresolved API credential.
|
|
2439
|
-
*
|
|
2440
|
-
* `MISSING_CREDENTIAL` is a generic harness code (DeepSeek and other providers
|
|
2441
|
-
* raise it too), so the provider must match exactly. On this path the failure
|
|
2442
|
-
* carries no `providerErrorCode` and the message text is explicitly ignored —
|
|
2443
|
-
* gating on either would misroute other providers' credential failures.
|
|
2444
|
-
* @param node - durable turn-error node, possibly absent at runtime boundaries.
|
|
2445
|
-
* @returns true only for the huaqiu missing-credential signature.
|
|
2446
|
-
*/
|
|
2447
|
-
function isHuaqiuMissingCredentialFailure(node) {
|
|
2448
|
-
return node != null && node.code === HUAQIU_MISSING_CREDENTIAL && node.provider === QUOTA_PROVIDER;
|
|
2449
|
-
}
|
|
2450
2432
|
const ctaStyle = {
|
|
2451
2433
|
display: "block",
|
|
2452
2434
|
width: "fit-content",
|
|
@@ -2486,7 +2468,6 @@ window.__ModuleLoader__.load({
|
|
|
2486
2468
|
const nodeKey = node.message;
|
|
2487
2469
|
const visibleNotice = notice !== null && notice.key === nodeKey ? notice.text : null;
|
|
2488
2470
|
const isQuotaFailure = isHuaqiuQuotaFailure(node);
|
|
2489
|
-
const isMissingCredential = isHuaqiuMissingCredentialFailure(node);
|
|
2490
2471
|
const open = (0, react.useCallback)(() => {
|
|
2491
2472
|
if (busy) return;
|
|
2492
2473
|
const fail = () => {
|
|
@@ -2509,11 +2490,6 @@ window.__ModuleLoader__.load({
|
|
|
2509
2490
|
fail();
|
|
2510
2491
|
}
|
|
2511
2492
|
};
|
|
2512
|
-
if (isMissingCredential) {
|
|
2513
|
-
setNotice(null);
|
|
2514
|
-
requestLogin();
|
|
2515
|
-
return;
|
|
2516
|
-
}
|
|
2517
2493
|
if (!authState.authenticated) {
|
|
2518
2494
|
requestLogin();
|
|
2519
2495
|
return;
|
|
@@ -2532,13 +2508,12 @@ window.__ModuleLoader__.load({
|
|
|
2532
2508
|
authState.authenticated,
|
|
2533
2509
|
busy,
|
|
2534
2510
|
dark,
|
|
2535
|
-
isMissingCredential,
|
|
2536
2511
|
locale,
|
|
2537
2512
|
nodeKey,
|
|
2538
2513
|
t
|
|
2539
2514
|
]);
|
|
2540
|
-
if (!isQuotaFailure
|
|
2541
|
-
const label =
|
|
2515
|
+
if (!isQuotaFailure) return null;
|
|
2516
|
+
const label = busy ? t("subscription.subscribing") : authState.authenticated ? t("turnError.aiQuotaCta") : t("turnError.aiQuotaSignIn");
|
|
2542
2517
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2543
2518
|
type: "button",
|
|
2544
2519
|
style: {
|