@xixka/dsh-hub 0.2.1-rc.21 → 0.2.1-rc.23

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.
@@ -3870,16 +3870,17 @@ function allModelsDisabled(models) {
3870
3870
  }
3871
3871
 
3872
3872
  // plugin-src/client/new-account.js
3873
- var PROVIDERS_ASKING_OPTIONS = Object.freeze(["zcode", "accio", "astudio", "autoclaw", "autoclawintl"]);
3873
+ var PROVIDERS_ASKING_OPTIONS = Object.freeze(["zcode", "accio", "astudio", "autoclaw", "autoclawintl", "loomy"]);
3874
3874
  function newAccountAsksChannel(provider) {
3875
3875
  return PROVIDERS_ASKING_OPTIONS.includes(provider);
3876
3876
  }
3877
- function buildCreateAccountPayload(provider, zcodeProvider, accioRegion, astudioLoginMethod, autoclawMode) {
3878
- if (provider !== "zcode" && provider !== "accio" && provider !== "astudio" && provider !== "autoclaw" && provider !== "autoclawintl") {
3877
+ function buildCreateAccountPayload(provider, zcodeProvider, accioRegion, astudioLoginMethod, autoclawMode, loomyLoginMethod) {
3878
+ if (provider !== "zcode" && provider !== "accio" && provider !== "astudio" && provider !== "autoclaw" && provider !== "autoclawintl" && provider !== "loomy") {
3879
3879
  return { provider };
3880
3880
  }
3881
3881
  if (provider === "zcode") return { provider, zcodeProvider };
3882
3882
  if (provider === "accio") return { provider, accioRegion };
3883
+ if (provider === "loomy") return { provider, loomyLoginMethod: loomyLoginMethod ?? "wechat" };
3883
3884
  if (provider === "astudio") return { provider, astudioLoginMethod: astudioLoginMethod ?? "local" };
3884
3885
  return { provider, autoclawMode: autoclawMode ?? "local" };
3885
3886
  }
@@ -8689,6 +8690,7 @@ function ProviderPanel({ provider, rpcCall }) {
8689
8690
  const [accioRegion, setAccioRegion] = React5.useState("cn");
8690
8691
  const [astudioLoginMethod, setAstudioLoginMethod] = React5.useState("local");
8691
8692
  const [autoclawMode, setAutoclawMode] = React5.useState("local");
8693
+ const [loomyLoginMethod, setLoomyLoginMethod] = React5.useState("wechat");
8692
8694
  const [pendingLogin, setPendingLogin] = React5.useState(void 0);
8693
8695
  const [probeBusy, setProbeBusy] = React5.useState(null);
8694
8696
  const [probeNotice, setProbeNoticeState] = React5.useState(null);
@@ -8747,6 +8749,7 @@ function ProviderPanel({ provider, rpcCall }) {
8747
8749
  const accioDialog = provider === "accio";
8748
8750
  const astudioDialog = provider === "astudio";
8749
8751
  const autoclawDialog = provider === "autoclaw" || provider === "autoclawintl";
8752
+ const loomyDialog = provider === "loomy";
8750
8753
  const autoclawSmsAvailable = provider === "autoclaw";
8751
8754
  const supportsCredits = supportsDailyCheckin(provider);
8752
8755
  const supportsGrowthTasks = GROWTH_TASK_PROVIDERS.has(provider);
@@ -9159,7 +9162,7 @@ function ProviderPanel({ provider, rpcCall }) {
9159
9162
  "account.create",
9160
9163
  // ⚠ 两个 provider 各占一个位置参数(astudio 第 4 位、autoclaw 第 5 位),
9161
9164
  // 不可合并成一个 —— 载荷字段不同,合并会静默串台(见 new-account.js)。
9162
- buildCreateAccountPayload(provider, zcodeProvider, accioRegion, astudioLoginMethod, autoclawMode)
9165
+ buildCreateAccountPayload(provider, zcodeProvider, accioRegion, astudioLoginMethod, autoclawMode, loomyLoginMethod)
9163
9166
  );
9164
9167
  accountId = res.accountId;
9165
9168
  loginUrl = res.loginUrl;
@@ -9848,14 +9851,14 @@ function ProviderPanel({ provider, rpcCall }) {
9848
9851
  { className: "dim-jh-zcDialogTitle" },
9849
9852
  // ⚠ 弹窗服务四个 provider(zcode / accio / astudio / autoclaw),
9850
9853
  // 各问各的东西:渠道 / 区域 / AStudio 登录方式 / AutoClaw 登录方式。
9851
- astudioDialog ? "添加 AStudio 账号" : autoclawDialog ? "添加 AutoClaw 账号" : accioDialog ? "添加 Accio 账号" : "添加 ZCode 账号"
9854
+ astudioDialog ? "添加 AStudio 账号" : autoclawDialog ? "添加 AutoClaw 账号" : loomyDialog ? "添加 Loomy 账号" : accioDialog ? "添加 Accio 账号" : "添加 ZCode 账号"
9852
9855
  ),
9853
9856
  React5.createElement(
9854
9857
  "p",
9855
9858
  { className: "dim-jh-zcDialogHint" },
9856
- astudioDialog ? "支持导入本机桌面端已登录会话,或在浏览器中打开三合一登录页(支持手机短信/账号密码/微信扫码)。" : autoclawDialog ? "请选择登录方式:可直接读取本机已安装并登录的桌面端凭据,或使用手机短信验证码快速登录。" : accioDialog ? "Accio 的登录页按区域分域名,且区域由服务端按账号下发 —— 登录前无法自动判断。请选择该账号所属的区域,否则会打开打不开的登录页。" : "选择登录渠道后才会打开对应的认证页面。两个渠道的授权页与凭据各自独立,"
9859
+ astudioDialog ? "支持导入本机桌面端已登录会话,或在浏览器中打开三合一登录页(支持手机短信/账号密码/微信扫码)。" : autoclawDialog ? "请选择登录方式:可直接读取本机已安装并登录的桌面端凭据,或使用手机短信验证码快速登录。" : loomyDialog ? "请选择登录方式:短信验证码 / 账号密码(密码方式会在凭据临期时自动续期),或微信扫码。" : accioDialog ? "Accio 的登录页按区域分域名,且区域由服务端按账号下发 —— 登录前无法自动判断。请选择该账号所属的区域,否则会打开打不开的登录页。" : "选择登录渠道后才会打开对应的认证页面。两个渠道的授权页与凭据各自独立,"
9857
9860
  ),
9858
- accioDialog || astudioDialog || autoclawDialog ? null : React5.createElement(
9861
+ accioDialog || astudioDialog || autoclawDialog || loomyDialog ? null : React5.createElement(
9859
9862
  "p",
9860
9863
  { className: "dim-jh-zcDialogHint" },
9861
9864
  "可用 z.ai(国际)登录另一个账号。"
@@ -9863,7 +9866,7 @@ function ProviderPanel({ provider, rpcCall }) {
9863
9866
  React5.createElement(
9864
9867
  "label",
9865
9868
  { className: "dim-jh-zcProvider" },
9866
- astudioDialog ? "登录方式" : autoclawDialog ? "登录方式" : accioDialog ? "登录区域" : "登录渠道"
9869
+ astudioDialog ? "登录方式" : autoclawDialog ? "登录方式" : loomyDialog ? "登录方式" : accioDialog ? "登录区域" : "登录渠道"
9867
9870
  // ⚠️⚠️ **原生 `<select>` 已整体删除**(2026-10-17 审计 P2 修复,
9868
9871
  // 本次合并 astudio 侧时一并采纳 —— astudio 侧原本还留着第四个死 select)。
9869
9872
  // 原先此处有**四个**各自带 `style:{display:'none'}` 的 `<select>`
@@ -9950,6 +9953,112 @@ function ProviderPanel({ provider, rpcCall }) {
9950
9953
  }, opt.desc)
9951
9954
  )
9952
9955
  );
9956
+ }) : loomyDialog ? [
9957
+ { value: "sms", label: "📱 短信验证码 / 账号密码登录", desc: "免装桌面端;密码 Tab 登录的账号支持凭据临期自动续期" },
9958
+ { value: "wechat", label: "💬 微信扫码登录", desc: "扫码 + 首次绑手机号;到期需重新扫码(无密码不可自动续期)" }
9959
+ ].map((opt) => {
9960
+ const active = loomyLoginMethod === opt.value;
9961
+ return React5.createElement(
9962
+ "div",
9963
+ {
9964
+ key: opt.value,
9965
+ onClick: () => setLoomyLoginMethod(opt.value),
9966
+ style: {
9967
+ display: "flex",
9968
+ alignItems: "center",
9969
+ gap: "10px",
9970
+ padding: "10px 14px",
9971
+ borderRadius: "6px",
9972
+ border: active ? "1.5px solid var(--dsw-alias-primary, #0284c7)" : "1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.25))",
9973
+ background: active ? "var(--dsw-alias-primary-tint, rgba(2, 132, 199, 0.1))" : "var(--dsw-alias-bg-layer-2, transparent)",
9974
+ cursor: "pointer",
9975
+ transition: "all 0.15s ease",
9976
+ userSelect: "none"
9977
+ }
9978
+ },
9979
+ React5.createElement("div", {
9980
+ style: {
9981
+ width: "14px",
9982
+ height: "14px",
9983
+ borderRadius: "50%",
9984
+ border: active ? "4px solid var(--dsw-alias-primary, #0284c7)" : "1.5px solid var(--dsw-alias-border-l2, #8b949e)",
9985
+ boxSizing: "border-box",
9986
+ flexShrink: 0,
9987
+ background: active ? "#fff" : "transparent"
9988
+ }
9989
+ }),
9990
+ React5.createElement(
9991
+ "div",
9992
+ { style: { display: "flex", flexDirection: "column" } },
9993
+ React5.createElement("span", {
9994
+ style: {
9995
+ fontSize: "13px",
9996
+ fontWeight: active ? 600 : 400,
9997
+ color: "var(--dsw-alias-label-primary, inherit)"
9998
+ }
9999
+ }, opt.label),
10000
+ React5.createElement("span", {
10001
+ style: {
10002
+ fontSize: "11px",
10003
+ color: "var(--dsw-alias-label-tertiary, #888)",
10004
+ marginTop: "2px"
10005
+ }
10006
+ }, opt.desc)
10007
+ )
10008
+ );
10009
+ }) : loomyDialog ? [
10010
+ { value: "sms", label: "📱 短信验证码 / 账号密码登录", desc: "免装桌面端;密码 Tab 登录的账号支持凭据临期自动续期" },
10011
+ { value: "wechat", label: "💬 微信扫码登录", desc: "扫码 + 首次绑手机号;到期需重新扫码(无密码不可自动续期)" }
10012
+ ].map((opt) => {
10013
+ const active = loomyLoginMethod === opt.value;
10014
+ return React5.createElement(
10015
+ "div",
10016
+ {
10017
+ key: opt.value,
10018
+ onClick: () => setLoomyLoginMethod(opt.value),
10019
+ style: {
10020
+ display: "flex",
10021
+ alignItems: "center",
10022
+ gap: "10px",
10023
+ padding: "10px 14px",
10024
+ borderRadius: "6px",
10025
+ border: active ? "1.5px solid var(--dsw-alias-primary, #0284c7)" : "1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.25))",
10026
+ background: active ? "var(--dsw-alias-primary-tint, rgba(2, 132, 199, 0.1))" : "var(--dsw-alias-bg-layer-2, transparent)",
10027
+ cursor: "pointer",
10028
+ transition: "all 0.15s ease",
10029
+ userSelect: "none"
10030
+ }
10031
+ },
10032
+ React5.createElement("div", {
10033
+ style: {
10034
+ width: "14px",
10035
+ height: "14px",
10036
+ borderRadius: "50%",
10037
+ border: active ? "4px solid var(--dsw-alias-primary, #0284c7)" : "1.5px solid var(--dsw-alias-border-l2, #8b949e)",
10038
+ boxSizing: "border-box",
10039
+ flexShrink: 0,
10040
+ background: active ? "#fff" : "transparent"
10041
+ }
10042
+ }),
10043
+ React5.createElement(
10044
+ "div",
10045
+ { style: { display: "flex", flexDirection: "column" } },
10046
+ React5.createElement("span", {
10047
+ style: {
10048
+ fontSize: "13px",
10049
+ fontWeight: active ? 600 : 400,
10050
+ color: "var(--dsw-alias-label-primary, inherit)"
10051
+ }
10052
+ }, opt.label),
10053
+ React5.createElement("span", {
10054
+ style: {
10055
+ fontSize: "11px",
10056
+ color: "var(--dsw-alias-label-tertiary, #888)",
10057
+ marginTop: "2px"
10058
+ }
10059
+ }, opt.desc)
10060
+ )
10061
+ );
9953
10062
  }) : accioDialog ? [
9954
10063
  { value: "cn", label: "🇨🇳 中国版(www.accio-ai.com)", desc: "适用于 Accio 国内站点账号" },
9955
10064
  { value: "global", label: "🌐 国际版(zh.accio.com)", desc: "适用于 Accio 国际站点账号" }
@@ -3460,6 +3460,50 @@ function registerJetHubEndpoints(ctx, pool, auths, modelAdapters) {
3460
3460
  return { ok: true, value: { accountId: id, loginUrl: started.loginUrl } };
3461
3461
  }
3462
3462
  else if (provider === LOOMY.id) {
3463
+ // ⚠ **登录方式**(2026-11-01):前端弹窗可选 `'sms'`(短信验证码 /
3464
+ // 密码直登)或缺省 `'wechat'`(微信扫码)。缺省维持既有行为
3465
+ // (微信扫码),老前端不带该字段时逐字节不变。
3466
+ const loomyLoginMethod = payload?.loomyLoginMethod;
3467
+ if (loomyLoginMethod === 'sms') {
3468
+ // 独立短信流(`loomy-sms-login.ts`):本地表单页收集手机号 /
3469
+ // 验证码 / 密码(选填)—— 不要求 `account.create` 预先携带手机号
3470
+ //(那正是早期「顺序死锁」缺陷的成因)。占位条目先行,成功后回填。
3471
+ await pool.addAccount({
3472
+ id,
3473
+ provider: LOOMY.id,
3474
+ nickname: id,
3475
+ enabled: true,
3476
+ credentialRef: refName,
3477
+ refreshable: false,
3478
+ createdAt: Date.now(),
3479
+ });
3480
+ let smsFlow;
3481
+ try {
3482
+ smsFlow = await loomy.startSmsLogin();
3483
+ }
3484
+ catch (error) {
3485
+ void pool.removeAccount(id).catch(() => { });
3486
+ const reason = error instanceof Error ? error.message : String(error);
3487
+ throw new Error(`无法启动 Loomy 短信登录:${reason}`);
3488
+ }
3489
+ smsFlow.result.then(async (outcome) => {
3490
+ const result = await loomy.persistSmsLogin(outcome, { refName });
3491
+ const credential = JSON.parse(result.access);
3492
+ await pool.updateAccount(id, {
3493
+ // 用手机号尾号让多账号可区分(与微信流回填同口径)。
3494
+ nickname: credential.phone.length >= 4 ? `Loomy ${credential.phone.slice(-4)}` : id,
3495
+ expiresAt: result.expires > 0 ? result.expires : undefined,
3496
+ // ⚠ 恒 false:Loomy 无续期端点(自动续期走凭据里的密码,
3497
+ // 与池的 refreshable 标记是两回事,见 isLoomyAutoRefreshable)。
3498
+ refreshable: false,
3499
+ });
3500
+ }).catch((error) => {
3501
+ ctx.logger.warn(`[jet-hub] background ${LOOMY.id} sms login failed for ${id}: ${String(error)}`);
3502
+ // 登录失败不删占位条目:验证码输错可重试(与 login.submitSms 同口径)。
3503
+ void failLogin(id, error);
3504
+ });
3505
+ return { ok: true, value: { accountId: id, loginUrl: smsFlow.loginUrl } };
3506
+ }
3463
3507
  // Loomy 走**微信扫码**登录(与其余 provider 同为「两步式」):
3464
3508
  // 起本地服务器承载弹窗页(内联二维码 + 轮询 + 首次绑手机号表单),
3465
3509
  // 立即返回 `loginUrl` 让前端 `window.open`。