fix: honor feishu setup account status

This commit is contained in:
Tak Hoffman 2026-04-03 12:13:34 -05:00
parent e37c0da23a
commit fc61e8d280
No known key found for this signature in database
2 changed files with 43 additions and 5 deletions

View File

@ -134,6 +134,31 @@ describe("feishu setup wizard status", () => {
expect(status.configured).toBe(false);
});
it("setup status honors the selected named account", async () => {
const status = await feishuGetStatus({
cfg: {
channels: {
feishu: {
appId: "top_level_app",
appSecret: "top-level-secret", // pragma: allowlist secret
accounts: {
work: {
appId: "",
appSecret: "work-secret", // pragma: allowlist secret
},
},
},
},
} as never,
accountOverrides: {
feishu: "work",
},
});
expect(status.configured).toBe(false);
expect(status.statusLines).toEqual(["Feishu: needs app credentials"]);
});
it("treats env SecretRef appId as not configured when env var is missing", async () => {
const appIdKey = "FEISHU_APP_ID_STATUS_MISSING_TEST";
const appSecretKey = "FEISHU_APP_CREDENTIAL_STATUS_MISSING_TEST"; // pragma: allowlist secret

View File

@ -16,7 +16,7 @@ import {
type OpenClawConfig,
type SecretInput,
} from "openclaw/plugin-sdk/setup";
import { inspectFeishuCredentials, listFeishuAccountIds } from "./accounts.js";
import { inspectFeishuCredentials, listFeishuAccountIds, resolveFeishuAccount } from "./accounts.js";
import { probeFeishu } from "./probe.js";
import { feishuSetupAdapter } from "./setup-core.js";
import type { FeishuConfig } from "./types.js";
@ -162,10 +162,23 @@ export const feishuSetupWizard: ChannelSetupWizard = {
unconfiguredHint: "needs app creds",
configuredScore: 2,
unconfiguredScore: 0,
resolveConfigured: ({ cfg }) => isFeishuConfigured(cfg),
resolveStatusLines: async ({ cfg, configured }) => {
const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined;
const resolvedCredentials = inspectFeishuCredentials(feishuCfg);
resolveConfigured: ({ cfg, accountId }) =>
accountId ? resolveFeishuAccount({ cfg, accountId }).configured : isFeishuConfigured(cfg),
resolveStatusLines: async ({ cfg, accountId, configured }) => {
const resolvedCredentials = accountId
? (() => {
const account = resolveFeishuAccount({ cfg, accountId });
return account.configured && account.appId && account.appSecret
? {
appId: account.appId,
appSecret: account.appSecret,
encryptKey: account.encryptKey,
verificationToken: account.verificationToken,
domain: account.domain,
}
: null;
})()
: inspectFeishuCredentials(cfg.channels?.feishu as FeishuConfig | undefined);
let probeResult = null;
if (configured && resolvedCredentials) {
try {