@ganglion/weacpx-channel-feishu 0.1.0-beta.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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @ganglion/weacpx-channel-feishu
2
+
3
+ Feishu channel plugin for `weacpx`.
4
+
5
+ ```bash
6
+ weacpx plugin add @ganglion/weacpx-channel-feishu
7
+ weacpx channel add feishu
8
+ weacpx restart
9
+ ```
10
+
11
+ The channel requires a Feishu self-built app `appId` and `appSecret`.
@@ -0,0 +1,31 @@
1
+ import type { ChannelStartInput, CoordinatorMessageInput, CreateChannelDeps, MessageChannelRuntime, OrchestrationDeliveryCallbacks } from "weacpx/plugin-api";
2
+ import type { FeishuResolvedAccountConfig } from "./config.js";
3
+ import { type FeishuLarkClient } from "./lark-client.js";
4
+ type OrchestrationTaskRecord = Parameters<MessageChannelRuntime["notifyTaskCompletion"]>[0];
5
+ interface FeishuChannelDeps extends CreateChannelDeps {
6
+ createClient?: (account: FeishuResolvedAccountConfig) => FeishuLarkClient;
7
+ }
8
+ export declare class FeishuChannel implements MessageChannelRuntime {
9
+ private readonly deps;
10
+ readonly id = "feishu";
11
+ private readonly accounts;
12
+ private dedup;
13
+ private markDelivered;
14
+ private markFailed;
15
+ private agent;
16
+ private quota;
17
+ private logger;
18
+ private readonly config;
19
+ constructor(options: Record<string, unknown> | undefined, deps?: FeishuChannelDeps);
20
+ isLoggedIn(): boolean;
21
+ login(): Promise<string>;
22
+ logout(): void;
23
+ configureOrchestration(callbacks: OrchestrationDeliveryCallbacks): void;
24
+ start(input: ChannelStartInput): Promise<void>;
25
+ notifyTaskCompletion(task: OrchestrationTaskRecord): Promise<void>;
26
+ notifyTaskProgress(task: OrchestrationTaskRecord, text: string): Promise<void>;
27
+ sendCoordinatorMessage(input: CoordinatorMessageInput): Promise<void>;
28
+ private sendRouteText;
29
+ private handleMessageEvent;
30
+ }
31
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare function buildFeishuQueueKey(accountId: string, chatId: string, threadId?: string): string;
2
+ export declare function enqueueFeishuChatTask(input: {
3
+ accountId: string;
4
+ chatId: string;
5
+ threadId?: string;
6
+ task: () => Promise<void>;
7
+ }): {
8
+ status: "queued" | "immediate";
9
+ promise: Promise<void>;
10
+ };
11
+ export declare function resetFeishuChatQueueForTests(): void;
@@ -0,0 +1,34 @@
1
+ export type FeishuDmPolicy = "open" | "allowlist" | "disabled";
2
+ export type FeishuGroupPolicy = "open" | "allowlist" | "disabled";
3
+ export interface FeishuAccountConfig {
4
+ name?: string;
5
+ enabled?: boolean;
6
+ appId?: string;
7
+ appSecret?: string;
8
+ domain?: string;
9
+ requireMention?: boolean;
10
+ dmPolicy?: FeishuDmPolicy;
11
+ groupPolicy?: FeishuGroupPolicy;
12
+ allowFrom?: string[];
13
+ }
14
+ export interface FeishuResolvedAccountConfig {
15
+ accountId: string;
16
+ name?: string;
17
+ enabled: boolean;
18
+ configured: boolean;
19
+ appId: string;
20
+ appSecret: string;
21
+ domain: string;
22
+ requireMention: boolean;
23
+ dmPolicy: FeishuDmPolicy;
24
+ groupPolicy: FeishuGroupPolicy;
25
+ allowFrom: string[];
26
+ }
27
+ export interface FeishuChannelConfig extends FeishuAccountConfig {
28
+ defaultAccount: string;
29
+ textMessageFormat: "text";
30
+ dedupTtlMs: number;
31
+ dedupMaxEntries: number;
32
+ accounts: FeishuResolvedAccountConfig[];
33
+ }
34
+ export declare function parseFeishuChannelConfig(raw: unknown): FeishuChannelConfig;
@@ -0,0 +1,11 @@
1
+ import type { FeishuMessageEvent, FeishuContentConversionResult } from "./types";
2
+ interface ConvertInput {
3
+ messageType: string;
4
+ content: string;
5
+ messageId: string;
6
+ mentions?: FeishuMessageEvent["message"]["mentions"];
7
+ botOpenId?: string;
8
+ stripBotMentions?: boolean;
9
+ }
10
+ export declare function convertFeishuMessageContent(input: ConvertInput): Promise<FeishuContentConversionResult>;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type ChannelCliProvider } from "./provider.js";
2
+ export declare const feishuCliProvider: ChannelCliProvider;
@@ -0,0 +1,32 @@
1
+ import type { FeishuMessageEvent } from "./types.js";
2
+ import type { FeishuResolvedAccountConfig } from "./config.js";
3
+ export declare function parseFeishuText(raw: string): string;
4
+ export declare function buildFeishuConversationId(accountId: string, chatId: string, threadId?: string): string;
5
+ export declare function parseFeishuConversationId(chatKey: string): {
6
+ accountId: string;
7
+ chatId: string;
8
+ threadId?: string;
9
+ } | null;
10
+ export declare function shouldHandleFeishuMessage(input: {
11
+ event: FeishuMessageEvent;
12
+ botOpenId?: string;
13
+ requireMention: boolean;
14
+ parsedText?: string;
15
+ allowMediaOnly?: boolean;
16
+ }): {
17
+ handle: true;
18
+ text: string;
19
+ } | {
20
+ handle: false;
21
+ reason: "no_mention" | "unsupported_type";
22
+ };
23
+ export type FeishuPolicyDecision = {
24
+ allow: true;
25
+ } | {
26
+ allow: false;
27
+ reason: "dm_disabled" | "group_disabled" | "sender_not_allowlisted" | "missing_sender_id";
28
+ };
29
+ export declare function evaluateFeishuAccessPolicy(input: {
30
+ event: FeishuMessageEvent;
31
+ account: Pick<FeishuResolvedAccountConfig, "dmPolicy" | "groupPolicy" | "allowFrom">;
32
+ }): FeishuPolicyDecision;
@@ -0,0 +1,5 @@
1
+ import type { WeacpxPlugin } from "weacpx/plugin-api";
2
+ export { FeishuChannel } from "./channel.js";
3
+ export { feishuCliProvider } from "./feishu-provider.js";
4
+ declare const plugin: WeacpxPlugin;
5
+ export default plugin;