@lark-apaas/openclaw-scripts-diagnose-cli 0.1.13-alpha.6 → 0.1.13-alpha.8
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.cjs +59 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -52,7 +52,7 @@ node_assert = __toESM(node_assert);
|
|
|
52
52
|
* it terse and parseable.
|
|
53
53
|
*/
|
|
54
54
|
function getVersion() {
|
|
55
|
-
return "0.1.13-alpha.
|
|
55
|
+
return "0.1.13-alpha.8";
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/rule-engine/base.ts
|
|
@@ -3560,31 +3560,31 @@ CleanupInstallBackupDirsRule = __decorate([Rule({
|
|
|
3560
3560
|
* Ensures each bot account's channel config is correct:
|
|
3561
3561
|
* 1. `allowFrom` contains its own `creatorOpenID` from larkApps
|
|
3562
3562
|
* 2. `appSecret` is either the canonical provider-ref or matches larkApps plaintext
|
|
3563
|
+
*
|
|
3564
|
+
* Covers both multi-account (channels.feishu.accounts) and single-account
|
|
3565
|
+
* (channels.feishu.appId + allowFrom at top level) layouts.
|
|
3563
3566
|
*/
|
|
3564
3567
|
let FeishuBotChannelConfigRule = class FeishuBotChannelConfigRule extends DiagnoseRule {
|
|
3565
3568
|
validate(ctx) {
|
|
3566
3569
|
const larkApps = ctx.vars.larkApps;
|
|
3567
3570
|
if (!larkApps || larkApps.length === 0) return { pass: true };
|
|
3568
|
-
const
|
|
3569
|
-
if (!
|
|
3571
|
+
const feishu = asRecord(getNestedMap(ctx.config, "channels", "feishu"));
|
|
3572
|
+
if (!feishu) return { pass: true };
|
|
3570
3573
|
const issues = [];
|
|
3571
|
-
|
|
3574
|
+
const accounts = asRecord(feishu.accounts);
|
|
3575
|
+
if (accounts) for (const [accountId, account] of Object.entries(accounts)) {
|
|
3572
3576
|
const bot = asRecord(account);
|
|
3573
3577
|
if (!bot) continue;
|
|
3574
3578
|
const appId = bot.appId;
|
|
3575
3579
|
if (typeof appId !== "string" || !appId.startsWith("cli_")) continue;
|
|
3576
3580
|
const larkApp = larkApps.find((e) => e.larkAppID === appId);
|
|
3577
3581
|
if (!larkApp) continue;
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
const
|
|
3583
|
-
if (
|
|
3584
|
-
if (!matchMap(secret, DEFAULT_FEISHU_APP_SECRET)) issues.push(`${accountId} appSecret is a provider-ref but not the canonical one`);
|
|
3585
|
-
} else if (typeof secret === "string") {
|
|
3586
|
-
if (secret !== larkApp.appSecret) issues.push(`${accountId} appSecret plaintext mismatch`);
|
|
3587
|
-
} else issues.push(`${accountId} appSecret has unexpected type`);
|
|
3582
|
+
this.checkBot(accountId, bot, larkApp, issues);
|
|
3583
|
+
}
|
|
3584
|
+
const singleAppId = feishu.appId;
|
|
3585
|
+
if (typeof singleAppId === "string" && singleAppId.startsWith("cli_") && !accounts) {
|
|
3586
|
+
const larkApp = larkApps.find((e) => e.larkAppID === singleAppId);
|
|
3587
|
+
if (larkApp) this.checkBot("feishu", feishu, larkApp, issues);
|
|
3588
3588
|
}
|
|
3589
3589
|
if (issues.length === 0) return { pass: true };
|
|
3590
3590
|
return {
|
|
@@ -3592,40 +3592,64 @@ let FeishuBotChannelConfigRule = class FeishuBotChannelConfigRule extends Diagno
|
|
|
3592
3592
|
message: issues.join("; ")
|
|
3593
3593
|
};
|
|
3594
3594
|
}
|
|
3595
|
+
/** Check a single bot entry (either an account object or the feishu channel itself). */
|
|
3596
|
+
checkBot(label, bot, larkApp, issues) {
|
|
3597
|
+
const creatorOpenID = larkApp.creatorOpenID;
|
|
3598
|
+
const allowFrom = Array.isArray(bot.allowFrom) ? bot.allowFrom : [];
|
|
3599
|
+
if (typeof creatorOpenID === "string" && creatorOpenID !== "") {
|
|
3600
|
+
if (!allowFrom.includes(creatorOpenID)) issues.push(`${label} allowFrom missing creatorOpenID ${creatorOpenID.length > 8 ? creatorOpenID.slice(0, 4) + "***" + creatorOpenID.slice(-4) : "***"}`);
|
|
3601
|
+
} else if (allowFrom.length === 0) issues.push(`${label} allowFrom is empty (creatorOpenID unavailable, cannot auto-fix)`);
|
|
3602
|
+
const secret = bot.appSecret;
|
|
3603
|
+
if (typeof secret === "object" && secret !== null && !Array.isArray(secret)) {
|
|
3604
|
+
if (!matchMap(secret, DEFAULT_FEISHU_APP_SECRET)) issues.push(`${label} appSecret is a provider-ref but not the canonical one`);
|
|
3605
|
+
} else if (typeof secret === "string") {
|
|
3606
|
+
if (secret !== larkApp.appSecret) issues.push(`${label} appSecret plaintext mismatch`);
|
|
3607
|
+
} else issues.push(`${label} appSecret has unexpected type`);
|
|
3608
|
+
}
|
|
3595
3609
|
repair(ctx) {
|
|
3596
3610
|
const larkApps = ctx.vars.larkApps;
|
|
3597
3611
|
if (!larkApps || larkApps.length === 0) return;
|
|
3598
|
-
const
|
|
3599
|
-
if (!
|
|
3600
|
-
|
|
3612
|
+
const feishu = asRecord(getNestedMap(ctx.config, "channels", "feishu"));
|
|
3613
|
+
if (!feishu) return;
|
|
3614
|
+
const accounts = asRecord(feishu.accounts);
|
|
3615
|
+
if (accounts) for (const [, account] of Object.entries(accounts)) {
|
|
3601
3616
|
const bot = asRecord(account);
|
|
3602
3617
|
if (!bot) continue;
|
|
3603
3618
|
const appId = bot.appId;
|
|
3604
3619
|
if (typeof appId !== "string" || !appId.startsWith("cli_")) continue;
|
|
3605
3620
|
const larkApp = larkApps.find((e) => e.larkAppID === appId);
|
|
3606
3621
|
if (!larkApp) continue;
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3622
|
+
this.fixBot(bot, larkApp);
|
|
3623
|
+
}
|
|
3624
|
+
const singleAppId = feishu.appId;
|
|
3625
|
+
if (typeof singleAppId === "string" && singleAppId.startsWith("cli_") && !accounts) {
|
|
3626
|
+
const larkApp = larkApps.find((e) => e.larkAppID === singleAppId);
|
|
3627
|
+
if (larkApp) this.fixBot(feishu, larkApp);
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
/** Fix a single bot entry in-place. */
|
|
3631
|
+
fixBot(bot, larkApp) {
|
|
3632
|
+
const creatorOpenID = larkApp.creatorOpenID;
|
|
3633
|
+
if (typeof creatorOpenID === "string" && creatorOpenID !== "") {
|
|
3634
|
+
const allowFrom = Array.isArray(bot.allowFrom) ? [...bot.allowFrom] : [];
|
|
3635
|
+
if (!allowFrom.includes(creatorOpenID)) {
|
|
3636
|
+
allowFrom.push(creatorOpenID);
|
|
3637
|
+
bot.allowFrom = allowFrom;
|
|
3614
3638
|
}
|
|
3615
|
-
const secret = bot.appSecret;
|
|
3616
|
-
let needsFix = false;
|
|
3617
|
-
if (typeof secret === "object" && secret !== null && !Array.isArray(secret)) {
|
|
3618
|
-
if (!matchMap(secret, DEFAULT_FEISHU_APP_SECRET)) needsFix = true;
|
|
3619
|
-
} else if (typeof secret === "string") {
|
|
3620
|
-
if (secret !== larkApp.appSecret) needsFix = true;
|
|
3621
|
-
} else needsFix = true;
|
|
3622
|
-
if (needsFix) bot.appSecret = { ...DEFAULT_FEISHU_APP_SECRET };
|
|
3623
3639
|
}
|
|
3640
|
+
const secret = bot.appSecret;
|
|
3641
|
+
let needsFix = false;
|
|
3642
|
+
if (typeof secret === "object" && secret !== null && !Array.isArray(secret)) {
|
|
3643
|
+
if (!matchMap(secret, DEFAULT_FEISHU_APP_SECRET)) needsFix = true;
|
|
3644
|
+
} else if (typeof secret === "string") {
|
|
3645
|
+
if (secret !== larkApp.appSecret) needsFix = true;
|
|
3646
|
+
} else needsFix = true;
|
|
3647
|
+
if (needsFix) bot.appSecret = { ...DEFAULT_FEISHU_APP_SECRET };
|
|
3624
3648
|
}
|
|
3625
3649
|
};
|
|
3626
3650
|
FeishuBotChannelConfigRule = __decorate([Rule({
|
|
3627
3651
|
key: "feishu_bot_channel_config",
|
|
3628
|
-
description: "
|
|
3652
|
+
description: "确保飞书配置中 bot 账号的 allowFrom 包含其创建者 openID 且 appSecret 值正确",
|
|
3629
3653
|
dependsOn: [
|
|
3630
3654
|
"config_syntax_check",
|
|
3631
3655
|
"feishu_default_account",
|
|
@@ -10246,7 +10270,7 @@ async function reportCliRun(opts) {
|
|
|
10246
10270
|
//#region src/help.ts
|
|
10247
10271
|
const BIN = "mclaw-diagnose";
|
|
10248
10272
|
function versionBanner() {
|
|
10249
|
-
return `v0.1.13-alpha.
|
|
10273
|
+
return `v0.1.13-alpha.8`;
|
|
10250
10274
|
}
|
|
10251
10275
|
const COMMANDS = [
|
|
10252
10276
|
{
|
|
@@ -10705,6 +10729,7 @@ function planCtxPopulate(opts) {
|
|
|
10705
10729
|
populate.secrets = true;
|
|
10706
10730
|
populate.install = true;
|
|
10707
10731
|
populate.reset = true;
|
|
10732
|
+
populate.larkApps = true;
|
|
10708
10733
|
}
|
|
10709
10734
|
return populate;
|
|
10710
10735
|
}
|
package/package.json
CHANGED