// --------------- Core types & utilities ---------------
// --------------- Registry singleton ---------------
import { discord } from './discord/definition';
import { feishu } from './feishu/definitions/feishu';
import { lark } from './feishu/definitions/lark';
import { imessage } from './imessage/definition';
import { line } from './line/definition';
import { qq } from './qq/definition';
import { PlatformRegistry } from './registry';
import { slack } from './slack/definition';
import { telegram } from './telegram/definition';
import { wechat } from './wechat/definition';

export {
  allowFromField,
  type BotReplyLocale,
  displayToolCallsField,
  type DmDecision,
  type DmPolicy,
  type DmSettings,
  extractDmSettings,
  extractGroupSettings,
  extractUserAllowlist,
  extractWatchKeywordEntries,
  extractWatchKeywords,
  findMatchingWatchKeywordEntries,
  getBotReplyLocale,
  getStepReactionEmoji,
  type GroupPolicy,
  type GroupSettings,
  makeDmPolicyField,
  makeGroupPolicyFields,
  makeServerIdField,
  makeUserIdField,
  messageMatchesWatchKeyword,
  normalizeAllowFromEntries,
  normalizeBotReplyLocale,
  RECEIVED_REACTION_EMOJI,
  shouldAllowSender,
  shouldHandleDm,
  shouldHandleGroup,
  THINKING_REACTION_EMOJI,
  type UserAllowlist,
  validateAccessSettings,
  type WatchKeywordEntry,
  watchKeywordsField,
  WORKING_REACTION_EMOJI,
} from './const';
export { PlatformRegistry } from './registry';
export type {
  BotMessageAttachment,
  BotPlatformRedisClient,
  BotPlatformRuntimeContext,
  BotProviderConfig,
  ConnectionMode,
  ExtractFilesResult,
  FieldSchema,
  MessengerContent,
  PlatformClient,
  PlatformDefinition,
  PlatformDocumentation,
  PlatformMessenger,
  SerializedPlatformDefinition,
  UsageStats,
  ValidationResult,
} from './types';
export { ClientFactory, messengerContentText } from './types';
export type { ProviderConfigInput, ResolvedBotProviderConfig } from './utils';
export {
  buildRuntimeKey,
  extractDefaults,
  formatDuration,
  formatTokens,
  formatUsageStats,
  getEffectiveConnectionMode,
  mergeWithDefaults,
  parseRuntimeKey,
  resolveBotProviderConfig,
  resolveConnectionMode,
} from './utils';

// --------------- Platform definitions ---------------
export { discord } from './discord/definition';
export { feishu } from './feishu/definitions/feishu';
export { lark } from './feishu/definitions/lark';
export { imessage } from './imessage/definition';
export { line } from './line/definition';
export { qq } from './qq/definition';
export { slack } from './slack/definition';
export { telegram } from './telegram/definition';
export { wechat } from './wechat/definition';

export const platformRegistry = new PlatformRegistry();

platformRegistry.register(discord);
platformRegistry.register(telegram);
platformRegistry.register(slack);
platformRegistry.register(feishu);
platformRegistry.register(imessage);
platformRegistry.register(lark);
platformRegistry.register(qq);
platformRegistry.register(wechat);
platformRegistry.register(line);
