@searchfe/openclaw-baiduapp 0.1.14 → 0.1.15
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.js +130 -3
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +3 -3
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -27203,6 +27203,9 @@ var DEFAULT_BAIDU_APP_SESSION_ID = "agent:main:main";
|
|
|
27203
27203
|
var require2 = createRequire(import.meta.url);
|
|
27204
27204
|
var pkg = require2("../package.json");
|
|
27205
27205
|
var PLUGIN_VERSION = pkg.version;
|
|
27206
|
+
function isBetaPluginVersion(version = PLUGIN_VERSION) {
|
|
27207
|
+
return /(?:^|-)beta(?:\.|$)/.test(version);
|
|
27208
|
+
}
|
|
27206
27209
|
|
|
27207
27210
|
// src/api.ts
|
|
27208
27211
|
var logger = createLogger("openclaw-baiduapp");
|
|
@@ -28653,12 +28656,16 @@ async function pollBaiduAppChatlistOnce(account, loggerOptions, requestOptions)
|
|
|
28653
28656
|
nonce
|
|
28654
28657
|
});
|
|
28655
28658
|
const url = `${endpoint}?${query.toString()}`;
|
|
28659
|
+
const shouldLogBetaPollDebug = isBetaPluginVersion();
|
|
28656
28660
|
const payload = {
|
|
28657
28661
|
sessionId: "agent:main:main",
|
|
28658
28662
|
num: 5,
|
|
28659
28663
|
version: PLUGIN_VERSION
|
|
28660
28664
|
};
|
|
28661
28665
|
const body = JSON.stringify(payload);
|
|
28666
|
+
if (shouldLogBetaPollDebug) {
|
|
28667
|
+
logger3.debug(`Baidu poll request url=${url}`);
|
|
28668
|
+
}
|
|
28662
28669
|
const requestSignal = createAbortSignalController({
|
|
28663
28670
|
signal: requestOptions?.signal,
|
|
28664
28671
|
timeoutMs: requestOptions?.timeoutMs
|
|
@@ -28677,6 +28684,9 @@ async function pollBaiduAppChatlistOnce(account, loggerOptions, requestOptions)
|
|
|
28677
28684
|
} catch (error) {
|
|
28678
28685
|
requestSignal.cleanup();
|
|
28679
28686
|
if (requestSignal.didTimeout()) {
|
|
28687
|
+
if (shouldLogBetaPollDebug) {
|
|
28688
|
+
logger3.debug(`Baidu poll result error=timeout, timeoutMs=${String(requestOptions?.timeoutMs)}`);
|
|
28689
|
+
}
|
|
28680
28690
|
return buildPollResult({
|
|
28681
28691
|
ok: false,
|
|
28682
28692
|
error: {
|
|
@@ -28686,6 +28696,9 @@ async function pollBaiduAppChatlistOnce(account, loggerOptions, requestOptions)
|
|
|
28686
28696
|
});
|
|
28687
28697
|
}
|
|
28688
28698
|
if (isAbortError2(error)) {
|
|
28699
|
+
if (shouldLogBetaPollDebug) {
|
|
28700
|
+
logger3.debug("Baidu poll result error=aborted");
|
|
28701
|
+
}
|
|
28689
28702
|
return buildPollResult({
|
|
28690
28703
|
ok: false,
|
|
28691
28704
|
error: {
|
|
@@ -28694,6 +28707,10 @@ async function pollBaiduAppChatlistOnce(account, loggerOptions, requestOptions)
|
|
|
28694
28707
|
}
|
|
28695
28708
|
});
|
|
28696
28709
|
}
|
|
28710
|
+
if (shouldLogBetaPollDebug) {
|
|
28711
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28712
|
+
logger3.debug(`Baidu poll result error=request-failed, message=${message}`);
|
|
28713
|
+
}
|
|
28697
28714
|
return buildPollResult({
|
|
28698
28715
|
ok: false,
|
|
28699
28716
|
error: {
|
|
@@ -28704,6 +28721,9 @@ async function pollBaiduAppChatlistOnce(account, loggerOptions, requestOptions)
|
|
|
28704
28721
|
}
|
|
28705
28722
|
const responseText = await response.text();
|
|
28706
28723
|
requestSignal.cleanup();
|
|
28724
|
+
if (shouldLogBetaPollDebug) {
|
|
28725
|
+
logger3.debug(`Baidu poll result status=${String(response.status)}, body=${responseText || "<empty>"}`);
|
|
28726
|
+
}
|
|
28707
28727
|
if (!responseText) {
|
|
28708
28728
|
return buildPollResult({
|
|
28709
28729
|
ok: false,
|
|
@@ -28820,14 +28840,119 @@ var logger2 = createLogger("openclaw-baiduapp");
|
|
|
28820
28840
|
var meta = {
|
|
28821
28841
|
id: "openclaw-baiduapp",
|
|
28822
28842
|
label: "Baidu App",
|
|
28823
|
-
selectionLabel: "Baidu
|
|
28843
|
+
selectionLabel: "Baidu App\uFF08\u767E\u5EA6 app\uFF09",
|
|
28824
28844
|
docsPath: "/channels/openclaw-baiduapp",
|
|
28825
28845
|
docsLabel: "openclaw-baiduapp",
|
|
28826
|
-
blurb: "\u767E\u5EA6\
|
|
28846
|
+
blurb: "\u767E\u5EA6 app \u6D88\u606F\u6E20\u9053\u3002",
|
|
28827
28847
|
aliases: ["baidu-ai", "\u767E\u5EA6\u641C\u7D22AI"],
|
|
28828
28848
|
order: 85
|
|
28829
28849
|
};
|
|
28830
28850
|
var unregisterHooks = /* @__PURE__ */ new Map();
|
|
28851
|
+
function applyBaiduAppSetupConfigPatch(params) {
|
|
28852
|
+
const currentChannel = params.cfg.channels?.["openclaw-baiduapp"] ?? {};
|
|
28853
|
+
if (params.accountId === DEFAULT_ACCOUNT_ID) {
|
|
28854
|
+
return {
|
|
28855
|
+
...params.cfg,
|
|
28856
|
+
channels: {
|
|
28857
|
+
...params.cfg.channels,
|
|
28858
|
+
"openclaw-baiduapp": {
|
|
28859
|
+
...currentChannel,
|
|
28860
|
+
...params.patch
|
|
28861
|
+
}
|
|
28862
|
+
}
|
|
28863
|
+
};
|
|
28864
|
+
}
|
|
28865
|
+
return {
|
|
28866
|
+
...params.cfg,
|
|
28867
|
+
channels: {
|
|
28868
|
+
...params.cfg.channels,
|
|
28869
|
+
"openclaw-baiduapp": {
|
|
28870
|
+
...currentChannel,
|
|
28871
|
+
accounts: {
|
|
28872
|
+
...currentChannel.accounts,
|
|
28873
|
+
[params.accountId]: {
|
|
28874
|
+
...currentChannel.accounts?.[params.accountId],
|
|
28875
|
+
...params.patch
|
|
28876
|
+
}
|
|
28877
|
+
}
|
|
28878
|
+
}
|
|
28879
|
+
}
|
|
28880
|
+
};
|
|
28881
|
+
}
|
|
28882
|
+
var baiduAppSetupWizard = {
|
|
28883
|
+
channel: "openclaw-baiduapp",
|
|
28884
|
+
status: {
|
|
28885
|
+
configuredLabel: "Configured",
|
|
28886
|
+
unconfiguredLabel: "Not configured",
|
|
28887
|
+
configuredHint: "App Key / App Secret configured",
|
|
28888
|
+
unconfiguredHint: "Enter App Key / App Secret",
|
|
28889
|
+
configuredScore: 100,
|
|
28890
|
+
unconfiguredScore: 20,
|
|
28891
|
+
resolveConfigured: ({ cfg, accountId }) => resolveBaiduAppAccount({ cfg, accountId }).configured
|
|
28892
|
+
},
|
|
28893
|
+
stepOrder: "text-first",
|
|
28894
|
+
textInputs: [{
|
|
28895
|
+
inputKey: "appToken",
|
|
28896
|
+
message: "\u8BF7\u8F93\u5165 App Key (AK)",
|
|
28897
|
+
required: true,
|
|
28898
|
+
confirmCurrentValue: false,
|
|
28899
|
+
currentValue: ({ cfg, accountId }) => resolveBaiduAppAccount({ cfg, accountId }).appKey,
|
|
28900
|
+
initialValue: ({ cfg, accountId }) => resolveBaiduAppAccount({ cfg, accountId }).appKey,
|
|
28901
|
+
validate: ({ value }) => value.trim() ? void 0 : "App Key \u4E0D\u80FD\u4E3A\u7A7A",
|
|
28902
|
+
normalizeValue: ({ value }) => value.trim(),
|
|
28903
|
+
applySet: ({ cfg, accountId, value }) => applyBaiduAppSetupConfigPatch({ cfg, accountId, patch: { appKey: value } })
|
|
28904
|
+
}],
|
|
28905
|
+
credentials: [{
|
|
28906
|
+
inputKey: "secret",
|
|
28907
|
+
providerHint: "openclaw-baiduapp",
|
|
28908
|
+
credentialLabel: "App Secret (SK)",
|
|
28909
|
+
preferredEnvVar: "BAIDU_APP_SECRET",
|
|
28910
|
+
envPrompt: "Use BAIDU_APP_SECRET from environment?",
|
|
28911
|
+
keepPrompt: "App Secret already configured. Keep it?",
|
|
28912
|
+
inputPrompt: "\u8BF7\u8F93\u5165 App Secret (SK)",
|
|
28913
|
+
inspect: ({ cfg, accountId }) => {
|
|
28914
|
+
const account = resolveBaiduAppAccount({ cfg, accountId });
|
|
28915
|
+
return {
|
|
28916
|
+
accountConfigured: account.configured,
|
|
28917
|
+
hasConfiguredValue: Boolean(account.appSecret?.trim())
|
|
28918
|
+
};
|
|
28919
|
+
},
|
|
28920
|
+
applySet: ({ cfg, accountId, resolvedValue }) => applyBaiduAppSetupConfigPatch({ cfg, accountId, patch: { appSecret: resolvedValue.trim() } })
|
|
28921
|
+
}],
|
|
28922
|
+
completionNote: {
|
|
28923
|
+
title: "\u767E\u5EA6 app \u914D\u7F6E\u5B8C\u6210",
|
|
28924
|
+
lines: ["\u5DF2\u5199\u5165 App Key / App Secret\u3002\u91CD\u542F Gateway \u540E\u751F\u6548\u3002"]
|
|
28925
|
+
},
|
|
28926
|
+
disable: (cfg) => ({
|
|
28927
|
+
...cfg,
|
|
28928
|
+
channels: {
|
|
28929
|
+
...cfg.channels,
|
|
28930
|
+
"openclaw-baiduapp": {
|
|
28931
|
+
...cfg.channels?.["openclaw-baiduapp"],
|
|
28932
|
+
enabled: false
|
|
28933
|
+
}
|
|
28934
|
+
}
|
|
28935
|
+
})
|
|
28936
|
+
};
|
|
28937
|
+
var baiduAppSetupAdapter = {
|
|
28938
|
+
applyAccountConfig: ({ cfg, accountId, input }) => applyBaiduAppSetupConfigPatch({
|
|
28939
|
+
cfg,
|
|
28940
|
+
accountId,
|
|
28941
|
+
patch: {
|
|
28942
|
+
...input.appToken?.trim() ? { appKey: input.appToken.trim() } : {},
|
|
28943
|
+
...input.secret?.trim() ? { appSecret: input.secret.trim() } : {}
|
|
28944
|
+
}
|
|
28945
|
+
}),
|
|
28946
|
+
validateInput: ({ input }) => {
|
|
28947
|
+
if (!input.appToken?.trim()) {
|
|
28948
|
+
return "App Key \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u901A\u8FC7 --app-token \u4F20\u5165 AK\u3002";
|
|
28949
|
+
}
|
|
28950
|
+
if (!input.secret?.trim()) {
|
|
28951
|
+
return "App Secret \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u901A\u8FC7 --secret \u4F20\u5165 SK\u3002";
|
|
28952
|
+
}
|
|
28953
|
+
return null;
|
|
28954
|
+
}
|
|
28955
|
+
};
|
|
28831
28956
|
function resolveOutboundLocalMediaPath(mediaUrl) {
|
|
28832
28957
|
const trimmed = mediaUrl?.trim();
|
|
28833
28958
|
if (!trimmed) {
|
|
@@ -28955,6 +29080,8 @@ var baiduAppPlugin = {
|
|
|
28955
29080
|
}
|
|
28956
29081
|
},
|
|
28957
29082
|
configSchema: BaiduAppConfigJsonSchema,
|
|
29083
|
+
setup: baiduAppSetupAdapter,
|
|
29084
|
+
setupWizard: baiduAppSetupWizard,
|
|
28958
29085
|
reload: { configPrefixes: ["channels.openclaw-baiduapp"] },
|
|
28959
29086
|
config: {
|
|
28960
29087
|
listAccountIds: (cfg) => listBaiduAppAccountIds(cfg),
|
|
@@ -29361,7 +29488,7 @@ async function sendBaidu(account, options) {
|
|
|
29361
29488
|
var plugin = {
|
|
29362
29489
|
id: "openclaw-baiduapp",
|
|
29363
29490
|
name: "Baidu App",
|
|
29364
|
-
description: "\u767E\
|
|
29491
|
+
description: "\u767E\u5EA6 app \u6D88\u606F\u6E20\u9053\u3002",
|
|
29365
29492
|
configSchema: {
|
|
29366
29493
|
type: "object",
|
|
29367
29494
|
additionalProperties: false,
|