@max1874/feishu 0.3.1 → 0.4.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/package.json +1 -1
- package/src/bot.ts +5 -0
- package/src/channel.ts +1 -1
- package/src/config-schema.ts +1 -1
- package/src/docx.ts +38 -3
package/package.json
CHANGED
package/src/bot.ts
CHANGED
|
@@ -594,6 +594,11 @@ export async function handleFeishuMessage(params: {
|
|
|
594
594
|
const dmPolicy = feishuCfg?.dmPolicy ?? "pairing";
|
|
595
595
|
const allowFrom = feishuCfg?.allowFrom ?? [];
|
|
596
596
|
|
|
597
|
+
if (dmPolicy === "disabled") {
|
|
598
|
+
log(`feishu: DMs disabled, ignoring message from ${ctx.senderOpenId}`);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
|
|
597
602
|
if (dmPolicy === "allowlist") {
|
|
598
603
|
const match = resolveFeishuAllowlistMatch({
|
|
599
604
|
allowFrom,
|
package/src/channel.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount> = {
|
|
|
76
76
|
connectionMode: { type: "string", enum: ["websocket", "webhook"] },
|
|
77
77
|
webhookPath: { type: "string" },
|
|
78
78
|
webhookPort: { type: "integer", minimum: 1 },
|
|
79
|
-
dmPolicy: { type: "string", enum: ["open", "pairing", "allowlist"] },
|
|
79
|
+
dmPolicy: { type: "string", enum: ["open", "pairing", "allowlist", "disabled"] },
|
|
80
80
|
allowFrom: { type: "array", items: { oneOf: [{ type: "string" }, { type: "number" }] } },
|
|
81
81
|
groupPolicy: { type: "string", enum: ["open", "allowlist", "disabled"] },
|
|
82
82
|
groupAllowFrom: { type: "array", items: { oneOf: [{ type: "string" }, { type: "number" }] } },
|
package/src/config-schema.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export { z };
|
|
3
3
|
|
|
4
|
-
const DmPolicySchema = z.enum(["open", "pairing", "allowlist"]);
|
|
4
|
+
const DmPolicySchema = z.enum(["open", "pairing", "allowlist", "disabled"]);
|
|
5
5
|
const GroupPolicySchema = z.enum(["open", "allowlist", "disabled"]);
|
|
6
6
|
const FeishuDomainSchema = z.enum(["feishu", "lark"]);
|
|
7
7
|
const FeishuConnectionModeSchema = z.enum(["websocket", "webhook"]);
|
package/src/docx.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
2
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
3
3
|
import { createFeishuClient } from "./client.js";
|
|
4
|
+
import { resolveFeishuCredentials, mergeFeishuAccountConfig } from "./accounts.js";
|
|
4
5
|
import { getConversationContext } from "./runtime.js";
|
|
5
6
|
import type { FeishuConfig } from "./types.js";
|
|
6
7
|
import type * as Lark from "@larksuiteoapi/node-sdk";
|
|
@@ -887,16 +888,50 @@ const WikiSpaceIdSchema = Type.Object({
|
|
|
887
888
|
),
|
|
888
889
|
});
|
|
889
890
|
|
|
891
|
+
/**
|
|
892
|
+
* Resolve a FeishuConfig that has credentials, checking:
|
|
893
|
+
* 1. Top-level appId/appSecret (legacy / pre-v2026.3.2 layout)
|
|
894
|
+
* 2. The defaultAccount entry under accounts
|
|
895
|
+
* 3. The first account that has valid credentials
|
|
896
|
+
*/
|
|
897
|
+
function resolveEffectiveFeishuConfig(cfg: FeishuConfig): FeishuConfig | null {
|
|
898
|
+
// 1. Top-level credentials
|
|
899
|
+
if (resolveFeishuCredentials(cfg)) return cfg;
|
|
900
|
+
|
|
901
|
+
// 2. defaultAccount (e.g. "main")
|
|
902
|
+
const defaultId = (cfg as any).defaultAccount as string | undefined;
|
|
903
|
+
if (defaultId && cfg.accounts?.[defaultId]) {
|
|
904
|
+
const merged = mergeFeishuAccountConfig(cfg, defaultId);
|
|
905
|
+
if (resolveFeishuCredentials(merged)) return merged;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// 3. First account with credentials
|
|
909
|
+
for (const id of Object.keys(cfg.accounts ?? {})) {
|
|
910
|
+
const merged = mergeFeishuAccountConfig(cfg, id);
|
|
911
|
+
if (resolveFeishuCredentials(merged)) return merged;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
916
|
+
|
|
890
917
|
// ============ Tool Registration ============
|
|
891
918
|
|
|
892
919
|
export function registerFeishuDocTools(api: OpenClawPluginApi) {
|
|
893
920
|
const feishuCfg = api.config?.channels?.feishu as FeishuConfig | undefined;
|
|
894
|
-
if (!feishuCfg
|
|
895
|
-
api.logger.debug?.("feishu_doc: Feishu
|
|
921
|
+
if (!feishuCfg) {
|
|
922
|
+
api.logger.debug?.("feishu_doc: Feishu not configured, skipping doc tools");
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Resolve effective config: try top-level credentials first, then fall back
|
|
927
|
+
// to defaultAccount or the first account that has credentials configured.
|
|
928
|
+
const resolvedCfg = resolveEffectiveFeishuConfig(feishuCfg);
|
|
929
|
+
if (!resolvedCfg) {
|
|
930
|
+
api.logger.debug?.("feishu_doc: Feishu credentials not configured (appId, appSecret required), skipping doc tools");
|
|
896
931
|
return;
|
|
897
932
|
}
|
|
898
933
|
|
|
899
|
-
const getClient = () => createFeishuClient(
|
|
934
|
+
const getClient = () => createFeishuClient(resolvedCfg);
|
|
900
935
|
|
|
901
936
|
// Tool 1: feishu_doc_read
|
|
902
937
|
api.registerTool(
|