openclaw-plugin-yuanbao 2.12.0 → 2.13.0
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/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/setup-entry.d.ts +1 -1
- package/dist/src/business/commands/log-upload/extractor.js +1 -1
- package/dist/src/business/commands/upgrade/env.js +1 -1
- package/dist/src/business/commands/upgrade/upgrade.js +11 -1
- package/dist/src/business/commands/upgrade/utils.d.ts +2 -1
- package/dist/src/business/commands/upgrade/utils.js +52 -3
- package/dist/src/channel-shared.d.ts +3 -2
- package/dist/src/channel-shared.js +2 -1
- package/dist/src/infra/env.js +22 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +9 -12
- package/api.ts +0 -16
- package/index.ts +0 -83
- package/runtime-api.ts +0 -9
- package/setup-entry.ts +0 -9
- package/src/access/api.ts +0 -22
- package/src/access/http/bot-id-cache.ts +0 -30
- package/src/access/http/main.ts +0 -59
- package/src/access/http/request.ts +0 -415
- package/src/access/ws/biz-codec.ts +0 -506
- package/src/access/ws/client.ts +0 -978
- package/src/access/ws/conn-codec.ts +0 -226
- package/src/access/ws/gateway.ts +0 -444
- package/src/access/ws/index.ts +0 -77
- package/src/access/ws/proto/biz/get_group_member_list.proto +0 -29
- package/src/access/ws/proto/biz/inbound_message.proto +0 -44
- package/src/access/ws/proto/biz/msg_body.proto +0 -54
- package/src/access/ws/proto/biz/openclaw_proxy_svr.proto +0 -29
- package/src/access/ws/proto/biz/query_group_info.proto +0 -30
- package/src/access/ws/proto/biz/send_c2c_message.proto +0 -33
- package/src/access/ws/proto/biz/send_group_heartbeat.proto +0 -27
- package/src/access/ws/proto/biz/send_group_message.proto +0 -33
- package/src/access/ws/proto/biz/send_private_heartbeat.proto +0 -30
- package/src/access/ws/proto/biz.json +0 -552
- package/src/access/ws/proto/conn.json +0 -391
- package/src/access/ws/proto/conn.proto +0 -176
- package/src/access/ws/runtime.ts +0 -35
- package/src/access/ws/types.ts +0 -202
- package/src/accounts.ts +0 -183
- package/src/business/actions/deliver.ts +0 -58
- package/src/business/actions/handler.ts +0 -181
- package/src/business/actions/index.ts +0 -46
- package/src/business/actions/media/send.ts +0 -64
- package/src/business/actions/resolve-target.ts +0 -115
- package/src/business/actions/sticker/builtin-stickers.json +0 -542
- package/src/business/actions/sticker/init-builtin-stickers.ts +0 -31
- package/src/business/actions/sticker/send.ts +0 -93
- package/src/business/actions/sticker/sticker-cache.ts +0 -344
- package/src/business/actions/sticker/sticker-types.ts +0 -35
- package/src/business/actions/text/send.ts +0 -38
- package/src/business/commands/command-sync/index.ts +0 -118
- package/src/business/commands/log-upload/cos-upload.ts +0 -181
- package/src/business/commands/log-upload/extractor.ts +0 -307
- package/src/business/commands/log-upload/index.ts +0 -33
- package/src/business/commands/log-upload/perform.ts +0 -212
- package/src/business/commands/log-upload/types.ts +0 -49
- package/src/business/commands/upgrade/env.ts +0 -64
- package/src/business/commands/upgrade/index.ts +0 -62
- package/src/business/commands/upgrade/upgrade.ts +0 -414
- package/src/business/commands/upgrade/utils.ts +0 -267
- package/src/business/inbound/index.ts +0 -67
- package/src/business/messaging/callbacks/recall.ts +0 -127
- package/src/business/messaging/chat-history.test.ts +0 -61
- package/src/business/messaging/chat-history.ts +0 -50
- package/src/business/messaging/context.ts +0 -27
- package/src/business/messaging/directory.ts +0 -152
- package/src/business/messaging/extract.test.ts +0 -82
- package/src/business/messaging/extract.ts +0 -51
- package/src/business/messaging/handlers/custom/index.ts +0 -120
- package/src/business/messaging/handlers/custom/link-card.ts +0 -109
- package/src/business/messaging/handlers/custom.test.ts +0 -99
- package/src/business/messaging/handlers/custom.ts +0 -6
- package/src/business/messaging/handlers/face.test.ts +0 -72
- package/src/business/messaging/handlers/face.ts +0 -56
- package/src/business/messaging/handlers/file.ts +0 -50
- package/src/business/messaging/handlers/image.test.ts +0 -67
- package/src/business/messaging/handlers/image.ts +0 -58
- package/src/business/messaging/handlers/index.test.ts +0 -89
- package/src/business/messaging/handlers/index.ts +0 -176
- package/src/business/messaging/handlers/sound.ts +0 -25
- package/src/business/messaging/handlers/text.test.ts +0 -59
- package/src/business/messaging/handlers/text.ts +0 -36
- package/src/business/messaging/handlers/types.ts +0 -113
- package/src/business/messaging/handlers/video.ts +0 -48
- package/src/business/messaging/index.ts +0 -30
- package/src/business/messaging/mention.ts +0 -134
- package/src/business/messaging/quote.test.ts +0 -85
- package/src/business/messaging/quote.ts +0 -81
- package/src/business/messaging/system-callbacks.ts +0 -58
- package/src/business/messaging/targets.test.ts +0 -56
- package/src/business/messaging/targets.ts +0 -93
- package/src/business/outbound/create-sender.ts +0 -93
- package/src/business/outbound/heartbeat.ts +0 -184
- package/src/business/outbound/index.ts +0 -8
- package/src/business/outbound/queue.ts +0 -341
- package/src/business/outbound/types.ts +0 -52
- package/src/business/pipeline/create.ts +0 -54
- package/src/business/pipeline/engine.test.ts +0 -217
- package/src/business/pipeline/engine.ts +0 -75
- package/src/business/pipeline/index.ts +0 -9
- package/src/business/pipeline/middlewares/build-context.test.ts +0 -156
- package/src/business/pipeline/middlewares/build-context.ts +0 -125
- package/src/business/pipeline/middlewares/dispatch-reply.test.ts +0 -245
- package/src/business/pipeline/middlewares/dispatch-reply.ts +0 -271
- package/src/business/pipeline/middlewares/download-media.test.ts +0 -139
- package/src/business/pipeline/middlewares/download-media.ts +0 -94
- package/src/business/pipeline/middlewares/extract-content.test.ts +0 -125
- package/src/business/pipeline/middlewares/extract-content.ts +0 -57
- package/src/business/pipeline/middlewares/guard-command.test.ts +0 -156
- package/src/business/pipeline/middlewares/guard-command.ts +0 -44
- package/src/business/pipeline/middlewares/guard-group-command.test.ts +0 -144
- package/src/business/pipeline/middlewares/guard-group-command.ts +0 -54
- package/src/business/pipeline/middlewares/guard-send-access.test.ts +0 -97
- package/src/business/pipeline/middlewares/guard-send-access.ts +0 -137
- package/src/business/pipeline/middlewares/guard-special-command.test.ts +0 -183
- package/src/business/pipeline/middlewares/guard-special-command.ts +0 -125
- package/src/business/pipeline/middlewares/index.ts +0 -21
- package/src/business/pipeline/middlewares/prepare-sender.test.ts +0 -151
- package/src/business/pipeline/middlewares/prepare-sender.ts +0 -50
- package/src/business/pipeline/middlewares/record-member.test.ts +0 -80
- package/src/business/pipeline/middlewares/record-member.ts +0 -20
- package/src/business/pipeline/middlewares/resolve-mention.test.ts +0 -149
- package/src/business/pipeline/middlewares/resolve-mention.ts +0 -80
- package/src/business/pipeline/middlewares/resolve-quote.test.ts +0 -67
- package/src/business/pipeline/middlewares/resolve-quote.ts +0 -21
- package/src/business/pipeline/middlewares/resolve-route.test.ts +0 -107
- package/src/business/pipeline/middlewares/resolve-route.ts +0 -37
- package/src/business/pipeline/middlewares/resolve-trace.ts +0 -25
- package/src/business/pipeline/middlewares/rewrite-body.test.ts +0 -142
- package/src/business/pipeline/middlewares/rewrite-body.ts +0 -68
- package/src/business/pipeline/middlewares/skip-placeholder.test.ts +0 -134
- package/src/business/pipeline/middlewares/skip-placeholder.ts +0 -58
- package/src/business/pipeline/middlewares/skip-self.test.ts +0 -44
- package/src/business/pipeline/middlewares/skip-self.ts +0 -16
- package/src/business/pipeline/test-helpers/mock-ctx.ts +0 -125
- package/src/business/pipeline/types.ts +0 -108
- package/src/business/tools/group.ts +0 -89
- package/src/business/tools/index.ts +0 -32
- package/src/business/tools/member.ts +0 -199
- package/src/business/tools/remind.ts +0 -396
- package/src/business/trace/context.ts +0 -116
- package/src/business/utils/markdown.ts +0 -491
- package/src/business/utils/media.ts +0 -598
- package/src/business/utils/utils.test.ts +0 -51
- package/src/business/utils/utils.ts +0 -96
- package/src/channel-shared.ts +0 -126
- package/src/channel.setup.ts +0 -31
- package/src/channel.ts +0 -212
- package/src/config-schema.ts +0 -125
- package/src/dispatcher/debouncer/index.ts +0 -283
- package/src/dispatcher/queue/session-abort-manager.ts +0 -49
- package/src/dispatcher/queue/session-queue.ts +0 -69
- package/src/infra/cache/member.ts +0 -478
- package/src/infra/cache/ttl-db.test.ts +0 -71
- package/src/infra/cache/ttl-db.ts +0 -93
- package/src/infra/env.ts +0 -58
- package/src/infra/transport.ts +0 -160
- package/src/logger.ts +0 -238
- package/src/runtime.ts +0 -11
- package/src/setup-core.ts +0 -82
- package/src/setup-surface.ts +0 -150
- package/src/types.ts +0 -219
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk
|
|
1
|
+
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk").ChannelPlugin>;
|
|
2
2
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineBundledChannelEntry, loadBundledEntryExportSync, } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
2
|
+
import { YUANBAO_PLUGIN_ID } from "./src/channel-shared.js";
|
|
2
3
|
function registerTools(api) {
|
|
3
4
|
const register = loadBundledEntryExportSync(import.meta.url, {
|
|
4
5
|
specifier: "./api.js",
|
|
@@ -36,7 +37,7 @@ function initLogger(api) {
|
|
|
36
37
|
init(api);
|
|
37
38
|
}
|
|
38
39
|
export default defineBundledChannelEntry({
|
|
39
|
-
id:
|
|
40
|
+
id: YUANBAO_PLUGIN_ID,
|
|
40
41
|
name: "YuanBao",
|
|
41
42
|
description: "YuanBao channel plugin",
|
|
42
43
|
importMetaUrl: import.meta.url,
|
package/dist/setup-entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk
|
|
1
|
+
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk").ChannelPlugin>;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
-
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/
|
|
2
|
+
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/run-command";
|
|
3
3
|
import { createLog } from "../../../logger.js";
|
|
4
4
|
import { getYuanbaoRuntime } from "../../../runtime.js";
|
|
5
5
|
const EXEC_TIMEOUT_MS = 10_000;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
|
-
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/
|
|
2
|
+
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/run-command";
|
|
3
3
|
export function makeEnv() {
|
|
4
4
|
const nodeBinDir = dirname(process.execPath);
|
|
5
5
|
const currentPath = process.env.PATH ?? "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLog } from "../../../logger.js";
|
|
2
|
-
import { getLatestStableVersion, isPublishedVersionOnNpm, isValidVersion, PLUGIN_ID, readInstalledVersion, runOpenClawCommand, runOpenClawCommandWithRetry, snapshotYuanbaoChannelConfig, } from "./utils.js";
|
|
2
|
+
import { checkTargetVersionHostCompatibility, getLatestStableVersion, isPublishedVersionOnNpm, isValidVersion, PLUGIN_ID, readInstalledVersion, runOpenClawCommand, runOpenClawCommandWithRetry, snapshotYuanbaoChannelConfig, } from "./utils.js";
|
|
3
3
|
const log = createLog("upgrade");
|
|
4
4
|
const INSTALL_SCRIPT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5
5
|
var MessageEnum;
|
|
@@ -153,6 +153,12 @@ async function runRegularUpgradeFlow(params) {
|
|
|
153
153
|
if (!latestStableVersion) {
|
|
154
154
|
log.warn("未获取到 npm 最新正式版本,将直接执行 update");
|
|
155
155
|
}
|
|
156
|
+
if (latestStableVersion) {
|
|
157
|
+
const hostCheckError = await checkTargetVersionHostCompatibility(latestStableVersion);
|
|
158
|
+
if (hostCheckError) {
|
|
159
|
+
return { ok: false, message: hostCheckError };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
156
162
|
await onProgress?.(currentVersion && latestStableVersion
|
|
157
163
|
? `🔄 正在将**元宝 Bot 插件**从 **v${currentVersion}** 升级至 **v${latestStableVersion}** ,请稍等片刻。`
|
|
158
164
|
: "⏳ 正在将**元宝 Bot 插件**升级至最新版本,请稍等片刻。");
|
|
@@ -207,6 +213,10 @@ export async function performUpgrade(config, accountId, onProgress, targetVersio
|
|
|
207
213
|
log.error("指定版本在 npm 不存在,升级流程中止", { targetVersion });
|
|
208
214
|
return `❌ 指定版本 \`${targetVersion}\` 不存在或暂不可用,请确认版本号后重试。`;
|
|
209
215
|
}
|
|
216
|
+
const hostCheckError = await checkTargetVersionHostCompatibility(requestedVersion);
|
|
217
|
+
if (hostCheckError) {
|
|
218
|
+
return hostCheckError;
|
|
219
|
+
}
|
|
210
220
|
}
|
|
211
221
|
const currentVersion = await readInstalledVersion(PLUGIN_ID);
|
|
212
222
|
log.info("读取当前版本", {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
|
|
2
|
-
export declare const PLUGIN_ID
|
|
2
|
+
export declare const PLUGIN_ID: "openclaw-plugin-yuanbao";
|
|
3
3
|
export declare function isValidVersion(version: string): boolean;
|
|
4
4
|
export declare function getLatestStableVersion(): Promise<string | null>;
|
|
5
5
|
export declare function isPublishedVersionOnNpm(version: string): Promise<boolean>;
|
|
6
6
|
export declare function readInstalledVersion(pluginId: string): Promise<string | null>;
|
|
7
7
|
export declare function snapshotYuanbaoChannelConfig(config: OpenClawConfig): string | null;
|
|
8
|
+
export declare function checkTargetVersionHostCompatibility(targetVersion: string): Promise<string | null>;
|
|
8
9
|
export declare function runOpenClawCommand(args: string[], timeoutMs?: number): Promise<{
|
|
9
10
|
ok: boolean;
|
|
10
11
|
stdout?: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { runPluginCommandWithTimeout } from "openclaw/plugin-sdk/run-command";
|
|
3
|
+
import { YUANBAO_PLUGIN_ID } from "../../../channel-shared.js";
|
|
4
|
+
import { getOpenclawVersion } from "../../../infra/env.js";
|
|
2
5
|
import { createLog } from "../../../logger.js";
|
|
3
6
|
import { makeEnv, nodeExecPath, resolveNpmBin, resolveOpenClawBin } from "./env.js";
|
|
4
7
|
const log = createLog("upgrade");
|
|
5
|
-
export const PLUGIN_ID =
|
|
8
|
+
export const PLUGIN_ID = YUANBAO_PLUGIN_ID;
|
|
6
9
|
const EXEC_TIMEOUT_MS = 3 * 60 * 1000;
|
|
7
10
|
const PLUGIN_CMD_RETRY_MAX_ATTEMPTS = 5;
|
|
8
11
|
const PLUGIN_CMD_RETRY_DELAY_MS = 3000;
|
|
@@ -18,7 +21,7 @@ export function isValidVersion(version) {
|
|
|
18
21
|
return /^\d+\.\d+\.\d+(-[\w.]+)?$/.test(version);
|
|
19
22
|
}
|
|
20
23
|
function sleep(ms) {
|
|
21
|
-
return new Promise(
|
|
24
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
22
25
|
}
|
|
23
26
|
export async function getLatestStableVersion() {
|
|
24
27
|
const npmBin = await resolveNpmBin();
|
|
@@ -145,6 +148,52 @@ function firstLine(e) {
|
|
|
145
148
|
}
|
|
146
149
|
return String(e).split("\n")[0];
|
|
147
150
|
}
|
|
151
|
+
export async function checkTargetVersionHostCompatibility(targetVersion) {
|
|
152
|
+
const hostVersion = getOpenclawVersion();
|
|
153
|
+
if (!hostVersion) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const npmBin = await resolveNpmBin();
|
|
157
|
+
try {
|
|
158
|
+
const result = await runPluginCommandWithTimeout({
|
|
159
|
+
argv: [
|
|
160
|
+
npmBin,
|
|
161
|
+
"view",
|
|
162
|
+
`${PLUGIN_ID}@${targetVersion}`,
|
|
163
|
+
"openclaw.install.minHostVersion",
|
|
164
|
+
],
|
|
165
|
+
timeoutMs: 15_000,
|
|
166
|
+
env: makeEnv(),
|
|
167
|
+
});
|
|
168
|
+
if (result.code !== 0) {
|
|
169
|
+
log.warn("Failed to query target version minHostVersion from npm", {
|
|
170
|
+
targetVersion,
|
|
171
|
+
stderr: result.stderr.trim(),
|
|
172
|
+
});
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
const constraint = result.stdout.trim();
|
|
176
|
+
if (!constraint) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
if (!semver.satisfies(hostVersion, constraint)) {
|
|
180
|
+
log.warn("Target version requires newer OpenClaw host", {
|
|
181
|
+
targetVersion,
|
|
182
|
+
constraint,
|
|
183
|
+
hostVersion,
|
|
184
|
+
});
|
|
185
|
+
return (`❌ 目标版本 v${targetVersion} 要求 OpenClaw ${constraint},`
|
|
186
|
+
+ `但当前版本为 ${hostVersion}。请先升级 OpenClaw 后再更新插件。`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
log.warn("Failed to check target version host compatibility", {
|
|
191
|
+
targetVersion,
|
|
192
|
+
error: firstLine(e),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
148
197
|
export async function runOpenClawCommand(args, timeoutMs = EXEC_TIMEOUT_MS) {
|
|
149
198
|
const openclawBin = await resolveOpenClawBin();
|
|
150
199
|
const argv = [openclawBin, ...args];
|
|
@@ -3,9 +3,10 @@ import { yuanbaoConfigSchema } from "./config-schema.js";
|
|
|
3
3
|
import { yuanbaoSetupAdapter } from "./setup-core.js";
|
|
4
4
|
import { yuanbaoSetupWizard } from "./setup-surface.js";
|
|
5
5
|
import type { ResolvedYuanbaoAccount } from "./types.js";
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const YUANBAO_PLUGIN_ID: "openclaw-plugin-yuanbao";
|
|
7
|
+
export declare const YUANBAO_CHANNEL_ID: "yuanbao";
|
|
7
8
|
export declare const yuanbaoMeta: {
|
|
8
|
-
readonly id: "
|
|
9
|
+
readonly id: "yuanbao";
|
|
9
10
|
readonly label: "Yuanbao";
|
|
10
11
|
readonly selectionLabel: "Yuanbao (腾讯元宝)";
|
|
11
12
|
readonly detailLabel: "Yuanbao";
|
|
@@ -3,7 +3,8 @@ import { listYuanbaoAccountIds, resolveDefaultYuanbaoAccountId, resolveYuanbaoAc
|
|
|
3
3
|
import { yuanbaoConfigSchema } from "./config-schema.js";
|
|
4
4
|
import { yuanbaoSetupAdapter } from "./setup-core.js";
|
|
5
5
|
import { yuanbaoSetupWizard } from "./setup-surface.js";
|
|
6
|
-
export const
|
|
6
|
+
export const YUANBAO_PLUGIN_ID = "openclaw-plugin-yuanbao";
|
|
7
|
+
export const YUANBAO_CHANNEL_ID = "yuanbao";
|
|
7
8
|
export const yuanbaoMeta = {
|
|
8
9
|
id: YUANBAO_CHANNEL_ID,
|
|
9
10
|
label: "Yuanbao",
|
package/dist/src/infra/env.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
2
|
import os from "os";
|
|
3
|
+
import semver from "semver";
|
|
3
4
|
let _pluginVersion = "";
|
|
4
5
|
let _openclawVersion = "";
|
|
5
6
|
export const getPluginVersion = () => _pluginVersion;
|
|
6
7
|
export const getOpenclawVersion = () => _openclawVersion;
|
|
7
8
|
export const getOperationSystem = () => os.type();
|
|
9
|
+
const getMinHostVersion = () => {
|
|
10
|
+
try {
|
|
11
|
+
const _require = createRequire(import.meta.url);
|
|
12
|
+
const pkg = _require("../../../package.json");
|
|
13
|
+
return pkg?.openclaw?.install?.minHostVersion;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const assertHostVersionCompatible = (hostVersion) => {
|
|
20
|
+
const constraint = getMinHostVersion();
|
|
21
|
+
if (!constraint)
|
|
22
|
+
return;
|
|
23
|
+
if (!semver.satisfies(hostVersion, constraint)) {
|
|
24
|
+
throw new Error(`openclaw-plugin-yuanbao requires openclaw ${constraint}, but current version is ${hostVersion}. Please upgrade openclaw first.`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
8
27
|
export const initEnv = (api) => {
|
|
9
28
|
_pluginVersion = api?.version || "";
|
|
10
29
|
_openclawVersion = api?.config?.meta?.lastTouchedVersion || "";
|
|
11
30
|
if (!_pluginVersion || !_openclawVersion) {
|
|
12
31
|
legacyInitEnv();
|
|
13
32
|
}
|
|
33
|
+
if (_openclawVersion) {
|
|
34
|
+
assertHostVersionCompatible(_openclawVersion);
|
|
35
|
+
}
|
|
14
36
|
};
|
|
15
37
|
const legacyInitEnv = () => {
|
|
16
38
|
try {
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-plugin-yuanbao",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Tencent YuanBao intelligent bot channel plugin",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "./index.
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"src",
|
|
11
|
-
"index.ts",
|
|
12
|
-
"api.ts",
|
|
13
|
-
"runtime-api.ts",
|
|
14
|
-
"setup-entry.ts",
|
|
15
10
|
"openclaw.plugin.json",
|
|
16
11
|
"README.md"
|
|
17
12
|
],
|
|
@@ -25,11 +20,11 @@
|
|
|
25
20
|
"author": "Tencent YuanBao Team",
|
|
26
21
|
"openclaw": {
|
|
27
22
|
"extensions": [
|
|
28
|
-
"./index.
|
|
23
|
+
"./dist/index.js"
|
|
29
24
|
],
|
|
30
|
-
"setupEntry": "./setup-entry.
|
|
25
|
+
"setupEntry": "./dist/setup-entry.js",
|
|
31
26
|
"channel": {
|
|
32
|
-
"id": "
|
|
27
|
+
"id": "yuanbao",
|
|
33
28
|
"label": "Yuanbao",
|
|
34
29
|
"selectionLabel": "Yuanbao (元宝)",
|
|
35
30
|
"detailLabel": "Yuanbao",
|
|
@@ -52,7 +47,7 @@
|
|
|
52
47
|
"npmSpec": "openclaw-plugin-yuanbao",
|
|
53
48
|
"localPath": "extensions/yuanbao",
|
|
54
49
|
"defaultChoice": "npm",
|
|
55
|
-
"minHostVersion": ">=2026.4.
|
|
50
|
+
"minHostVersion": ">=2026.4.5"
|
|
56
51
|
}
|
|
57
52
|
},
|
|
58
53
|
"private": false,
|
|
@@ -67,6 +62,7 @@
|
|
|
67
62
|
"@semantic-release/npm": "^13.1.5",
|
|
68
63
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
69
64
|
"@types/node": "^20.19.37",
|
|
65
|
+
"@types/semver": "^7.7.1",
|
|
70
66
|
"@types/ws": "^8.18.1",
|
|
71
67
|
"semantic-release": "^25.0.3",
|
|
72
68
|
"typescript": "^5.0.0"
|
|
@@ -74,6 +70,7 @@
|
|
|
74
70
|
"dependencies": {
|
|
75
71
|
"cos-nodejs-sdk-v5": "^2.15.4",
|
|
76
72
|
"protobufjs": "^8.0.0",
|
|
73
|
+
"semver": "^7.7.4",
|
|
77
74
|
"uuid": "^13.0.0",
|
|
78
75
|
"ws": "^8.19.0"
|
|
79
76
|
},
|
|
@@ -83,7 +80,7 @@
|
|
|
83
80
|
"yauzl": ">=3.2.1"
|
|
84
81
|
},
|
|
85
82
|
"peerDependencies": {
|
|
86
|
-
"openclaw": ">=2026.4.
|
|
83
|
+
"openclaw": ">=2026.4.5"
|
|
87
84
|
},
|
|
88
85
|
"scripts": {
|
|
89
86
|
"build": "tsc",
|
package/api.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Aggregated export file
|
|
3
|
-
* 供 index.ts 通过 loadBundledEntryExportSync 懒加载引用
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { yuanbaoPlugin } from "./src/channel.js";
|
|
7
|
-
export { yuanbaoSetupPlugin } from "./src/channel.setup.js";
|
|
8
|
-
export { initLogger } from "./src/logger.js";
|
|
9
|
-
export { initEnv } from "./src/infra/env.js";
|
|
10
|
-
export { registerTools } from "./src/business/tools/index.js";
|
|
11
|
-
export {
|
|
12
|
-
yuanbaoUpgradeCommand,
|
|
13
|
-
yuanbaobotUpgradeCommand,
|
|
14
|
-
} from "./src/business/commands/upgrade/index.js";
|
|
15
|
-
export { logUploadCommandDefinition } from "./src/business/commands/log-upload/index.js";
|
|
16
|
-
export { initBuiltinStickers } from "./src/business/actions/sticker/init-builtin-stickers.js";
|
package/index.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineBundledChannelEntry,
|
|
3
|
-
loadBundledEntryExportSync,
|
|
4
|
-
} from "openclaw/plugin-sdk/channel-entry-contract";
|
|
5
|
-
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
6
|
-
|
|
7
|
-
/** 懒加载注册工具 */
|
|
8
|
-
function registerTools(api: OpenClawPluginApi) {
|
|
9
|
-
const register = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>(import.meta.url, {
|
|
10
|
-
specifier: "./api.js",
|
|
11
|
-
exportName: "registerTools",
|
|
12
|
-
});
|
|
13
|
-
register(api);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Lazy-load and register all slash commands */
|
|
17
|
-
function registerCommands(api: OpenClawPluginApi) {
|
|
18
|
-
const yuanbaoUpgradeCommand = loadBundledEntryExportSync<Parameters<OpenClawPluginApi["registerCommand"]>[0]>(
|
|
19
|
-
import.meta.url,
|
|
20
|
-
{ specifier: "./api.js", exportName: "yuanbaoUpgradeCommand" },
|
|
21
|
-
);
|
|
22
|
-
const yuanbaobotUpgradeCommand = loadBundledEntryExportSync<Parameters<OpenClawPluginApi["registerCommand"]>[0]>(
|
|
23
|
-
import.meta.url,
|
|
24
|
-
{ specifier: "./api.js", exportName: "yuanbaobotUpgradeCommand" },
|
|
25
|
-
);
|
|
26
|
-
const logUploadCommandDefinition = loadBundledEntryExportSync<Parameters<OpenClawPluginApi["registerCommand"]>[0]>(
|
|
27
|
-
import.meta.url,
|
|
28
|
-
{ specifier: "./api.js", exportName: "logUploadCommandDefinition" },
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
api.registerCommand(yuanbaoUpgradeCommand);
|
|
32
|
-
api.registerCommand(yuanbaobotUpgradeCommand);
|
|
33
|
-
api.registerCommand(logUploadCommandDefinition);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** 懒加载初始化内置表情缓存 */
|
|
37
|
-
function initBuiltinStickers() {
|
|
38
|
-
const init = loadBundledEntryExportSync<() => void>(import.meta.url, {
|
|
39
|
-
specifier: "./api.js",
|
|
40
|
-
exportName: "initBuiltinStickers",
|
|
41
|
-
});
|
|
42
|
-
init();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** 懒加载初始化环境变量 */
|
|
46
|
-
function initEnv(api: OpenClawPluginApi) {
|
|
47
|
-
const init = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>(import.meta.url, {
|
|
48
|
-
specifier: "./api.js",
|
|
49
|
-
exportName: "initEnv",
|
|
50
|
-
});
|
|
51
|
-
init(api);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** 懒加载初始化日志 */
|
|
55
|
-
function initLogger(api: OpenClawPluginApi) {
|
|
56
|
-
const init = loadBundledEntryExportSync<(api: OpenClawPluginApi) => void>(import.meta.url, {
|
|
57
|
-
specifier: "./api.js",
|
|
58
|
-
exportName: "initLogger",
|
|
59
|
-
});
|
|
60
|
-
init(api);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default defineBundledChannelEntry({
|
|
64
|
-
id: "openclaw-plugin-yuanbao",
|
|
65
|
-
name: "YuanBao",
|
|
66
|
-
description: "YuanBao channel plugin",
|
|
67
|
-
importMetaUrl: import.meta.url,
|
|
68
|
-
plugin: {
|
|
69
|
-
specifier: "./api.js",
|
|
70
|
-
exportName: "yuanbaoPlugin",
|
|
71
|
-
},
|
|
72
|
-
runtime: {
|
|
73
|
-
specifier: "./runtime-api.js",
|
|
74
|
-
exportName: "setYuanbaoRuntime",
|
|
75
|
-
},
|
|
76
|
-
registerFull(api) {
|
|
77
|
-
initEnv(api);
|
|
78
|
-
initLogger(api);
|
|
79
|
-
registerTools(api);
|
|
80
|
-
registerCommands(api);
|
|
81
|
-
initBuiltinStickers();
|
|
82
|
-
},
|
|
83
|
-
});
|
package/runtime-api.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type { ChannelPlugin, OpenClawPluginApi, PluginRuntime } from "openclaw/plugin-sdk/core";
|
|
2
|
-
export type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
|
3
|
-
export type {
|
|
4
|
-
OpenClawPluginService,
|
|
5
|
-
OpenClawPluginServiceContext,
|
|
6
|
-
PluginLogger,
|
|
7
|
-
} from "openclaw/plugin-sdk/core";
|
|
8
|
-
export type { ResolvedYuanbaoAccount } from "./src/types.js";
|
|
9
|
-
export { getYuanbaoRuntime, setYuanbaoRuntime } from "./src/runtime.js";
|
package/setup-entry.ts
DELETED
package/src/access/api.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yuanbao API client.
|
|
3
|
-
*
|
|
4
|
-
* Backward-compatible re-export entry point.
|
|
5
|
-
* Implementation split into:
|
|
6
|
-
* - http/request.ts — Types, token cache, signing, auth headers, HTTP utilities
|
|
7
|
-
* - http/main.ts — Business APIs (uploadInfo / downloadUrl)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export type { SignTokenData, AuthHeaders, CosUploadConfig, Log } from "./http/request.js";
|
|
11
|
-
export {
|
|
12
|
-
clearSignTokenCache,
|
|
13
|
-
clearAllSignTokenCache,
|
|
14
|
-
getTokenStatus,
|
|
15
|
-
verifySignature,
|
|
16
|
-
getSignToken,
|
|
17
|
-
forceRefreshSignToken,
|
|
18
|
-
getAuthHeaders,
|
|
19
|
-
yuanbaoPost,
|
|
20
|
-
yuanbaoGet,
|
|
21
|
-
} from "./http/request.js";
|
|
22
|
-
export { apiGetUploadInfo, apiGetDownloadUrl } from "./http/main.js";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight botId cache shared between the HTTP sign-token client and
|
|
3
|
-
* account resolution.
|
|
4
|
-
*
|
|
5
|
-
* Kept in its own module (rather than inlined in `request.ts`) so that
|
|
6
|
-
* `accounts.ts` — which is on the `openclaw setup` / `openclaw configure`
|
|
7
|
-
* code path — can look up a previously-resolved botId without statically
|
|
8
|
-
* pulling in the full HTTP/crypto/env runtime stack.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const botIdCache = new Map<string, string>();
|
|
12
|
-
|
|
13
|
-
/** Read the last-known botId for an account, if any. */
|
|
14
|
-
export function getCachedBotId(accountId: string): string | undefined {
|
|
15
|
-
const value = botIdCache.get(accountId);
|
|
16
|
-
return value && value.length > 0 ? value : undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Record a botId obtained during sign-token exchange. */
|
|
20
|
-
export function setCachedBotId(accountId: string, botId: string | undefined): void {
|
|
21
|
-
if (!accountId || !botId) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
botIdCache.set(accountId, botId);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Clear the cached botId (e.g. when tearing down an account). */
|
|
28
|
-
export function clearCachedBotId(accountId: string): void {
|
|
29
|
-
botIdCache.delete(accountId);
|
|
30
|
-
}
|
package/src/access/http/main.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yuanbao business API.
|
|
3
|
-
*
|
|
4
|
-
* Upload pre-sign config retrieval, resource download URL retrieval, etc.
|
|
5
|
-
* Auth and HTTP utilities are in request.ts.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { ResolvedYuanbaoAccount } from "../../types.js";
|
|
9
|
-
import type { Log, CosUploadConfig } from "./request.js";
|
|
10
|
-
import { yuanbaoPost, yuanbaoGet } from "./request.js";
|
|
11
|
-
|
|
12
|
-
const UPLOAD_INFO_PATH = "/api/resource/genUploadInfo";
|
|
13
|
-
const DOWNLOAD_INFO_PATH = "/api/resource/v1/download";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get COS upload pre-sign config.
|
|
17
|
-
*/
|
|
18
|
-
export async function apiGetUploadInfo(
|
|
19
|
-
account: ResolvedYuanbaoAccount,
|
|
20
|
-
fileName: string,
|
|
21
|
-
fileId: string,
|
|
22
|
-
log?: Log,
|
|
23
|
-
): Promise<CosUploadConfig> {
|
|
24
|
-
const data = await yuanbaoPost<CosUploadConfig>(
|
|
25
|
-
account,
|
|
26
|
-
UPLOAD_INFO_PATH,
|
|
27
|
-
{ fileName, fileId, docFrom: "localDoc", docOpenId: "" },
|
|
28
|
-
log,
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
if (!data.bucketName || !data.location) {
|
|
32
|
-
throw new Error(`[yuanbao-api] genUploadInfo incomplete config: ${JSON.stringify(data)}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get COS download URL for a given resourceId.
|
|
40
|
-
*/
|
|
41
|
-
export async function apiGetDownloadUrl(
|
|
42
|
-
account: ResolvedYuanbaoAccount,
|
|
43
|
-
resourceId: string,
|
|
44
|
-
log?: Log,
|
|
45
|
-
): Promise<string> {
|
|
46
|
-
const data = await yuanbaoGet<{ url?: string; realUrl?: string }>(
|
|
47
|
-
account,
|
|
48
|
-
DOWNLOAD_INFO_PATH,
|
|
49
|
-
{ resourceId },
|
|
50
|
-
log,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const downloadUrl = data.url ?? data.realUrl;
|
|
54
|
-
if (!downloadUrl) {
|
|
55
|
-
throw new Error(`[yuanbao-api] resource/v1/download returned no valid URL: ${JSON.stringify(data)}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return downloadUrl;
|
|
59
|
-
}
|