What: serialize block reply sends, make typing non-blocking, add timeout fallback + abort-aware routing, and add regression tests. Why: prevent out-of-order streamed blocks while keeping final fallback on timeouts. Tests: ./node_modules/.bin/vitest run src/auto-reply/reply.block-streaming.test.ts src/auto-reply/reply/route-reply.test.ts Tests: corepack pnpm lint && corepack pnpm build (pass). corepack pnpm test (ran locally; failure observed during run). Co-authored-by: Josh Palmer <joshp123@users.noreply.github.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { TypingController } from "./reply/typing.js";
|
|
|
|
export type BlockReplyContext = {
|
|
abortSignal?: AbortSignal;
|
|
timeoutMs?: number;
|
|
};
|
|
|
|
export type GetReplyOptions = {
|
|
onReplyStart?: () => Promise<void> | void;
|
|
onTypingController?: (typing: TypingController) => void;
|
|
isHeartbeat?: boolean;
|
|
onPartialReply?: (payload: ReplyPayload) => Promise<void> | void;
|
|
onReasoningStream?: (payload: ReplyPayload) => Promise<void> | void;
|
|
onBlockReply?: (
|
|
payload: ReplyPayload,
|
|
context?: BlockReplyContext,
|
|
) => Promise<void> | void;
|
|
onToolResult?: (payload: ReplyPayload) => Promise<void> | void;
|
|
disableBlockStreaming?: boolean;
|
|
/** Timeout for block reply delivery (ms). */
|
|
blockReplyTimeoutMs?: number;
|
|
/** If provided, only load these skills for this session (empty = no skills). */
|
|
skillFilter?: string[];
|
|
};
|
|
|
|
export type ReplyPayload = {
|
|
text?: string;
|
|
mediaUrl?: string;
|
|
mediaUrls?: string[];
|
|
replyToId?: string;
|
|
/** Send audio as voice message (bubble) instead of audio file. Defaults to false. */
|
|
audioAsVoice?: boolean;
|
|
isError?: boolean;
|
|
};
|