@aigne/afs-lark 1.11.0-beta.12

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/LICENSE.md ADDED
@@ -0,0 +1,26 @@
1
+ # Proprietary License
2
+
3
+ Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
4
+
5
+ This software and associated documentation files (the "Software") are proprietary
6
+ and confidential. Unauthorized copying, modification, distribution, or use of
7
+ this Software, via any medium, is strictly prohibited.
8
+
9
+ The Software is provided for internal use only within ArcBlock, Inc. and its
10
+ authorized affiliates.
11
+
12
+ ## No License Granted
13
+
14
+ No license, express or implied, is granted to any party for any purpose.
15
+ All rights are reserved by ArcBlock, Inc.
16
+
17
+ ## Public Artifact Distribution
18
+
19
+ Portions of this Software may be released publicly under separate open-source
20
+ licenses (such as MIT License) through designated public repositories. Such
21
+ public releases are governed by their respective licenses and do not affect
22
+ the proprietary nature of this repository.
23
+
24
+ ## Contact
25
+
26
+ For licensing inquiries, contact: legal@arcblock.io
package/dist/index.cjs ADDED
@@ -0,0 +1,468 @@
1
+ let _aigne_afs_provider = require("@aigne/afs/provider");
2
+ let _aigne_afs_messaging = require("@aigne/afs-messaging");
3
+
4
+ //#region src/client.ts
5
+ /**
6
+ * LarkClient — pure Lark (Feishu) API wrapper.
7
+ *
8
+ * Two modes:
9
+ * - Webhook: outbound-only, POST to Incoming Webhook URL
10
+ * - Bot: bidirectional, send via App Bot API with tenant_access_token
11
+ *
12
+ * Zero external dependencies (uses native fetch).
13
+ * No AFS or application-specific concepts.
14
+ */
15
+ const DEFAULT_API_BASE = "https://open.feishu.cn/open-apis";
16
+ const DEFAULT_TIMEOUT = 3e4;
17
+ /** 5-minute buffer before token expiry to trigger refresh */
18
+ const TOKEN_REFRESH_BUFFER_MS = 3e5;
19
+ var LarkClient = class LarkClient {
20
+ mode;
21
+ _webhookUrl;
22
+ _appId;
23
+ _appSecret;
24
+ _apiBase;
25
+ _timeout;
26
+ _tenantAccessToken = null;
27
+ _tokenExpiresAt = 0;
28
+ constructor(opts) {
29
+ this.mode = opts.mode;
30
+ this._webhookUrl = opts.webhookUrl ?? null;
31
+ this._appId = opts.appId ?? null;
32
+ this._appSecret = opts.appSecret ?? null;
33
+ this._apiBase = opts.apiBase ?? DEFAULT_API_BASE;
34
+ this._timeout = opts.timeout ?? DEFAULT_TIMEOUT;
35
+ }
36
+ static webhook(url, options) {
37
+ if (!url) throw new Error("LarkClient.webhook requires a webhook URL");
38
+ let parsed;
39
+ try {
40
+ parsed = new URL(url);
41
+ } catch {
42
+ throw new Error("LarkClient.webhook: invalid webhook URL");
43
+ }
44
+ const isLocal = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
45
+ if (parsed.protocol !== "https:" && !isLocal) throw new Error("LarkClient.webhook: webhook URL must use HTTPS (or localhost for testing)");
46
+ return new LarkClient({
47
+ mode: "webhook",
48
+ webhookUrl: url,
49
+ timeout: options?.timeout
50
+ });
51
+ }
52
+ static bot(options) {
53
+ if (!options.appId) throw new Error("LarkClient.bot requires an appId");
54
+ if (!options.appSecret) throw new Error("LarkClient.bot requires an appSecret");
55
+ return new LarkClient({
56
+ mode: "bot",
57
+ appId: options.appId,
58
+ appSecret: options.appSecret,
59
+ apiBase: options.apiBase,
60
+ timeout: options.timeout
61
+ });
62
+ }
63
+ async sendWebhook(text) {
64
+ if (!this._webhookUrl) throw new Error("sendWebhook requires webhook mode");
65
+ const payload = {
66
+ msg_type: "text",
67
+ content: { text }
68
+ };
69
+ const response = await fetch(this._webhookUrl, {
70
+ method: "POST",
71
+ headers: { "Content-Type": "application/json" },
72
+ body: JSON.stringify(payload),
73
+ signal: AbortSignal.timeout(this._timeout)
74
+ });
75
+ if (!response.ok) {
76
+ const desc = await response.text().catch(() => "");
77
+ throw new Error(`Lark webhook error ${response.status}: ${desc}`);
78
+ }
79
+ }
80
+ async sendMessage(chatId, text, options) {
81
+ await this._ensureToken();
82
+ const body = {
83
+ receive_id: chatId,
84
+ content: JSON.stringify({ text }),
85
+ msg_type: "text"
86
+ };
87
+ if (options?.replyTo) body.reply_in_thread = true;
88
+ const response = await fetch(`${this._apiBase}/im/v1/messages?receive_id_type=chat_id`, {
89
+ method: "POST",
90
+ headers: {
91
+ "Content-Type": "application/json",
92
+ Authorization: `Bearer ${this._tenantAccessToken}`
93
+ },
94
+ body: JSON.stringify(body),
95
+ signal: AbortSignal.timeout(this._timeout)
96
+ });
97
+ if (!response.ok) {
98
+ const desc = await response.text().catch(() => "");
99
+ const safeDesc = this._appSecret ? desc.replace(this._appSecret, "***") : desc;
100
+ throw new Error(`Lark API error ${response.status}: ${safeDesc}`);
101
+ }
102
+ const data = await response.json();
103
+ if (data.code !== 0) throw new Error(`Lark API error: ${data.msg} (code ${data.code})`);
104
+ return { messageId: data.data?.message_id ?? "" };
105
+ }
106
+ static parseEvent(payload) {
107
+ if (!payload) return null;
108
+ if (payload.type === "url_verification" && payload.challenge) return {
109
+ type: "url_verification",
110
+ challenge: payload.challenge
111
+ };
112
+ const header = payload.header ?? payload.schema;
113
+ const event = payload.event;
114
+ if (!event) return null;
115
+ if ((header?.event_type ?? payload.event_type) !== "im.message.receive_v1") return null;
116
+ const message = event.message;
117
+ if (!message) return null;
118
+ const messageId = message.message_id ?? "";
119
+ const chatId = message.chat_id ?? "";
120
+ const messageType = message.message_type ?? "text";
121
+ let content = "";
122
+ try {
123
+ content = JSON.parse(message.content ?? "{}").text ?? "";
124
+ } catch {
125
+ content = String(message.content ?? "");
126
+ }
127
+ const sender = event.sender ?? {};
128
+ const senderId = sender.sender_id?.open_id ?? sender.sender_id?.user_id ?? "";
129
+ const senderType = sender.sender_type ?? "user";
130
+ if (!content.trim() || !senderId) return null;
131
+ return {
132
+ type: "message",
133
+ messageId,
134
+ chatId,
135
+ messageType,
136
+ content: content.trim(),
137
+ senderId,
138
+ senderType
139
+ };
140
+ }
141
+ /** Ensure we have a valid tenant access token, refreshing if needed. */
142
+ async _ensureToken() {
143
+ if (this._tenantAccessToken && Date.now() < this._tokenExpiresAt - TOKEN_REFRESH_BUFFER_MS) return;
144
+ if (!this._appId || !this._appSecret) throw new Error("Token refresh requires bot mode (appId + appSecret)");
145
+ const response = await fetch(`${this._apiBase}/auth/v3/tenant_access_token/internal`, {
146
+ method: "POST",
147
+ headers: { "Content-Type": "application/json" },
148
+ body: JSON.stringify({
149
+ app_id: this._appId,
150
+ app_secret: this._appSecret
151
+ }),
152
+ signal: AbortSignal.timeout(this._timeout)
153
+ });
154
+ if (!response.ok) {
155
+ const desc = await response.text().catch(() => "");
156
+ throw new Error(`Lark token refresh error ${response.status}: ${desc}`);
157
+ }
158
+ const data = await response.json();
159
+ if (data.code !== 0 || !data.tenant_access_token) throw new Error(`Lark token refresh failed: ${data.msg} (code ${data.code})`);
160
+ this._tenantAccessToken = data.tenant_access_token;
161
+ this._tokenExpiresAt = Date.now() + (data.expire ?? 7200) * 1e3;
162
+ }
163
+ static escapeMarkdown(text) {
164
+ return text.replace(/([*_~`|\\])/g, "\\$1");
165
+ }
166
+ };
167
+
168
+ //#endregion
169
+ //#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
170
+ function __decorate(decorators, target, key, desc) {
171
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
172
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
173
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
174
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
175
+ }
176
+
177
+ //#endregion
178
+ //#region src/index.ts
179
+ var AFSLark = class extends _aigne_afs_messaging.BaseMessageProvider {
180
+ static manifest() {
181
+ return {
182
+ name: "lark",
183
+ description: "Lark/Feishu (飞书) messaging — webhook or bot API with auto token refresh.\n- Webhook mode for simple outbound notifications\n- Bot mode with app credentials for bidirectional messaging\n- Path: /:bot/conversations/:chatId/messages/:msgId",
184
+ uriTemplate: "lark://{appId}",
185
+ category: "messaging",
186
+ schema: {
187
+ type: "object",
188
+ properties: {
189
+ appId: {
190
+ type: "string",
191
+ description: "Lark App ID"
192
+ },
193
+ appSecret: {
194
+ type: "string",
195
+ description: "Lark App Secret",
196
+ sensitive: true
197
+ },
198
+ webhook: {
199
+ type: "string",
200
+ description: "Webhook URL for outbound-only mode",
201
+ sensitive: true
202
+ },
203
+ chatIds: {
204
+ type: "array",
205
+ items: { type: "string" },
206
+ description: "Chat IDs to monitor"
207
+ }
208
+ }
209
+ },
210
+ tags: [
211
+ "lark",
212
+ "feishu",
213
+ "messaging",
214
+ "chat",
215
+ "enterprise"
216
+ ],
217
+ capabilityTags: [
218
+ "read-write",
219
+ "crud",
220
+ "search",
221
+ "auth:token",
222
+ "remote",
223
+ "http",
224
+ "real-time",
225
+ "rate-limited"
226
+ ],
227
+ security: {
228
+ riskLevel: "external",
229
+ resourceAccess: ["internet"],
230
+ notes: ["Connects to Lark/Feishu API — requires app credentials or webhook URL"]
231
+ },
232
+ capabilities: { network: {
233
+ egress: true,
234
+ allowedDomains: ["open.feishu.cn", "open.larksuite.com"]
235
+ } }
236
+ };
237
+ }
238
+ static treeSchema() {
239
+ return {
240
+ operations: [
241
+ "list",
242
+ "read",
243
+ "exec",
244
+ "stat",
245
+ "explain"
246
+ ],
247
+ tree: {
248
+ "/": {
249
+ kind: "messaging:root",
250
+ operations: ["list", "exec"],
251
+ actions: [
252
+ "add-bot",
253
+ "remove-bot",
254
+ "process-event"
255
+ ]
256
+ },
257
+ "/{bot}": {
258
+ kind: "messaging:bot",
259
+ operations: ["list", "read"]
260
+ },
261
+ "/{bot}/ctl": {
262
+ kind: "messaging:status",
263
+ operations: ["read"]
264
+ },
265
+ "/{bot}/conversations": {
266
+ kind: "messaging:conversations",
267
+ operations: ["list"]
268
+ },
269
+ "/{bot}/conversations/{convId}": {
270
+ kind: "messaging:conversation",
271
+ operations: ["list"]
272
+ },
273
+ "/{bot}/conversations/{convId}/messages": {
274
+ kind: "messaging:messages",
275
+ operations: ["list", "exec"],
276
+ actions: ["send"]
277
+ },
278
+ "/{bot}/conversations/{convId}/messages/{msgId}": {
279
+ kind: "messaging:message",
280
+ operations: ["read"]
281
+ }
282
+ },
283
+ auth: {
284
+ type: "custom",
285
+ env: ["LARK_APP_ID", "LARK_APP_SECRET"]
286
+ },
287
+ bestFor: [
288
+ "enterprise messaging",
289
+ "workflow alerts",
290
+ "team collaboration"
291
+ ],
292
+ notFor: ["file storage", "database queries"]
293
+ };
294
+ }
295
+ providerName = "lark";
296
+ eventPrefix = "lark";
297
+ constructor(options) {
298
+ let bots;
299
+ if (options.bots) bots = options.bots.map((b) => ({
300
+ ...b,
301
+ conversations: b.chatIds
302
+ }));
303
+ else {
304
+ if (!options.appId && !options.webhook) throw new Error("AFSLark requires either appId+appSecret or webhook");
305
+ bots = [{
306
+ name: "default",
307
+ appId: options.appId,
308
+ appSecret: options.appSecret,
309
+ webhook: options.webhook,
310
+ conversations: options.chatIds ?? [],
311
+ apiBase: options.apiBase
312
+ }];
313
+ }
314
+ super({
315
+ bots,
316
+ bufferSize: options.bufferSize
317
+ });
318
+ }
319
+ getMessageCapabilities() {
320
+ return {
321
+ formats: {
322
+ send: ["text", "markdown"],
323
+ receive: ["text"]
324
+ },
325
+ maxMessageLength: 4096,
326
+ features: {
327
+ edit: false,
328
+ delete: false,
329
+ reply: true,
330
+ thread: true,
331
+ reaction: true,
332
+ inlineKeyboard: true
333
+ },
334
+ limits: { messagesPerSecond: 5 }
335
+ };
336
+ }
337
+ createBotClient(config) {
338
+ const appId = config.appId;
339
+ const appSecret = config.appSecret;
340
+ const webhook = config.webhook;
341
+ const apiBase = config.apiBase;
342
+ if (appId && appSecret) return LarkClient.bot({
343
+ appId,
344
+ appSecret,
345
+ apiBase
346
+ });
347
+ if (webhook) return LarkClient.webhook(webhook);
348
+ throw new Error(`Lark bot "${config.name}" requires appId+appSecret or webhook`);
349
+ }
350
+ async sendMessage(client, convId, text, _opts) {
351
+ const lc = client;
352
+ if (lc.mode === "bot") return lc.sendMessage(convId, text);
353
+ await lc.sendWebhook(text);
354
+ return { messageId: String(Date.now()) };
355
+ }
356
+ async sendTypingIndicator(_client, _convId) {}
357
+ normalizeMessage(raw) {
358
+ const msg = raw;
359
+ let text = "";
360
+ if (typeof msg.content === "string") try {
361
+ text = JSON.parse(msg.content).text ?? "";
362
+ } catch {
363
+ text = msg.content;
364
+ }
365
+ else text = String(msg.content ?? msg.text ?? "");
366
+ return {
367
+ id: String(msg.message_id ?? msg.messageId ?? "0"),
368
+ text,
369
+ from: this.normalizeSender(msg.sender ?? {}),
370
+ timestamp: Math.floor(Date.now() / 1e3),
371
+ conversationId: String(msg.chat_id ?? msg.chatId ?? ""),
372
+ platform: { message_type: msg.message_type ?? msg.messageType }
373
+ };
374
+ }
375
+ normalizeSender(raw) {
376
+ const senderId = raw.sender_id;
377
+ return {
378
+ id: String(senderId?.open_id ?? raw.open_id ?? raw.id ?? "0"),
379
+ name: String(raw.name ?? raw.sender_type ?? ""),
380
+ isBot: raw.sender_type === "app" ? true : void 0
381
+ };
382
+ }
383
+ async listRootActions(_ctx) {
384
+ return { data: [
385
+ this.buildEntry("/.actions/add-bot", { meta: { description: "Add a bot instance at runtime" } }),
386
+ this.buildEntry("/.actions/remove-bot", { meta: { description: "Remove a bot instance" } }),
387
+ this.buildEntry("/.actions/process-event", { meta: { description: "Process an incoming Lark event callback payload" } })
388
+ ] };
389
+ }
390
+ async execProcessEvent(_ctx, args) {
391
+ return {
392
+ success: true,
393
+ data: this._processEvent(args) ?? { ok: true }
394
+ };
395
+ }
396
+ /** Process a Lark event callback payload. Returns challenge response for url_verification. */
397
+ _processEvent(payload) {
398
+ const parsed = LarkClient.parseEvent(payload);
399
+ if (!parsed) return { ok: true };
400
+ if (parsed.type === "url_verification") return { challenge: parsed.challenge };
401
+ if (parsed.senderType === "app") return { ok: true };
402
+ const botName = this._botOrder[0] ?? "default";
403
+ this.emitMessageReceived(botName, {
404
+ id: parsed.messageId,
405
+ text: parsed.content,
406
+ from: {
407
+ id: parsed.senderId,
408
+ name: parsed.senderType
409
+ },
410
+ timestamp: Math.floor(Date.now() / 1e3),
411
+ conversationId: parsed.chatId,
412
+ platform: { message_type: parsed.messageType }
413
+ });
414
+ return { ok: true };
415
+ }
416
+ /** Add a chat to a bot. Defaults to first bot. */
417
+ addChat(chatId, botName) {
418
+ const name = botName ?? this._botOrder[0];
419
+ if (!name) return;
420
+ const convs = this._botConversations.get(name);
421
+ if (!convs || convs.has(chatId)) return;
422
+ convs.add(chatId);
423
+ const buffers = this._botBuffers.get(name);
424
+ if (buffers && !buffers.has(chatId)) buffers.set(chatId, []);
425
+ }
426
+ /** Remove a chat from a bot. */
427
+ removeChat(chatId, botName) {
428
+ const name = botName ?? this._botOrder[0];
429
+ if (!name) return;
430
+ const convs = this._botConversations.get(name);
431
+ if (convs) convs.delete(chatId);
432
+ const buffers = this._botBuffers.get(name);
433
+ if (buffers) buffers.delete(chatId);
434
+ }
435
+ /** Add a message to the ring buffer directly. Public for testing/conformance. */
436
+ _addToBuffer(chatId, msg) {
437
+ const botName = this._botOrder[0] ?? "default";
438
+ const convs = this._botConversations.get(botName);
439
+ if (convs && !convs.has(chatId)) convs.add(chatId);
440
+ let botBuffers = this._botBuffers.get(botName);
441
+ if (!botBuffers) {
442
+ botBuffers = /* @__PURE__ */ new Map();
443
+ this._botBuffers.set(botName, botBuffers);
444
+ }
445
+ let buffer = botBuffers.get(chatId);
446
+ if (!buffer) {
447
+ buffer = [];
448
+ botBuffers.set(chatId, buffer);
449
+ }
450
+ buffer.push({
451
+ id: msg.messageId,
452
+ text: msg.content,
453
+ from: {
454
+ id: msg.senderId,
455
+ name: msg.senderName ?? msg.senderId
456
+ },
457
+ timestamp: Math.floor(Date.now() / 1e3),
458
+ conversationId: chatId,
459
+ platform: {}
460
+ });
461
+ while (buffer.length > this._bufferSize) buffer.shift();
462
+ }
463
+ };
464
+ __decorate([(0, _aigne_afs_provider.Actions)("/")], AFSLark.prototype, "listRootActions", null);
465
+ __decorate([_aigne_afs_provider.Actions.Exec("/", "process-event")], AFSLark.prototype, "execProcessEvent", null);
466
+
467
+ //#endregion
468
+ exports.AFSLark = AFSLark;
@@ -0,0 +1,166 @@
1
+ import { AFSExecResult, AFSListResult, ProviderTreeSchema } from "@aigne/afs";
2
+ import { RouteContext } from "@aigne/afs/provider";
3
+ import { BaseMessageProvider, BotConfig, BufferedMessage, MessageCapabilities, MessageSender, SendOptions } from "@aigne/afs-messaging";
4
+
5
+ //#region src/client.d.ts
6
+ /**
7
+ * LarkClient — pure Lark (Feishu) API wrapper.
8
+ *
9
+ * Two modes:
10
+ * - Webhook: outbound-only, POST to Incoming Webhook URL
11
+ * - Bot: bidirectional, send via App Bot API with tenant_access_token
12
+ *
13
+ * Zero external dependencies (uses native fetch).
14
+ * No AFS or application-specific concepts.
15
+ */
16
+ interface LarkBotOptions {
17
+ appId: string;
18
+ appSecret: string;
19
+ apiBase?: string;
20
+ timeout?: number;
21
+ }
22
+ interface SendMessageOptions {
23
+ /** Reply to a specific message */
24
+ replyTo?: string;
25
+ }
26
+ /** Parsed Lark event callback. */
27
+ type LarkParsedEvent = {
28
+ type: "url_verification";
29
+ challenge: string;
30
+ } | {
31
+ type: "message";
32
+ messageId: string;
33
+ chatId: string;
34
+ messageType: string;
35
+ content: string;
36
+ senderId: string;
37
+ senderType: string;
38
+ } | null;
39
+ declare class LarkClient {
40
+ readonly mode: "webhook" | "bot";
41
+ private readonly _webhookUrl;
42
+ private readonly _appId;
43
+ private readonly _appSecret;
44
+ private readonly _apiBase;
45
+ private readonly _timeout;
46
+ private _tenantAccessToken;
47
+ private _tokenExpiresAt;
48
+ private constructor();
49
+ static webhook(url: string, options?: {
50
+ timeout?: number;
51
+ }): LarkClient;
52
+ static bot(options: LarkBotOptions): LarkClient;
53
+ sendWebhook(text: string): Promise<void>;
54
+ sendMessage(chatId: string, text: string, options?: SendMessageOptions): Promise<{
55
+ messageId: string;
56
+ }>;
57
+ static parseEvent(payload: any): LarkParsedEvent;
58
+ /** Ensure we have a valid tenant access token, refreshing if needed. */
59
+ private _ensureToken;
60
+ static escapeMarkdown(text: string): string;
61
+ }
62
+ //#endregion
63
+ //#region src/index.d.ts
64
+ interface AFSLarkOptions {
65
+ /** Multi-bot config */
66
+ bots?: Array<{
67
+ name: string;
68
+ appId?: string;
69
+ appSecret?: string;
70
+ webhook?: string;
71
+ chatIds?: string[];
72
+ apiBase?: string;
73
+ }>;
74
+ /** Single-bot shorthand: webhook URL (outbound only) */
75
+ webhook?: string;
76
+ /** Single-bot shorthand: app ID */
77
+ appId?: string;
78
+ /** Single-bot shorthand: app secret */
79
+ appSecret?: string;
80
+ /** Single-bot shorthand: chat IDs to monitor */
81
+ chatIds?: string[];
82
+ apiBase?: string;
83
+ bufferSize?: number;
84
+ }
85
+ declare class AFSLark extends BaseMessageProvider {
86
+ static manifest(): {
87
+ name: string;
88
+ description: string;
89
+ uriTemplate: string;
90
+ category: string;
91
+ schema: {
92
+ type: string;
93
+ properties: {
94
+ appId: {
95
+ type: string;
96
+ description: string;
97
+ };
98
+ appSecret: {
99
+ type: string;
100
+ description: string;
101
+ sensitive: boolean;
102
+ };
103
+ webhook: {
104
+ type: string;
105
+ description: string;
106
+ sensitive: boolean;
107
+ };
108
+ chatIds: {
109
+ type: string;
110
+ items: {
111
+ type: string;
112
+ };
113
+ description: string;
114
+ };
115
+ };
116
+ };
117
+ tags: string[];
118
+ capabilityTags: string[];
119
+ security: {
120
+ riskLevel: string;
121
+ resourceAccess: string[];
122
+ notes: string[];
123
+ };
124
+ capabilities: {
125
+ network: {
126
+ egress: boolean;
127
+ allowedDomains: string[];
128
+ };
129
+ };
130
+ };
131
+ static treeSchema(): ProviderTreeSchema;
132
+ readonly providerName = "lark";
133
+ readonly eventPrefix = "lark";
134
+ constructor(options: AFSLarkOptions);
135
+ getMessageCapabilities(): MessageCapabilities;
136
+ createBotClient(config: BotConfig): LarkClient;
137
+ sendMessage(client: unknown, convId: string, text: string, _opts?: SendOptions): Promise<{
138
+ messageId: string;
139
+ }>;
140
+ sendTypingIndicator(_client: unknown, _convId: string): Promise<void>;
141
+ normalizeMessage(raw: Record<string, unknown>): BufferedMessage;
142
+ normalizeSender(raw: Record<string, unknown>): MessageSender;
143
+ listRootActions(_ctx: RouteContext): Promise<AFSListResult>;
144
+ execProcessEvent(_ctx: RouteContext, args: Record<string, unknown>): Promise<AFSExecResult>;
145
+ /** Process a Lark event callback payload. Returns challenge response for url_verification. */
146
+ _processEvent(payload: any): {
147
+ ok: true;
148
+ } | {
149
+ challenge: string;
150
+ };
151
+ /** Add a chat to a bot. Defaults to first bot. */
152
+ addChat(chatId: string, botName?: string): void;
153
+ /** Remove a chat from a bot. */
154
+ removeChat(chatId: string, botName?: string): void;
155
+ /** Add a message to the ring buffer directly. Public for testing/conformance. */
156
+ _addToBuffer(chatId: string, msg: {
157
+ messageId: string;
158
+ content: string;
159
+ chatId?: string;
160
+ senderId: string;
161
+ senderName?: string;
162
+ }): void;
163
+ }
164
+ //#endregion
165
+ export { AFSLark, AFSLarkOptions, type LarkClient, type LarkParsedEvent };
166
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/client.ts","../src/index.ts"],"mappings":";;;;;;;;;;AAiBA;;;;;UAAiB,cAAA;EACf,KAAA;EACA,SAAA;EACA,OAAA;EACA,OAAA;AAAA;AAAA,UAGe,kBAAA;;EAEf,OAAA;AAAA;AAIF;AAAA,KAAY,eAAA;EACN,IAAA;EAA0B,SAAA;AAAA;EAE1B,IAAA;EACA,SAAA;EACA,MAAA;EACA,WAAA;EACA,OAAA;EACA,QAAA;EACA,UAAA;AAAA;AAAA,cAIO,UAAA;EAAA,SACF,IAAA;EAAA,iBACQ,WAAA;EAAA,iBACA,MAAA;EAAA,iBACA,UAAA;EAAA,iBACA,QAAA;EAAA,iBACA,QA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