import { type NormalizedMessage } from "@larksuiteoapi/node-sdk";
import type { Db } from "@rudderhq/db";
import type { AgentIntegrationProviderRegion } from "@rudderhq/shared";
import type { StorageService } from "../../../storage/types.js";
import { chatAssistantService } from "../../chat-assistant.js";
import { type AgentIntegrationInboundDispatchResult } from "./inbound-dispatcher.js";
interface FeishuCredential {
    appId?: string | null;
    appSecret?: string | null;
    verificationToken?: string | null;
    encryptKey?: string | null;
    tenantAccessToken?: string | null;
    websocketUrl?: string | null;
}
export interface FeishuRuntimeIntegration {
    id: string;
    orgId: string;
    agentId: string;
    providerRegion: AgentIntegrationProviderRegion;
    appCredentialSecretId: string;
    externalAppId: string;
    externalBotOpenId: string | null;
}
export interface FeishuOutboundSender {
    sendText(input: {
        region: AgentIntegrationProviderRegion;
        appId: string;
        appSecret?: string | null;
        tenantAccessToken?: string | null;
        chatId: string;
        text: string;
    }): Promise<{
        messageId: string | null;
    }>;
    addReaction?(input: {
        region: AgentIntegrationProviderRegion;
        appId: string;
        appSecret?: string | null;
        tenantAccessToken?: string | null;
        messageId: string;
        emojiType: string;
    }): Promise<{
        reactionId: string | null;
    }>;
    removeReaction?(input: {
        region: AgentIntegrationProviderRegion;
        appId: string;
        appSecret?: string | null;
        tenantAccessToken?: string | null;
        messageId: string;
        reactionId: string;
    }): Promise<void>;
}
export interface FeishuLongConnectionClient {
    start(input: {
        integration: FeishuRuntimeIntegration;
        credential: FeishuCredential;
        onEvent: (payload: Record<string, unknown>) => Promise<void>;
    }): Promise<{
        stop: () => Promise<void> | void;
    }>;
}
export interface FeishuIntegrationRuntime {
    handleEvent: (integration: FeishuRuntimeIntegration, credential: FeishuCredential, payload: Record<string, unknown>) => Promise<AgentIntegrationInboundDispatchResult>;
    start(): Promise<{
        started: number;
    }>;
    isRunning(integrationId: string): boolean;
    stopIntegration(integrationId: string): Promise<boolean>;
    stop(): Promise<void>;
    sendPendingForRuns(runIds: string[]): Promise<number>;
}
type FeishuAssistantRunner = Pick<ReturnType<typeof chatAssistantService>, "streamChatAssistantReply">;
export declare function parseFeishuCredential(value: string): FeishuCredential;
export declare function createFeishuRestOutboundSender(): FeishuOutboundSender;
export declare function feishuRuntimePayloadFromNormalizedMessage(msg: NormalizedMessage, integration: FeishuRuntimeIntegration): Record<string, unknown>;
export declare function dispatchFeishuNormalizedMessage(input: {
    msg: NormalizedMessage;
    integration: FeishuRuntimeIntegration;
    onEvent: (payload: Record<string, unknown>) => Promise<void>;
}): Promise<boolean>;
export declare function createFeishuLongConnectionClient(): FeishuLongConnectionClient;
export declare function createDisabledFeishuLongConnectionClient(): FeishuLongConnectionClient;
export declare function feishuIntegrationRuntimeService(db: Db, options?: {
    storage?: StorageService;
    sender?: FeishuOutboundSender;
    client?: FeishuLongConnectionClient;
    assistant?: FeishuAssistantRunner;
}): FeishuIntegrationRuntime;
export {};
//# sourceMappingURL=runtime.d.ts.map