import { r as KlawConfig } from "./types.klaw-xKUw_Rz7.js"; import { n as GetReplyOptions, s as ReplyPayload } from "./get-reply-options.types-CS-CA1Iq.js"; import { n as InboundEventKind } from "./input-provenance-Cx2sX495.js"; import { r as GroupKeyResolution } from "./types-XfK0DXQJ.js"; import { a as CommandTurnKind, n as MsgContext, t as FinalizedMsgContext } from "./templating-B8JLQEN3.js"; import { n as HistoryMediaEntry, t as HistoryEntry } from "./history.types-DnjBpMO9.js"; import { N as MessageReceipt } from "./types-CPrjYzuc.js"; import { t as ReplyDispatchKind } from "./reply-dispatcher.types-DrTstzbu.js"; import { n as RecordInboundSession, t as InboundLastRouteUpdate } from "./session.types-BxIs5pjf.js"; import { r as GetReplyFromConfig, t as DispatchFromConfigResult } from "./dispatch-from-config.types-C7798lTY.js"; import { n as CreateChannelReplyPipelineParams } from "./reply-pipeline-BJbW2NFd.js"; import { i as ReplyDispatcherWithTypingOptions, t as DispatchReplyWithBufferedBlockDispatcher } from "./provider-dispatcher.types-Ddx7dYu6.js"; import { a as OutboundDeliveryQueuePolicy, r as DurableFinalDeliveryRequirements, t as DeliverOutboundPayloadsParams } from "./deliver-CwujvoXi.js"; import { a as PairLoopGuardResult, i as PairLoopGuardConfig, s as PairLoopGuardSnapshotEntry } from "./pair-loop-guard-runtime-BSEFhtA7.js"; //#region src/channels/turn/bot-loop-protection.d.ts type ChannelBotLoopProtectionFacts = { scopeId: string; conversationId: string; senderId: string; receiverId: string; config?: PairLoopGuardConfig; defaultsConfig?: PairLoopGuardConfig; defaultEnabled: boolean; nowMs?: number; }; declare function recordChannelBotPairLoopAndCheckSuppression(params: ChannelBotLoopProtectionFacts): PairLoopGuardResult; declare function clearChannelBotPairLoopGuardForTests(): void; declare function listTrackedChannelBotPairsForTests(): PairLoopGuardSnapshotEntry[]; //#endregion //#region src/channels/turn/types.d.ts type ChannelTurnAdmission = { kind: "dispatch"; reason?: string; } | { kind: "observeOnly"; reason: string; } | { kind: "handled"; reason: string; } | { kind: "drop"; reason: string; recordHistory?: boolean; }; type ChannelEventClass = { kind: "message" | "command" | "interaction" | "reaction" | "lifecycle" | "unknown"; canStartAgentTurn: boolean; requiresImmediateAck?: boolean; }; type NormalizedTurnInput = { id: string; timestamp?: number; rawText: string; textForAgent?: string; textForCommands?: string; raw?: unknown; }; type SenderFacts = { id?: string; name?: string; username?: string; tag?: string; roles?: string[]; isBot?: boolean; isSelf?: boolean; displayLabel?: string; }; type ConversationFacts = { kind: "direct" | "group" | "channel"; id: string; label?: string; spaceId?: string; parentId?: string; threadId?: string; nativeChannelId?: string; routePeer: { kind: "direct" | "group" | "channel"; id: string; }; }; type RouteFacts = { agentId: string; accountId?: string; routeSessionKey: string; dispatchSessionKey?: string; persistedSessionKey?: string; parentSessionKey?: string; modelParentSessionKey?: string; mainSessionKey?: string; createIfMissing?: boolean; }; type ReplyPlanFacts = { to: string; originatingTo: string; nativeChannelId?: string; replyTarget?: string; deliveryTarget?: string; replyToId?: string; replyToIdFull?: string; messageThreadId?: string | number; threadParentId?: string; sourceReplyDeliveryMode?: "thread" | "reply" | "channel" | "direct" | "none"; }; type ProjectedAllowlistAccessFacts = { configured: boolean; matched: boolean; reasonCode?: string; matchedEntryIds: string[]; invalidEntryCount: number; disabledEntryCount: number; accessGroups: { referenced: string[]; matched: string[]; missing: string[]; unsupported: string[]; failed: string[]; }; }; type ProjectedEventAccessFacts = { kind: "message" | "reaction" | "button" | "postback" | "native-command" | "slash-command" | "system"; authMode: "inbound" | "command" | "origin-subject" | "route-only" | "none"; mayPair: boolean; authorized: boolean; reasonCode?: string; hasOriginSubject: boolean; originSubjectMatched: boolean; }; type AccessFacts = { dm?: { decision: "allow" | "pairing" | "deny"; reason?: string; /** * @deprecated Shared ingress projections redact allowlist entries and return an empty compat list. * Use allowlist diagnostics instead. */ allowFrom: string[]; allowlist?: ProjectedAllowlistAccessFacts; }; group?: { policy: "open" | "allowlist" | "disabled"; routeAllowed: boolean; senderAllowed: boolean; /** * @deprecated Shared ingress projections redact allowlist entries and return an empty compat list. * Use allowlist diagnostics instead. */ allowFrom: string[]; requireMention: boolean; allowlist?: ProjectedAllowlistAccessFacts; }; commands?: { authorized?: boolean; shouldBlockControlCommand?: boolean; reasonCode?: string; useAccessGroups: boolean; allowTextCommands: boolean; modeWhenAccessGroupsOff?: "allow" | "deny" | "configured"; /** * @deprecated Shared ingress projections do not expose raw authorizer lists. * Use authorized and reasonCode instead. */ authorizers: Array<{ configured: boolean; allowed: boolean; }>; }; event?: ProjectedEventAccessFacts; mentions?: { canDetectMention: boolean; wasMentioned: boolean; hasAnyMention?: boolean; implicitMentionKinds?: Array<"reply_to_bot" | "quoted_bot" | "bot_thread_participant" | "native">; requireMention?: boolean; effectiveWasMentioned?: boolean; shouldSkip?: boolean; }; }; type MessageFacts = { inboundEventKind?: InboundEventKind; body?: string; rawBody: string; bodyForAgent?: string; commandBody?: string; envelopeFrom: string; senderLabel?: string; preview?: string; inboundHistory?: HistoryEntry[]; }; type CommandFacts = { kind: CommandTurnKind; body?: string; name?: string; authorized?: boolean; }; type SupplementalContextFacts = { quote?: { id?: string; fullId?: string; body?: string; sender?: string; senderAllowed?: boolean; isExternal?: boolean; isQuote?: boolean; }; forwarded?: { from?: string; fromType?: string; fromId?: string; date?: number; senderAllowed?: boolean; }; thread?: { id?: string; starterBody?: string; historyBody?: string; label?: string; parentSessionKey?: string; modelParentSessionKey?: string; senderAllowed?: boolean; }; untrustedContext?: Array<{ label: string; source?: string; type?: string; payload: unknown; }>; groupSystemPrompt?: string; }; type InboundMediaFacts = { path?: string; url?: string; contentType?: string; kind?: "image" | "video" | "audio" | "document" | "unknown"; transcribed?: boolean; messageId?: string; }; type MaybePromise = T | Promise; type PreflightFacts = { admission?: ChannelTurnAdmission; command?: CommandFacts; message?: Partial; media?: readonly InboundMediaFacts[] | (() => MaybePromise); supplemental?: SupplementalContextFacts; history?: ChannelTurnDroppedHistoryOptions; }; type ChannelDeliveryInfo = { kind: ReplyDispatchKind; }; type ChannelDeliveryIntent = { id: string; kind: "outbound_queue"; queuePolicy: OutboundDeliveryQueuePolicy; }; type ChannelDeliveryResult = { messageIds?: string[]; receipt?: MessageReceipt; threadId?: string; replyToId?: string; visibleReplySent?: boolean; deliveryIntent?: ChannelDeliveryIntent; }; type ChannelTurnDurableDeliveryOptions = Pick & { to?: string | null; replyToId?: string | null; requiredCapabilities?: DurableFinalDeliveryRequirements; }; type ChannelEventDeliveryAdapter = { preparePayload?: (payload: ReplyPayload, info: ChannelDeliveryInfo) => Promise | ReplyPayload; deliver: (payload: ReplyPayload, info: ChannelDeliveryInfo) => Promise; durable?: false | ChannelTurnDurableDeliveryOptions | ((payload: ReplyPayload, info: ChannelDeliveryInfo) => false | ChannelTurnDurableDeliveryOptions | Promise); onDelivered?: (payload: ReplyPayload, info: ChannelDeliveryInfo, result: ChannelDeliveryResult | void) => Promise | void; onError?: (err: unknown, info: { kind: string; }) => void; }; type ChannelTurnRecordOptions = { groupResolution?: GroupKeyResolution | null; createIfMissing?: boolean; updateLastRoute?: InboundLastRouteUpdate; onRecordError?: (err: unknown) => void; trackSessionMetaTask?: (task: Promise) => void; }; type ChannelTurnHistoryFinalizeOptions = { isGroup?: boolean; historyKey?: string; historyMap?: Map; limit?: number; }; type ChannelTurnDroppedHistoryOptions = { key: string; limit: number; historyMap: Map; recordOnDrop?: boolean; mediaLimit?: number; shouldRecord?: () => boolean; }; type ChannelTurnDispatcherOptions = Omit; type ChannelTurnReplyPipelineOptions = Omit; type AssembledChannelTurn = { cfg: KlawConfig; channel: string; accountId?: string; agentId: string; routeSessionKey: string; storePath: string; ctxPayload: FinalizedMsgContext; recordInboundSession: RecordInboundSession; dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher; delivery: ChannelEventDeliveryAdapter; replyPipeline?: ChannelTurnReplyPipelineOptions; dispatcherOptions?: ChannelTurnDispatcherOptions; replyOptions?: Omit; replyResolver?: GetReplyFromConfig; record?: ChannelTurnRecordOptions; history?: ChannelTurnHistoryFinalizeOptions; admission?: Extract; botLoopProtection?: ChannelBotLoopProtectionFacts; log?: (event: ChannelTurnLogEvent) => void; messageId?: string; }; type PreparedChannelTurn = { channel: string; accountId?: string; routeSessionKey: string; storePath: string; ctxPayload: FinalizedMsgContext; recordInboundSession: RecordInboundSession; record?: ChannelTurnRecordOptions; history?: ChannelTurnHistoryFinalizeOptions; onPreDispatchFailure?: (err: unknown) => void | Promise; runDispatch: () => Promise; observeOnlyDispatchResult?: TDispatchResult; admission?: Extract; botLoopProtection?: ChannelBotLoopProtectionFacts; log?: (event: ChannelTurnLogEvent) => void; messageId?: string; }; type ChannelTurnResolved = (AssembledChannelTurn & { admission?: Extract; }) | (PreparedChannelTurn & { admission?: Extract; }); type ChannelTurnStage = "ingest" | "classify" | "preflight" | "resolve" | "authorize" | "assemble" | "record" | "dispatch" | "finalize"; type ChannelTurnLogEvent = { stage: ChannelTurnStage; event: "start" | "done" | "drop" | "handled" | "error"; channel: string; accountId?: string; messageId?: string; sessionKey?: string; admission?: ChannelTurnAdmission["kind"]; reason?: string; error?: unknown; }; type ChannelTurnResult = DispatchedChannelTurnResult | { admission: ChannelTurnAdmission; dispatched: false; ctxPayload?: MsgContext; routeSessionKey?: string; }; type DispatchedChannelTurnResult = { admission: Extract; dispatched: true; ctxPayload: MsgContext; routeSessionKey: string; dispatchResult: TDispatchResult; }; type ChannelTurnAdapter = { ingest: (raw: TRaw) => Promise | NormalizedTurnInput | null; classify?: (input: NormalizedTurnInput) => Promise | ChannelEventClass; preflight?: (input: NormalizedTurnInput, eventClass: ChannelEventClass) => Promise | PreflightFacts | ChannelTurnAdmission | null | undefined; resolveTurn: (input: NormalizedTurnInput, eventClass: ChannelEventClass, preflight: PreflightFacts) => Promise> | ChannelTurnResolved; onFinalize?: (result: ChannelTurnResult) => Promise | void; }; type RunChannelTurnParams = { channel: string; accountId?: string; raw: TRaw; adapter: ChannelTurnAdapter; log?: (event: ChannelTurnLogEvent) => void; }; type RunResolvedChannelTurnParams = { channel: string; accountId?: string; raw: TRaw; input: NormalizedTurnInput | ((raw: TRaw) => Promise | NormalizedTurnInput | null); resolveTurn: (input: NormalizedTurnInput, eventClass: ChannelEventClass, preflight: PreflightFacts) => Promise> | ChannelTurnResolved; log?: (event: ChannelTurnLogEvent) => void; }; //#endregion export { SenderFacts as A, NormalizedTurnInput as C, RouteFacts as D, ReplyPlanFacts as E, recordChannelBotPairLoopAndCheckSuppression as F, ChannelBotLoopProtectionFacts as M, clearChannelBotPairLoopGuardForTests as N, RunChannelTurnParams as O, listTrackedChannelBotPairsForTests as P, MessageFacts as S, PreparedChannelTurn as T, ChannelTurnResult as _, ChannelDeliveryResult as a, DispatchedChannelTurnResult as b, ChannelTurnAdapter as c, ChannelTurnDroppedHistoryOptions as d, ChannelTurnHistoryFinalizeOptions as f, ChannelTurnResolved as g, ChannelTurnReplyPipelineOptions as h, ChannelDeliveryIntent as i, SupplementalContextFacts as j, RunResolvedChannelTurnParams as k, ChannelTurnAdmission as l, ChannelTurnRecordOptions as m, AssembledChannelTurn as n, ChannelEventClass as o, ChannelTurnLogEvent as p, ChannelDeliveryInfo as r, ChannelEventDeliveryAdapter as s, AccessFacts as t, ChannelTurnDispatcherOptions as u, CommandFacts as v, PreflightFacts as w, InboundMediaFacts as x, ConversationFacts as y };