import { u as ReplyPayload } from "./types-CQee7pkj.js"; import { i as OpenClawConfig } from "./types.openclaw-CpnoYlBx.js"; import { T as ReplyToMode } from "./types.base-CrXPFJf5.js"; import { t as OutboundMediaAccess } from "./load-options-CQixiFLj.js"; import { n as PollInput } from "./polls-CfHkU59X.js"; import { t as OutboundSendDeps } from "./send-deps-Ds6JW9s7.js"; //#region src/channels/message/types.d.ts /** Delivery durability requested by core when a channel sends agent output. */ type MessageDurabilityPolicy = "required" | "best_effort" | "disabled"; /** Capability names a channel must advertise before core can rely on durable final delivery. */ declare const durableFinalDeliveryCapabilities: readonly ["text", "media", "poll", "payload", "silent", "replyTo", "thread", "nativeQuote", "messageSendingHooks", "batch", "reconcileUnknownSend", "afterSendSuccess", "afterCommit"]; /** Durable final delivery capability key understood by message-channel adapters. */ type DurableFinalDeliveryCapability = (typeof durableFinalDeliveryCapabilities)[number]; /** Capability map used by adapters to declare which final-send guarantees they support. */ type DurableFinalDeliveryRequirementMap = Partial>; /** Minimal payload facts used to derive required durable-delivery capabilities. */ type DurableFinalDeliveryPayloadShape = { text?: string | null; replyToId?: string | null; mediaUrl?: string | null; mediaUrls?: readonly (string | null | undefined)[] | null; }; /** Raw platform result shape normalized into a message receipt. */ type MessageReceiptSourceResult = { channel?: string; messageId?: string; chatId?: string; channelId?: string; roomId?: string; conversationId?: string; toJid?: string; pollId?: string; timestamp?: number; meta?: Record; }; /** Logical part kind for multi-part rendered messages. */ type MessageReceiptPartKind = "text" | "media" | "voice" | "poll" | "card" | "preview" | "unknown"; /** One platform message produced by a logical outbound send. */ type MessageReceiptPart = { platformMessageId: string; kind: MessageReceiptPartKind; index: number; threadId?: string; replyToId?: string; raw?: MessageReceiptSourceResult; }; /** Normalized receipt for all platform messages that make up a logical send. */ type MessageReceipt = { primaryPlatformMessageId?: string; platformMessageIds: string[]; parts: MessageReceiptPart[]; threadId?: string; replyToId?: string; editToken?: string; deleteToken?: string; sentAt: number; raw?: readonly MessageReceiptSourceResult[]; }; /** Render-plan item category used before adapter-specific send execution. */ type RenderedMessageBatchPlanKind = "text" | "media" | "voice" | "presentation" | "interactive" | "channelData" | "empty"; /** Render plan for a single reply payload after text/media/presentation splitting. */ type RenderedMessageBatchPlanItem = { index: number; kinds: readonly RenderedMessageBatchPlanKind[]; text?: string; mediaUrls: readonly string[]; audioAsVoice?: boolean; presentationBlockCount?: number; hasInteractive?: boolean; hasChannelData?: boolean; }; /** Aggregate render plan for a batch of reply payloads. */ type RenderedMessageBatchPlan = { payloadCount: number; textCount: number; mediaCount: number; voiceCount: number; presentationCount: number; interactiveCount: number; channelDataCount: number; items: readonly RenderedMessageBatchPlanItem[]; }; /** Rendered payload batch paired with the plan core uses for send routing and recovery. */ type RenderedMessageBatch = { payloads: TPayload[]; plan: RenderedMessageBatchPlan; }; /** Lifecycle phase for a live preview or streaming message send. */ type LiveMessagePhase = "idle" | "previewing" | "finalizing" | "finalized" | "cancelled"; /** Mutable state snapshot for live preview/finalization flows. */ type LiveMessageState = { phase: LiveMessagePhase; canFinalizeInPlace: boolean; receipt?: MessageReceipt; lastRendered?: RenderedMessageBatch; }; /** Durable send context passed through render, preview, send, edit, commit, and failure steps. */ type MessageSendContext = { id: string; channel: string; to: string; accountId?: string; durability: Exclude; attempt: number; signal: AbortSignal; intent?: DurableMessageSendIntent; previousReceipt?: MessageReceipt; preview?: LiveMessageState; render(): Promise>; previewUpdate(rendered: RenderedMessageBatch): Promise>; send(rendered: RenderedMessageBatch): Promise; edit(receipt: MessageReceipt, rendered: RenderedMessageBatch): Promise; delete(receipt: MessageReceipt): Promise; commit(receipt: MessageReceipt): Promise; fail(error: unknown): Promise; }; /** Common text-send context shared by text, media, payload, and poll adapter calls. */ type ChannelMessageSendTextContext = { cfg: TConfig; to: string; text: string; accountId?: string | null; deps?: OutboundSendDeps; replyToId?: string | null; replyToIdSource?: "explicit" | "implicit"; replyToMode?: ReplyToMode; threadId?: string | number | null; silent?: boolean; signal?: AbortSignal; gatewayClientScopes?: readonly string[]; }; /** Media send context with validated access hooks and media presentation hints. */ type ChannelMessageSendMediaContext = ChannelMessageSendTextContext & { mediaUrl: string; mediaAccess?: OutboundMediaAccess; mediaLocalRoots?: readonly string[]; mediaReadFile?: (filePath: string) => Promise; audioAsVoice?: boolean; gifPlayback?: boolean; forceDocument?: boolean; }; /** Rich reply payload send context used when adapters can consume structured payloads. */ type ChannelMessageSendPayloadContext = ChannelMessageSendTextContext & { payload: ReplyPayload; mediaUrl?: string; mediaAccess?: OutboundMediaAccess; mediaLocalRoots?: readonly string[]; mediaReadFile?: (filePath: string) => Promise; audioAsVoice?: boolean; gifPlayback?: boolean; forceDocument?: boolean; }; /** Poll send context; thread ids stay string-like because poll APIs do not accept numeric ids. */ type ChannelMessageSendPollContext = Omit, "text" | "threadId"> & { poll: PollInput; threadId?: string | null; isAnonymous?: boolean; }; /** Adapter send result normalized to a receipt plus optional legacy message id. */ type ChannelMessageSendResult = { receipt: MessageReceipt; messageId?: string; }; /** Discriminator for lifecycle hooks around a concrete adapter send attempt. */ type ChannelMessageSendAttemptKind = "text" | "media" | "payload" | "poll"; /** Send-attempt context tagged with the adapter method core is about to call. */ type ChannelMessageSendAttemptContext = (ChannelMessageSendTextContext & { kind: "text"; }) | (ChannelMessageSendMediaContext & { kind: "media"; }) | (ChannelMessageSendPayloadContext & { kind: "payload"; }) | (ChannelMessageSendPollContext & { kind: "poll"; }); /** Lifecycle context emitted after an adapter send succeeds but before commit finishes. */ type ChannelMessageSendSuccessContext = ChannelMessageSendAttemptContext & { result: TSendResult; attemptToken?: unknown; }; /** Lifecycle context emitted after an adapter send throws or rejects. */ type ChannelMessageSendFailureContext = ChannelMessageSendAttemptContext & { error: unknown; attemptToken?: unknown; }; /** Lifecycle context emitted when a successful send is being durably committed. */ type ChannelMessageSendCommitContext = ChannelMessageSendSuccessContext; /** Durable queue context used to reconcile a send whose platform state is unknown. */ type ChannelMessageUnknownSendContext = { cfg: TConfig; queueId: string; channel: string; to: string; accountId?: string | null; enqueuedAt: number; retryCount: number; platformSendStartedAt?: number; payloads: readonly ReplyPayload[]; renderedBatchPlan?: RenderedMessageBatchPlan; replyToId?: string | null; replyToMode?: ReplyToMode; threadId?: string | number | null; silent?: boolean; }; /** Adapter verdict for whether an unknown queued send reached the platform. */ type ChannelMessageUnknownSendReconciliationResult = { status: "sent"; receipt: MessageReceipt; messageId?: string; } | { status: "not_sent"; } | { status: "unresolved"; error?: string; retryable?: boolean; }; /** Optional hooks around adapter send attempts, platform success/failure, and commit. */ type ChannelMessageSendLifecycleAdapter = { beforeSendAttempt?: (ctx: ChannelMessageSendAttemptContext) => unknown; afterSendSuccess?: (ctx: ChannelMessageSendSuccessContext) => Promise | void; afterSendFailure?: (ctx: ChannelMessageSendFailureContext) => Promise | void; afterCommit?: (ctx: ChannelMessageSendCommitContext) => Promise | void; }; /** Adapter methods a message channel can implement for outbound text/media/payload/poll sends. */ type ChannelMessageSendAdapter = { text?: (ctx: ChannelMessageSendTextContext) => Promise; media?: (ctx: ChannelMessageSendMediaContext) => Promise; payload?: (ctx: ChannelMessageSendPayloadContext) => Promise; poll?: (ctx: ChannelMessageSendPollContext) => Promise; lifecycle?: ChannelMessageSendLifecycleAdapter; }; /** Durable final-delivery extension for queue reconciliation and capability declaration. */ type ChannelMessageDurableFinalAdapter = { capabilities?: DurableFinalDeliveryRequirementMap; reconcileUnknownSend?: (ctx: ChannelMessageUnknownSendContext) => Promise | ChannelMessageUnknownSendReconciliationResult | null; }; /** Live-message feature key declared by adapters that support preview or streaming behavior. */ type ChannelMessageLiveCapability = "draftPreview" | "previewFinalization" | "progressUpdates" | "nativeStreaming" | "quietFinalization"; /** Capability keys for turning a preview into a final platform message. */ declare const livePreviewFinalizerCapabilities: readonly ["finalEdit", "normalFallback", "discardPending", "previewReceipt", "retainOnAmbiguousFailure"]; /** Finalizer capability key understood by live-message adapters. */ type LivePreviewFinalizerCapability = (typeof livePreviewFinalizerCapabilities)[number]; /** Capability map for preview finalization behavior. */ type LivePreviewFinalizerCapabilityMap = Partial>; /** Adapter shape for finalizing live previews. */ type ChannelMessageLiveFinalizerAdapterShape = { capabilities?: LivePreviewFinalizerCapabilityMap; }; /** Adapter shape for live preview and streaming message features. */ type ChannelMessageLiveAdapterShape = { capabilities?: Partial>; finalizer?: ChannelMessageLiveFinalizerAdapterShape; }; /** Receive acknowledgement timing policy for durable inbound message records. */ type ChannelMessageReceiveAckPolicy = "after_receive_record" | "after_agent_dispatch" | "after_durable_send" | "manual"; /** Adapter receive shape for default and supported inbound acknowledgement policies. */ type ChannelMessageReceiveAdapterShape = { defaultAckPolicy?: ChannelMessageReceiveAckPolicy; supportedAckPolicies?: readonly ChannelMessageReceiveAckPolicy[]; }; /** Full message adapter shape composed from send, durable-final, live, and receive facets. */ type ChannelMessageAdapterShape = { id?: string; durableFinal?: ChannelMessageDurableFinalAdapter; send?: ChannelMessageSendAdapter; live?: ChannelMessageLiveAdapterShape; receive?: ChannelMessageReceiveAdapterShape; }; /** Concrete message adapter type, preserving channel-specific adapter refinements. */ type ChannelMessageAdapter = TAdapter; /** Extra durable-final requirement map for caller-derived capability checks. */ type DurableFinalRequirementExtras = DurableFinalDeliveryRequirementMap; /** Inputs used to derive durable final-delivery requirements for a planned send. */ type DeriveDurableFinalDeliveryRequirementsParams = { payload: DurableFinalDeliveryPayloadShape; replyToId?: string | null; threadId?: string | number | null; silent?: boolean; messageSendingHooks?: boolean; payloadTransport?: boolean; batch?: boolean; reconcileUnknownSend?: boolean; afterSendSuccess?: boolean; afterCommit?: boolean; extraCapabilities?: DurableFinalRequirementExtras; }; /** Stable intent record for a durable outbound message send. */ type DurableMessageSendIntent = { id: string; channel: string; to: string; accountId?: string; durability: Exclude; renderedBatch?: RenderedMessageBatch; }; //#endregion export { LiveMessageState as A, RenderedMessageBatchPlan as B, DeriveDurableFinalDeliveryRequirementsParams as C, DurableFinalRequirementExtras as D, DurableFinalDeliveryRequirementMap as E, MessageReceiptPart as F, RenderedMessageBatchPlanKind as H, MessageReceiptPartKind as I, MessageReceiptSourceResult as L, LivePreviewFinalizerCapabilityMap as M, MessageDurabilityPolicy as N, DurableMessageSendIntent as O, MessageReceipt as P, MessageSendContext as R, ChannelMessageUnknownSendReconciliationResult as S, DurableFinalDeliveryPayloadShape as T, RenderedMessageBatchPlanItem as V, ChannelMessageSendPollContext as _, ChannelMessageLiveCapability as a, ChannelMessageSendTextContext as b, ChannelMessageReceiveAdapterShape as c, ChannelMessageSendAttemptKind as d, ChannelMessageSendCommitContext as f, ChannelMessageSendPayloadContext as g, ChannelMessageSendMediaContext as h, ChannelMessageLiveAdapterShape as i, LivePreviewFinalizerCapability as j, LiveMessagePhase as k, ChannelMessageSendAdapter as l, ChannelMessageSendLifecycleAdapter as m, ChannelMessageAdapterShape as n, ChannelMessageLiveFinalizerAdapterShape as o, ChannelMessageSendFailureContext as p, ChannelMessageDurableFinalAdapter as r, ChannelMessageReceiveAckPolicy as s, ChannelMessageAdapter as t, ChannelMessageSendAttemptContext as u, ChannelMessageSendResult as v, DurableFinalDeliveryCapability as w, ChannelMessageUnknownSendContext as x, ChannelMessageSendSuccessContext as y, RenderedMessageBatch as z };