/** * Adapter to integrate DiscordProgressStream with the message handler. * Provides callbacks compatible with GetReplyOptions. */ import type { RequestClient } from "@buape/carbon"; import { DiscordProgressStream, type DiscordProgressStreamOptions } from "../progress/index.js"; import type { TurnEndEvent } from "../progress/types.js"; export type ProgressStreamAdapterOptions = DiscordProgressStreamOptions & { /** Placeholder message to edit (if available) */ placeholder?: { id: string; } | null; /** Channel to send messages to */ channelId: string; /** Discord REST client */ rest: RequestClient; /** Timeout in ms (for finalizeTimeout display) */ timeoutMs?: number; }; export type ProgressStreamAdapter = { /** The underlying progress stream */ stream: DiscordProgressStream; /** Start tracking progress */ start: () => Promise; /** Stop tracking (but dont finalize) */ stop: () => void; /** Callback for onToolStart events */ onToolStart: (payload: { name?: string; phase?: string; toolCallId?: string; args?: unknown; }) => void; /** Callback for onToolResult events - accepts ReplyPayload shape from IdleHands */ onToolResult: (payload: { text?: string; mediaUrls?: string[]; }) => void; /** Callback for onPartialReply - updates assistant text buffer */ onPartialReply: (payload: { text?: string; }) => void; /** Callback for turn end stats */ onTurnEnd: (stats: TurnEndEvent) => void; /** Finalize with success */ finalize: (finalText: string) => Promise; /** Finalize with timeout */ finalizeTimeout: (partialText?: string) => Promise; /** Finalize with error */ finalizeError: (errorMsg: string) => Promise; /** Check if a placeholder message exists */ hasPlaceholder: () => boolean; /** Get the message ID (if created) */ getMessageId: () => string | undefined; }; /** * Create a progress stream adapter for Discord message handling. */ export declare function createProgressStreamAdapter(opts: ProgressStreamAdapterOptions): ProgressStreamAdapter;