opencode-copilot-account-switcher 0.14.30 → 0.14.32
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/wechat/compat/jiti-loader.d.ts +5 -2
- package/dist/wechat/compat/jiti-loader.js +8 -2
- package/dist/wechat/compat/openclaw-account-helpers.js +3 -3
- package/dist/wechat/compat/openclaw-public-entry.js +3 -3
- package/dist/wechat/compat/openclaw-sync-buf.js +5 -5
- package/dist/wechat/compat/openclaw-updates-send.js +5 -4
- package/package.json +1 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export type JitiLoader = (path: string) => unknown;
|
|
2
2
|
type CreateJiti = (id: string | URL, options?: Record<string, unknown>) => JitiLoader;
|
|
3
|
+
type JitiImport = (specifier: string) => Promise<unknown> | unknown;
|
|
4
|
+
type JitiResolve = (specifier: string) => string;
|
|
3
5
|
type JitiNamespace = {
|
|
4
6
|
createJiti?: unknown;
|
|
5
7
|
default?: unknown;
|
|
6
8
|
};
|
|
7
9
|
export declare function resolveCreateJiti(namespace: JitiNamespace): CreateJiti;
|
|
8
|
-
export declare function
|
|
10
|
+
export declare function resolveJitiEsmEntry(resolveImpl?: JitiResolve): string;
|
|
11
|
+
export declare function loadJiti(importImpl?: JitiImport, resolveImpl?: JitiResolve): Promise<{
|
|
9
12
|
createJiti: CreateJiti;
|
|
10
|
-
}
|
|
13
|
+
}>;
|
|
11
14
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
2
4
|
function isCreateJiti(value) {
|
|
3
5
|
return typeof value === "function";
|
|
4
6
|
}
|
|
@@ -19,8 +21,12 @@ export function resolveCreateJiti(namespace) {
|
|
|
19
21
|
}
|
|
20
22
|
throw new Error("[wechat-compat] createJiti export unavailable");
|
|
21
23
|
}
|
|
22
|
-
export function
|
|
23
|
-
const
|
|
24
|
+
export function resolveJitiEsmEntry(resolveImpl = createRequire(import.meta.url).resolve) {
|
|
25
|
+
const packageJsonPath = resolveImpl("jiti/package.json");
|
|
26
|
+
return pathToFileURL(path.join(path.dirname(packageJsonPath), "lib", "jiti.mjs")).href;
|
|
27
|
+
}
|
|
28
|
+
export async function loadJiti(importImpl = (specifier) => import(specifier), resolveImpl = createRequire(import.meta.url).resolve) {
|
|
29
|
+
const namespace = await Promise.resolve(importImpl(resolveJitiEsmEntry(resolveImpl)));
|
|
24
30
|
return {
|
|
25
31
|
createJiti: resolveCreateJiti(namespace),
|
|
26
32
|
};
|
|
@@ -2,11 +2,11 @@ import { createRequire } from "node:module";
|
|
|
2
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
|
-
function getAccountJiti() {
|
|
5
|
+
async function getAccountJiti() {
|
|
6
6
|
if (accountJitiLoader) {
|
|
7
7
|
return accountJitiLoader;
|
|
8
8
|
}
|
|
9
|
-
accountJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
9
|
+
accountJitiLoader = (await loadJiti()).createJiti(import.meta.url, {
|
|
10
10
|
interopDefault: true,
|
|
11
11
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
12
12
|
});
|
|
@@ -52,7 +52,7 @@ export function createOpenClawAccountHelpers(input) {
|
|
|
52
52
|
export async function loadOpenClawAccountHelpers(options = {}) {
|
|
53
53
|
const require = createRequire(import.meta.url);
|
|
54
54
|
const accountsModulePath = require.resolve(options.accountsModulePath ?? OPENCLAW_WEIXIN_ACCOUNTS_MODULE);
|
|
55
|
-
const accountsModule = getAccountJiti()(accountsModulePath);
|
|
55
|
+
const accountsModule = (await getAccountJiti())(accountsModulePath);
|
|
56
56
|
if (typeof accountsModule.listIndexedWeixinAccountIds !== "function" || typeof accountsModule.loadWeixinAccount !== "function") {
|
|
57
57
|
throw new Error("[wechat-compat] account source helper unavailable");
|
|
58
58
|
}
|
|
@@ -8,11 +8,11 @@ function requireField(condition, message) {
|
|
|
8
8
|
throw new Error(`[wechat-compat] ${message}`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
function getPublicJiti() {
|
|
11
|
+
async function getPublicJiti() {
|
|
12
12
|
if (publicJitiLoader) {
|
|
13
13
|
return publicJitiLoader;
|
|
14
14
|
}
|
|
15
|
-
publicJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
15
|
+
publicJitiLoader = (await loadJiti()).createJiti(import.meta.url, {
|
|
16
16
|
interopDefault: true,
|
|
17
17
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
18
18
|
});
|
|
@@ -42,7 +42,7 @@ export async function resolveOpenClawWeixinPublicEntry() {
|
|
|
42
42
|
}
|
|
43
43
|
export async function loadOpenClawWeixinDefaultExport() {
|
|
44
44
|
const entry = await resolveOpenClawWeixinPublicEntry();
|
|
45
|
-
const moduleNamespace = getPublicJiti()(entry.entryAbsolutePath);
|
|
45
|
+
const moduleNamespace = (await getPublicJiti())(entry.entryAbsolutePath);
|
|
46
46
|
const plugin = moduleNamespace.default;
|
|
47
47
|
if (!plugin || typeof plugin !== "object" || typeof plugin.register !== "function") {
|
|
48
48
|
throw new Error("[wechat-compat] @tencent-weixin/openclaw-weixin public entry default export is missing register(api)");
|
|
@@ -5,11 +5,11 @@ 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;
|
|
8
|
-
function getSyncBufJiti() {
|
|
8
|
+
async function getSyncBufJiti() {
|
|
9
9
|
if (syncBufJitiLoader) {
|
|
10
10
|
return syncBufJitiLoader;
|
|
11
11
|
}
|
|
12
|
-
syncBufJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
12
|
+
syncBufJitiLoader = (await loadJiti()).createJiti(import.meta.url, {
|
|
13
13
|
interopDefault: true,
|
|
14
14
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
15
15
|
});
|
|
@@ -29,7 +29,7 @@ export function createOpenClawSyncBufHelper(input) {
|
|
|
29
29
|
export async function loadOpenClawSyncBufHelper(options = {}) {
|
|
30
30
|
const require = createRequire(import.meta.url);
|
|
31
31
|
const syncBufModulePath = require.resolve(options.syncBufModulePath ?? OPENCLAW_SYNC_BUF_MODULE);
|
|
32
|
-
const syncBufModule = getSyncBufJiti()(syncBufModulePath);
|
|
32
|
+
const syncBufModule = (await getSyncBufJiti())(syncBufModulePath);
|
|
33
33
|
if (typeof syncBufModule.getSyncBufFilePath !== "function" || typeof syncBufModule.saveGetUpdatesBuf !== "function") {
|
|
34
34
|
throw new Error("[wechat-compat] sync-buf source helper unavailable");
|
|
35
35
|
}
|
|
@@ -41,7 +41,7 @@ export async function loadOpenClawSyncBufHelper(options = {}) {
|
|
|
41
41
|
export async function loadLatestWeixinAccountState(options = {}) {
|
|
42
42
|
const require = createRequire(import.meta.url);
|
|
43
43
|
const stateDirModulePath = require.resolve(options.stateDirModulePath ?? OPENCLAW_STATE_DIR_MODULE);
|
|
44
|
-
const stateDirModule = getSyncBufJiti()(stateDirModulePath);
|
|
44
|
+
const stateDirModule = (await getSyncBufJiti())(stateDirModulePath);
|
|
45
45
|
const stateDir = stateDirModule.resolveStateDir?.();
|
|
46
46
|
if (!stateDir) {
|
|
47
47
|
return null;
|
|
@@ -67,7 +67,7 @@ export async function loadLatestWeixinAccountState(options = {}) {
|
|
|
67
67
|
const accountRaw = await readFile(accountFilePath, "utf8");
|
|
68
68
|
const account = JSON.parse(accountRaw);
|
|
69
69
|
const syncBufModulePath = require.resolve(options.syncBufModulePath ?? OPENCLAW_SYNC_BUF_MODULE);
|
|
70
|
-
const syncBufModule = getSyncBufJiti()(syncBufModulePath);
|
|
70
|
+
const syncBufModule = (await getSyncBufJiti())(syncBufModulePath);
|
|
71
71
|
if (typeof account.token !== "string" || account.token.trim().length === 0) {
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
@@ -3,11 +3,11 @@ 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;
|
|
6
|
-
function getUpdatesSendJiti() {
|
|
6
|
+
async function getUpdatesSendJiti() {
|
|
7
7
|
if (updatesSendJitiLoader) {
|
|
8
8
|
return updatesSendJitiLoader;
|
|
9
9
|
}
|
|
10
|
-
updatesSendJitiLoader = loadJiti().createJiti(import.meta.url, {
|
|
10
|
+
updatesSendJitiLoader = (await loadJiti()).createJiti(import.meta.url, {
|
|
11
11
|
interopDefault: true,
|
|
12
12
|
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
|
|
13
13
|
});
|
|
@@ -34,8 +34,9 @@ export async function loadOpenClawUpdatesAndSendHelpers(options = {}) {
|
|
|
34
34
|
const require = createRequire(import.meta.url);
|
|
35
35
|
const getUpdatesModulePath = require.resolve(options.getUpdatesModulePath ?? OPENCLAW_UPDATES_MODULE);
|
|
36
36
|
const sendModulePath = require.resolve(options.sendMessageWeixinModulePath ?? OPENCLAW_SEND_MODULE);
|
|
37
|
-
const
|
|
38
|
-
const
|
|
37
|
+
const jiti = await getUpdatesSendJiti();
|
|
38
|
+
const getUpdatesModule = jiti(getUpdatesModulePath);
|
|
39
|
+
const sendModule = jiti(sendModulePath);
|
|
39
40
|
if (typeof getUpdatesModule.getUpdates !== "function") {
|
|
40
41
|
throw new Error("public getUpdates helper unavailable");
|
|
41
42
|
}
|