opencode-copilot-account-switcher 0.14.26 → 0.14.27
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/dist/providers/codex-menu-adapter.js +1 -1
- package/dist/providers/copilot-menu-adapter.js +1 -1
- package/dist/wechat/bind-flow.js +2 -1
- package/dist/wechat/compat/jiti-loader.d.ts +11 -0
- package/dist/wechat/compat/jiti-loader.js +27 -0
- package/dist/wechat/compat/openclaw-account-helpers.js +2 -2
- package/dist/wechat/compat/openclaw-public-entry.js +2 -2
- package/dist/wechat/compat/openclaw-sync-buf.js +2 -2
- package/dist/wechat/compat/openclaw-updates-send.js +2 -2
- package/dist/wechat/compat/qrcode-terminal-loader.d.ts +12 -0
- package/dist/wechat/compat/qrcode-terminal-loader.js +16 -0
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ import { recoverInvalidCodexAccount } from "../codex-invalid-account.js";
|
|
|
7
7
|
import { readAuth } from "../store.js";
|
|
8
8
|
import { readCommonSettingsStore, writeCommonSettingsStore, } from "../common-settings-store.js";
|
|
9
9
|
import { applyCommonSettingsAction } from "../common-settings-actions.js";
|
|
10
|
-
import { runWechatBindFlow } from "../wechat/bind-flow.js";
|
|
11
10
|
function pickName(input) {
|
|
12
11
|
const accountId = input.accountId?.trim();
|
|
13
12
|
if (accountId)
|
|
@@ -384,6 +383,7 @@ export function createCodexMenuAdapter(inputDeps) {
|
|
|
384
383
|
return false;
|
|
385
384
|
}
|
|
386
385
|
if (action.name === "wechat-bind" || action.name === "wechat-rebind") {
|
|
386
|
+
const { runWechatBindFlow } = await import("../wechat/bind-flow.js");
|
|
387
387
|
await runWechatBindFlow({
|
|
388
388
|
action: action.name,
|
|
389
389
|
readCommonSettings,
|
|
@@ -5,7 +5,6 @@ import { getGitHubToken, normalizeDomain } from "../copilot-api-helpers.js";
|
|
|
5
5
|
import { listAssignableAccountsForModel, listKnownCopilotModels, rewriteModelAccountAssignments, } from "../model-account-map.js";
|
|
6
6
|
import { applyMenuAction, persistAccountSwitch } from "../plugin-actions.js";
|
|
7
7
|
import { readCommonSettingsStore, writeCommonSettingsStore, } from "../common-settings-store.js";
|
|
8
|
-
import { runWechatBindFlow } from "../wechat/bind-flow.js";
|
|
9
8
|
import { select, selectMany } from "../ui/select.js";
|
|
10
9
|
import { authPath, readAuth, readStore } from "../store.js";
|
|
11
10
|
const CLIENT_ID = "Ov23li8tweQw6odWQebz";
|
|
@@ -742,6 +741,7 @@ export function createCopilotMenuAdapter(inputDeps) {
|
|
|
742
741
|
return false;
|
|
743
742
|
}
|
|
744
743
|
if (action.name === "wechat-bind" || action.name === "wechat-rebind") {
|
|
744
|
+
const { runWechatBindFlow } = await import("../wechat/bind-flow.js");
|
|
745
745
|
await runWechatBindFlow({
|
|
746
746
|
action: action.name,
|
|
747
747
|
readCommonSettings,
|
package/dist/wechat/bind-flow.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { bindOperator, readOperatorBinding, rebindOperator, resetOperatorBinding } from "./operator-store.js";
|
|
2
2
|
import { loadOpenClawWeixinPublicHelpers } from "./compat/openclaw-public-helpers.js";
|
|
3
3
|
import { buildOpenClawMenuAccount } from "./openclaw-account-adapter.js";
|
|
4
|
+
import { loadQrCodeTerminal } from "./compat/qrcode-terminal-loader.js";
|
|
4
5
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
5
|
-
import qrcodeTerminal from "qrcode-terminal";
|
|
6
6
|
const DEFAULT_QR_WAIT_TIMEOUT_MS = 480000;
|
|
7
7
|
function pickFirstNonEmptyString(...values) {
|
|
8
8
|
for (const value of values) {
|
|
@@ -41,6 +41,7 @@ function isSameOperatorBinding(left, right) {
|
|
|
41
41
|
return left.wechatAccountId === right.wechatAccountId && left.userId === right.userId && left.boundAt === right.boundAt;
|
|
42
42
|
}
|
|
43
43
|
async function renderQrTerminalDefault(input) {
|
|
44
|
+
const qrcodeTerminal = loadQrCodeTerminal();
|
|
44
45
|
return await new Promise((resolve) => {
|
|
45
46
|
qrcodeTerminal.generate(input.value, { small: true }, (output) => {
|
|
46
47
|
resolve(typeof output === "string" && output.trim().length > 0 ? output : undefined);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type JitiLoader = (path: string) => unknown;
|
|
2
|
+
type CreateJiti = (id: string | URL, options?: Record<string, unknown>) => JitiLoader;
|
|
3
|
+
type JitiNamespace = {
|
|
4
|
+
createJiti?: unknown;
|
|
5
|
+
default?: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveCreateJiti(namespace: JitiNamespace): CreateJiti;
|
|
8
|
+
export declare function loadJiti(requireImpl?: NodeRequire): {
|
|
9
|
+
createJiti: CreateJiti;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
function isCreateJiti(value) {
|
|
3
|
+
return typeof value === "function";
|
|
4
|
+
}
|
|
5
|
+
export function resolveCreateJiti(namespace) {
|
|
6
|
+
if (isCreateJiti(namespace)) {
|
|
7
|
+
return namespace;
|
|
8
|
+
}
|
|
9
|
+
if (isCreateJiti(namespace.createJiti)) {
|
|
10
|
+
return namespace.createJiti;
|
|
11
|
+
}
|
|
12
|
+
if (isCreateJiti(namespace.default)) {
|
|
13
|
+
return namespace.default;
|
|
14
|
+
}
|
|
15
|
+
if (namespace.default &&
|
|
16
|
+
typeof namespace.default === "object" &&
|
|
17
|
+
isCreateJiti(namespace.default.createJiti)) {
|
|
18
|
+
return namespace.default.createJiti;
|
|
19
|
+
}
|
|
20
|
+
throw new Error("[wechat-compat] createJiti export unavailable");
|
|
21
|
+
}
|
|
22
|
+
export function loadJiti(requireImpl = createRequire(import.meta.url)) {
|
|
23
|
+
const namespace = requireImpl("jiti");
|
|
24
|
+
return {
|
|
25
|
+
createJiti: resolveCreateJiti(namespace),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import {
|
|
2
|
+
import { loadJiti } from "./jiti-loader.js";
|
|
3
3
|
const OPENCLAW_WEIXIN_ACCOUNTS_MODULE = "@tencent-weixin/openclaw-weixin/src/auth/accounts.ts";
|
|
4
4
|
let accountJitiLoader = null;
|
|
5
5
|
function getAccountJiti() {
|
|
6
6
|
if (accountJitiLoader) {
|
|
7
7
|
return accountJitiLoader;
|
|
8
8
|
}
|
|
9
|
-
accountJitiLoader = createJiti(import.meta.url, {
|
|
9
|
+
accountJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
10
10
|
interopDefault: true,
|
|
11
11
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
12
12
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { loadJiti } from "./jiti-loader.js";
|
|
5
5
|
let publicJitiLoader = null;
|
|
6
6
|
function requireField(condition, message) {
|
|
7
7
|
if (!condition) {
|
|
@@ -12,7 +12,7 @@ function getPublicJiti() {
|
|
|
12
12
|
if (publicJitiLoader) {
|
|
13
13
|
return publicJitiLoader;
|
|
14
14
|
}
|
|
15
|
-
publicJitiLoader = createJiti(import.meta.url, {
|
|
15
|
+
publicJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
16
16
|
interopDefault: true,
|
|
17
17
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
18
18
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { loadJiti } from "./jiti-loader.js";
|
|
5
5
|
const OPENCLAW_SYNC_BUF_MODULE = "@tencent-weixin/openclaw-weixin/src/storage/sync-buf.ts";
|
|
6
6
|
const OPENCLAW_STATE_DIR_MODULE = "@tencent-weixin/openclaw-weixin/src/storage/state-dir.ts";
|
|
7
7
|
let syncBufJitiLoader = null;
|
|
@@ -9,7 +9,7 @@ function getSyncBufJiti() {
|
|
|
9
9
|
if (syncBufJitiLoader) {
|
|
10
10
|
return syncBufJitiLoader;
|
|
11
11
|
}
|
|
12
|
-
syncBufJitiLoader = createJiti(import.meta.url, {
|
|
12
|
+
syncBufJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
13
13
|
interopDefault: true,
|
|
14
14
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
15
15
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import {
|
|
2
|
+
import { loadJiti } from "./jiti-loader.js";
|
|
3
3
|
const OPENCLAW_UPDATES_MODULE = "@tencent-weixin/openclaw-weixin/src/api/api.ts";
|
|
4
4
|
const OPENCLAW_SEND_MODULE = "@tencent-weixin/openclaw-weixin/src/messaging/send.ts";
|
|
5
5
|
let updatesSendJitiLoader = null;
|
|
@@ -7,7 +7,7 @@ function getUpdatesSendJiti() {
|
|
|
7
7
|
if (updatesSendJitiLoader) {
|
|
8
8
|
return updatesSendJitiLoader;
|
|
9
9
|
}
|
|
10
|
-
updatesSendJitiLoader = createJiti(import.meta.url, {
|
|
10
|
+
updatesSendJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
11
11
|
interopDefault: true,
|
|
12
12
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
13
13
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type QrCodeTerminal = {
|
|
2
|
+
generate(input: string, opts: {
|
|
3
|
+
small?: boolean;
|
|
4
|
+
}, cb?: (output: string) => void): void;
|
|
5
|
+
};
|
|
6
|
+
type QrCodeTerminalNamespace = {
|
|
7
|
+
default?: unknown;
|
|
8
|
+
generate?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveQrCodeTerminal(namespace: QrCodeTerminalNamespace): QrCodeTerminal;
|
|
11
|
+
export declare function loadQrCodeTerminal(requireImpl?: NodeRequire): QrCodeTerminal;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
function isQrCodeTerminal(value) {
|
|
3
|
+
return Boolean(value && typeof value === "object" && typeof value.generate === "function");
|
|
4
|
+
}
|
|
5
|
+
export function resolveQrCodeTerminal(namespace) {
|
|
6
|
+
if (isQrCodeTerminal(namespace)) {
|
|
7
|
+
return namespace;
|
|
8
|
+
}
|
|
9
|
+
if (isQrCodeTerminal(namespace.default)) {
|
|
10
|
+
return namespace.default;
|
|
11
|
+
}
|
|
12
|
+
throw new Error("[wechat-compat] qrcode-terminal export unavailable");
|
|
13
|
+
}
|
|
14
|
+
export function loadQrCodeTerminal(requireImpl = createRequire(import.meta.url)) {
|
|
15
|
+
return resolveQrCodeTerminal(requireImpl("qrcode-terminal"));
|
|
16
|
+
}
|