@openclaw-china/feishu 0.1.1

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.
@@ -0,0 +1,29 @@
1
+ {
2
+ "id": "feishu",
3
+ "name": "Feishu",
4
+ "description": "飞书/Lark 消息渠道插件",
5
+ "version": "0.1.0",
6
+ "channels": ["feishu"],
7
+ "configSchema": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "enabled": { "type": "boolean" },
12
+ "appId": { "type": "string" },
13
+ "appSecret": { "type": "string" },
14
+ "connectionMode": { "type": "string", "enum": ["websocket"] },
15
+ "dmPolicy": { "type": "string", "enum": ["open", "pairing", "allowlist"] },
16
+ "groupPolicy": { "type": "string", "enum": ["open", "allowlist", "disabled"] },
17
+ "requireMention": { "type": "boolean" },
18
+ "allowFrom": { "type": "array", "items": { "type": "string" } },
19
+ "groupAllowFrom": { "type": "array", "items": { "type": "string" } },
20
+ "sendMarkdownAsCard": { "type": "boolean" },
21
+ "historyLimit": { "type": "integer", "minimum": 0 },
22
+ "textChunkLimit": { "type": "integer", "minimum": 1 }
23
+ }
24
+ },
25
+ "uiHints": {
26
+ "appId": { "label": "App ID" },
27
+ "appSecret": { "label": "App Secret", "sensitive": true }
28
+ }
29
+ }
@@ -0,0 +1,474 @@
1
+ var __createBinding = (undefined && undefined.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __exportStar = (undefined && undefined.__exportStar) || function(m, exports$1) {
13
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ __exportStar(require("./errors.cjs"), exports);
17
+ __exportStar(require("./helpers/parseUtil.cjs"), exports);
18
+ __exportStar(require("./helpers/typeAliases.cjs"), exports);
19
+ __exportStar(require("./helpers/util.cjs"), exports);
20
+ __exportStar(require("./types.cjs"), exports);
21
+ __exportStar(require("./ZodError.cjs"), exports);
22
+
23
+ /**
24
+ * 飞书渠道配置 Schema
25
+ *
26
+ * 配置字段说明:
27
+ * - enabled: 是否启用该渠道
28
+ * - appId: 飞书应用 App ID
29
+ * - appSecret: 飞书应用 App Secret
30
+ * - connectionMode: 连接模式(仅支持 websocket)
31
+ * - dmPolicy: 单聊策略 (open=开放, pairing=配对, allowlist=白名单)
32
+ * - groupPolicy: 群聊策略 (open=开放, allowlist=白名单, disabled=禁用)
33
+ * - requireMention: 群聊是否需要 @机器人
34
+ * - allowFrom: 单聊白名单用户 ID 列表
35
+ * - groupAllowFrom: 群聊白名单会话 ID 列表
36
+ * - historyLimit: 历史消息数量限制
37
+ * - textChunkLimit: 文本分块大小限制
38
+ */
39
+ declare const FeishuConfigSchema: undefined<{
40
+ /** 是否启用飞书渠道 */
41
+ enabled: undefined<undefined<undefined>>;
42
+ /** 飞书应用 App ID */
43
+ appId: undefined<undefined>;
44
+ /** 飞书应用 App Secret */
45
+ appSecret: undefined<undefined>;
46
+ /** 连接模式(暂只支持 websocket) */
47
+ connectionMode: undefined<undefined<undefined<["websocket"]>>>;
48
+ /** 单聊策略: open=开放, pairing=配对, allowlist=白名单 */
49
+ dmPolicy: undefined<undefined<undefined<["open", "pairing", "allowlist"]>>>;
50
+ /** 群聊策略: open=开放, allowlist=白名单, disabled=禁用 */
51
+ groupPolicy: undefined<undefined<undefined<["open", "allowlist", "disabled"]>>>;
52
+ /** 群聊是否需要 @机器人才响应 */
53
+ requireMention: undefined<undefined<undefined>>;
54
+ /** 单聊白名单: 允许的用户 ID 列表 */
55
+ allowFrom: undefined<undefined<undefined, "many">>;
56
+ /** 群聊白名单: 允许的会话 ID 列表 */
57
+ groupAllowFrom: undefined<undefined<undefined, "many">>;
58
+ /** 是否将 Markdown 文本以卡片形式发送 */
59
+ sendMarkdownAsCard: undefined<undefined<undefined>>;
60
+ /** 历史消息数量限制 */
61
+ historyLimit: undefined<undefined<undefined>>;
62
+ /** 文本分块大小限制 (飞书文本消息最大 4000 字符) */
63
+ textChunkLimit: undefined<undefined<undefined>>;
64
+ }, "strip", undefined, {
65
+ enabled: boolean;
66
+ connectionMode: "websocket";
67
+ dmPolicy: "open" | "pairing" | "allowlist";
68
+ groupPolicy: "open" | "allowlist" | "disabled";
69
+ requireMention: boolean;
70
+ sendMarkdownAsCard: boolean;
71
+ historyLimit: number;
72
+ textChunkLimit: number;
73
+ appId?: string | undefined;
74
+ appSecret?: string | undefined;
75
+ allowFrom?: string[] | undefined;
76
+ groupAllowFrom?: string[] | undefined;
77
+ }, {
78
+ enabled?: boolean | undefined;
79
+ appId?: string | undefined;
80
+ appSecret?: string | undefined;
81
+ connectionMode?: "websocket" | undefined;
82
+ dmPolicy?: "open" | "pairing" | "allowlist" | undefined;
83
+ groupPolicy?: "open" | "allowlist" | "disabled" | undefined;
84
+ requireMention?: boolean | undefined;
85
+ allowFrom?: string[] | undefined;
86
+ groupAllowFrom?: string[] | undefined;
87
+ sendMarkdownAsCard?: boolean | undefined;
88
+ historyLimit?: number | undefined;
89
+ textChunkLimit?: number | undefined;
90
+ }>;
91
+ type FeishuConfig = undefined<typeof FeishuConfigSchema>;
92
+
93
+ /**
94
+ * 发送消息结果
95
+ */
96
+ interface FeishuSendResult {
97
+ /** 消息 ID */
98
+ messageId: string;
99
+ /** 会话 ID */
100
+ chatId: string;
101
+ }
102
+ /**
103
+ * 解析后的飞书账户配置
104
+ * 用于 ChannelPlugin config 适配器
105
+ */
106
+ interface ResolvedFeishuAccount {
107
+ /** 账户 ID */
108
+ accountId: string;
109
+ /** 是否启用 */
110
+ enabled: boolean;
111
+ /** 是否已配置(有凭证) */
112
+ configured: boolean;
113
+ /** 应用 ID */
114
+ appId?: string;
115
+ }
116
+
117
+ /**
118
+ * 飞书出站适配器
119
+ */
120
+
121
+ interface OutboundConfig {
122
+ channels?: {
123
+ feishu?: FeishuConfig;
124
+ };
125
+ }
126
+ interface SendResult {
127
+ channel: string;
128
+ messageId: string;
129
+ chatId?: string;
130
+ conversationId?: string;
131
+ }
132
+
133
+ /** 默认账户 ID */
134
+ declare const DEFAULT_ACCOUNT_ID = "default";
135
+ interface PluginConfig {
136
+ channels?: {
137
+ feishu?: FeishuConfig;
138
+ };
139
+ }
140
+ declare const feishuPlugin: {
141
+ id: string;
142
+ meta: {
143
+ id: "feishu";
144
+ label: "Feishu";
145
+ selectionLabel: "Feishu/Lark (飞书)";
146
+ docsPath: "/channels/feishu";
147
+ docsLabel: "feishu";
148
+ blurb: "飞书/Lark 企业消息";
149
+ aliases: readonly ["lark"];
150
+ order: 70;
151
+ };
152
+ capabilities: {
153
+ chatTypes: readonly ["direct", "channel"];
154
+ media: boolean;
155
+ reactions: boolean;
156
+ threads: boolean;
157
+ edit: boolean;
158
+ reply: boolean;
159
+ polls: boolean;
160
+ };
161
+ configSchema: {
162
+ schema: {
163
+ type: string;
164
+ additionalProperties: boolean;
165
+ properties: {
166
+ enabled: {
167
+ type: string;
168
+ };
169
+ appId: {
170
+ type: string;
171
+ };
172
+ appSecret: {
173
+ type: string;
174
+ };
175
+ connectionMode: {
176
+ type: string;
177
+ enum: string[];
178
+ };
179
+ dmPolicy: {
180
+ type: string;
181
+ enum: string[];
182
+ };
183
+ groupPolicy: {
184
+ type: string;
185
+ enum: string[];
186
+ };
187
+ requireMention: {
188
+ type: string;
189
+ };
190
+ allowFrom: {
191
+ type: string;
192
+ items: {
193
+ type: string;
194
+ };
195
+ };
196
+ groupAllowFrom: {
197
+ type: string;
198
+ items: {
199
+ type: string;
200
+ };
201
+ };
202
+ sendMarkdownAsCard: {
203
+ type: string;
204
+ };
205
+ historyLimit: {
206
+ type: string;
207
+ minimum: number;
208
+ };
209
+ textChunkLimit: {
210
+ type: string;
211
+ minimum: number;
212
+ };
213
+ };
214
+ };
215
+ };
216
+ reload: {
217
+ configPrefixes: string[];
218
+ };
219
+ config: {
220
+ listAccountIds: (_cfg: PluginConfig) => string[];
221
+ resolveAccount: (cfg: PluginConfig, accountId?: string) => ResolvedFeishuAccount;
222
+ defaultAccountId: () => string;
223
+ setAccountEnabled: (params: {
224
+ cfg: PluginConfig;
225
+ enabled: boolean;
226
+ }) => PluginConfig;
227
+ deleteAccount: (params: {
228
+ cfg: PluginConfig;
229
+ }) => PluginConfig;
230
+ isConfigured: (_account: ResolvedFeishuAccount, cfg: PluginConfig) => boolean;
231
+ describeAccount: (account: ResolvedFeishuAccount) => {
232
+ accountId: string;
233
+ enabled: boolean;
234
+ configured: boolean;
235
+ };
236
+ resolveAllowFrom: (params: {
237
+ cfg: PluginConfig;
238
+ }) => string[];
239
+ formatAllowFrom: (params: {
240
+ allowFrom: (string | number)[];
241
+ }) => string[];
242
+ };
243
+ security: {
244
+ collectWarnings: (params: {
245
+ cfg: PluginConfig;
246
+ }) => string[];
247
+ };
248
+ setup: {
249
+ resolveAccountId: () => string;
250
+ applyAccountConfig: (params: {
251
+ cfg: PluginConfig;
252
+ }) => PluginConfig;
253
+ };
254
+ outbound: {
255
+ deliveryMode: "direct";
256
+ textChunkLimit: number;
257
+ chunkerMode: "markdown";
258
+ chunker: (text: string, limit: number) => string[];
259
+ sendText: (params: {
260
+ cfg: OutboundConfig;
261
+ to: string;
262
+ text: string;
263
+ }) => Promise<SendResult>;
264
+ };
265
+ gateway: {
266
+ startAccount: (ctx: {
267
+ cfg: PluginConfig;
268
+ runtime?: unknown;
269
+ abortSignal?: AbortSignal;
270
+ accountId: string;
271
+ setStatus?: (status: Record<string, unknown>) => void;
272
+ log?: {
273
+ info: (msg: string) => void;
274
+ error: (msg: string) => void;
275
+ };
276
+ }) => Promise<void>;
277
+ stopAccount: (ctx: {
278
+ accountId: string;
279
+ }) => Promise<void>;
280
+ getStatus: () => {
281
+ connected: boolean;
282
+ };
283
+ };
284
+ };
285
+
286
+ /**
287
+ * 飞书发送消息
288
+ */
289
+
290
+ interface SendMessageParams {
291
+ cfg: FeishuConfig;
292
+ to: string;
293
+ text: string;
294
+ receiveIdType?: "chat_id" | "open_id";
295
+ }
296
+ declare function sendMessageFeishu(params: SendMessageParams): Promise<FeishuSendResult>;
297
+
298
+ /**
299
+ * 飞书插件运行时管理
300
+ *
301
+ * 提供对 Moltbot 核心运行时的访问。
302
+ */
303
+ /**
304
+ * Moltbot 插件运行时接口
305
+ */
306
+ interface PluginRuntime {
307
+ /** 日志函数 */
308
+ log?: (msg: string) => void;
309
+ /** 错误日志函数 */
310
+ error?: (msg: string) => void;
311
+ /** Moltbot 核心 API */
312
+ channel?: {
313
+ routing?: {
314
+ resolveAgentRoute?: (params: {
315
+ cfg: unknown;
316
+ channel: string;
317
+ peer: {
318
+ kind: string;
319
+ id: string;
320
+ };
321
+ }) => {
322
+ sessionKey: string;
323
+ accountId: string;
324
+ agentId?: string;
325
+ };
326
+ };
327
+ reply?: {
328
+ dispatchReplyFromConfig?: (params: {
329
+ ctx: unknown;
330
+ cfg: unknown;
331
+ dispatcher?: unknown;
332
+ replyOptions?: unknown;
333
+ }) => Promise<{
334
+ queuedFinal: boolean;
335
+ counts: {
336
+ final: number;
337
+ };
338
+ }>;
339
+ finalizeInboundContext?: (ctx: unknown) => unknown;
340
+ createReplyDispatcher?: (params: unknown) => unknown;
341
+ createReplyDispatcherWithTyping?: (params: unknown) => {
342
+ dispatcher: unknown;
343
+ replyOptions?: unknown;
344
+ markDispatchIdle?: () => void;
345
+ };
346
+ resolveHumanDelayConfig?: (cfg: unknown, agentId?: string) => unknown;
347
+ };
348
+ text?: {
349
+ resolveTextChunkLimit?: (params: {
350
+ cfg: unknown;
351
+ channel: string;
352
+ defaultLimit?: number;
353
+ }) => number;
354
+ resolveChunkMode?: (cfg: unknown, channel: string) => unknown;
355
+ chunkTextWithMode?: (text: string, limit: number, mode: unknown) => string[];
356
+ chunkMarkdownText?: (text: string, limit: number) => string[];
357
+ };
358
+ };
359
+ system?: {
360
+ enqueueSystemEvent?: (message: string, options?: unknown) => void;
361
+ };
362
+ [key: string]: unknown;
363
+ }
364
+ /**
365
+ * 设置飞书插件运行时
366
+ */
367
+ declare function setFeishuRuntime(next: PluginRuntime): void;
368
+ /**
369
+ * 获取飞书插件运行时
370
+ */
371
+ declare function getFeishuRuntime(): PluginRuntime;
372
+
373
+ /**
374
+ * @openclaw-china/feishu
375
+ * 飞书渠道插件入口
376
+ *
377
+ * 导出:
378
+ * - feishuPlugin: ChannelPlugin 实现
379
+ * - sendMessageFeishu: 发送消息函数
380
+ * - DEFAULT_ACCOUNT_ID: 默认账户 ID
381
+ */
382
+ /**
383
+ * Moltbot 插件 API 接口
384
+ *
385
+ * 包含:
386
+ * - registerChannel: 注册渠道插件
387
+ * - runtime: 完整的 Moltbot 运行时(包含 core API)
388
+ */
389
+ interface MoltbotPluginApi {
390
+ registerChannel: (opts: {
391
+ plugin: unknown;
392
+ }) => void;
393
+ /** Moltbot 运行时,包含 channel.routing、channel.reply 等核心 API */
394
+ runtime?: unknown;
395
+ [key: string]: unknown;
396
+ }
397
+
398
+ /**
399
+ * 飞书插件定义
400
+ *
401
+ * 包含:
402
+ * - id: 插件标识符
403
+ * - name: 插件名称
404
+ * - description: 插件描述
405
+ * - configSchema: 配置 JSON Schema
406
+ * - register: 注册函数,调用 api.registerChannel 并设置 runtime
407
+ */
408
+ declare const plugin: {
409
+ id: string;
410
+ name: string;
411
+ description: string;
412
+ configSchema: {
413
+ type: string;
414
+ additionalProperties: boolean;
415
+ properties: {
416
+ enabled: {
417
+ type: string;
418
+ };
419
+ appId: {
420
+ type: string;
421
+ };
422
+ appSecret: {
423
+ type: string;
424
+ };
425
+ connectionMode: {
426
+ type: string;
427
+ enum: string[];
428
+ };
429
+ dmPolicy: {
430
+ type: string;
431
+ enum: string[];
432
+ };
433
+ groupPolicy: {
434
+ type: string;
435
+ enum: string[];
436
+ };
437
+ requireMention: {
438
+ type: string;
439
+ };
440
+ allowFrom: {
441
+ type: string;
442
+ items: {
443
+ type: string;
444
+ };
445
+ };
446
+ groupAllowFrom: {
447
+ type: string;
448
+ items: {
449
+ type: string;
450
+ };
451
+ };
452
+ sendMarkdownAsCard: {
453
+ type: string;
454
+ };
455
+ historyLimit: {
456
+ type: string;
457
+ minimum: number;
458
+ };
459
+ textChunkLimit: {
460
+ type: string;
461
+ minimum: number;
462
+ };
463
+ };
464
+ };
465
+ /**
466
+ * 注册飞书渠道插件
467
+ *
468
+ * 1. 设置完整的 Moltbot 运行时(包含 core API)
469
+ * 2. 调用 api.registerChannel 将 feishuPlugin 注册到 Moltbot
470
+ */
471
+ register(api: MoltbotPluginApi): void;
472
+ };
473
+
474
+ export { DEFAULT_ACCOUNT_ID, type FeishuConfig, type FeishuSendResult, type MoltbotPluginApi, type ResolvedFeishuAccount, plugin as default, feishuPlugin, getFeishuRuntime, sendMessageFeishu, setFeishuRuntime };