opencode-copilot-account-switcher 0.14.36 → 0.14.37

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.
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { loadQrCodeTerminal } from "./qrcode-terminal-loader.js";
2
3
  const DEFAULT_BASE_URL = "https://ilinkai.weixin.qq.com";
3
4
  const DEFAULT_ILINK_BOT_TYPE = "3";
4
5
  const ACTIVE_LOGIN_TTL_MS = 5 * 60_000;
@@ -32,6 +33,19 @@ async function fetchQrCode(apiBaseUrl, botType) {
32
33
  }
33
34
  return await response.json();
34
35
  }
36
+ async function renderQrTerminal(value) {
37
+ const qrcodeTerminal = loadQrCodeTerminal();
38
+ return await new Promise((resolve, reject) => {
39
+ try {
40
+ qrcodeTerminal.generate(value, { small: true }, (output) => {
41
+ resolve(typeof output === "string" && output.trim().length > 0 ? output : undefined);
42
+ });
43
+ }
44
+ catch (error) {
45
+ reject(error);
46
+ }
47
+ });
48
+ }
35
49
  async function pollQrStatus(apiBaseUrl, qrcode) {
36
50
  const base = apiBaseUrl.endsWith("/") ? apiBaseUrl : `${apiBaseUrl}/`;
37
51
  const url = new URL(`ilink/bot/get_qrcode_status?qrcode=${encodeURIComponent(qrcode)}`, base);
@@ -102,6 +116,7 @@ export async function loadOpenClawWeixinBindHelpers() {
102
116
  startedAt: Date.now(),
103
117
  });
104
118
  return {
119
+ qrTerminal: await renderQrTerminal(qrResponse.qrcode_img_content).catch(() => undefined),
105
120
  qrDataUrl: qrResponse.qrcode_img_content,
106
121
  qrcodeUrl: qrResponse.qrcode_img_content,
107
122
  message: "使用微信扫描以下二维码,以完成连接。",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-account-switcher",
3
- "version": "0.14.36",
3
+ "version": "0.14.37",
4
4
  "description": "GitHub Copilot account switcher plugin for OpenCode",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",