/** * Discord progress streaming message - shows tool history block like IdleHands. * * Usage: * const stream = new DiscordProgressStream(placeholder, channel, rest); * stream.start(); * * // Wire up to agent events * agent.on("tool_call", stream.hooks.onToolCall); * agent.on("tool_result", stream.hooks.onToolResult); * agent.on("token", stream.hooks.onToken); * * // When done * await stream.finalize(finalText); * // Or on timeout * await stream.finalizeTimeout(partialText, timeoutMs); */ import type { RequestClient } from "@buape/carbon"; import type { ProgressHooks, ProgressSnapshot } from "./types.js"; export type DiscordProgressStreamOptions = { /** Message edit interval (default: 1500ms) */ editIntervalMs?: number; /** Max Discord message length (default: 1900) */ maxChars?: number; /** Max tool lines to display (default: 8) */ maxToolLines?: number; /** Max assistant text preview chars (default: 1200) */ maxAssistantChars?: number; /** Show stats line (turn count, tokens) - default: true */ showStats?: boolean; }; export declare class DiscordProgressStream { private readonly rest; private readonly channelId; private readonly placeholder; private readonly opts; private progress; private scheduler; private lastSnapshot; private assistantBuffer; private toolTail; private banner; private dirty; private finalized; private messageId; constructor(placeholder: { id: string; } | null, channelId: string, rest: RequestClient, opts?: DiscordProgressStreamOptions); /** Start tracking progress and editing the placeholder message */ start(): Promise; /** Stop progress tracking (but do not finalize) */ stop(): void; /** Get hooks to wire up to agent events */ hooks(): ProgressHooks; /** Set a banner message (e.g., warnings) */ setBanner(text: string | null): void; /** Get current snapshot */ getSnapshot(): ProgressSnapshot; /** Render current state to Discord markdown */ private render; /** Build stats object from current snapshot */ private buildStats; /** Finalize with the final response text (successful completion) */ finalize(finalText: string): Promise; /** Finalize due to timeout */ finalizeTimeout(partialText: string, timeoutMs?: number): Promise; /** Finalize with an error message */ finalizeError(errorMsg: string): Promise; /** Internal finalize with status */ private finalizeWithStatus; private sendMessage; private splitMessage; }