* fix(tts): generate audio when block streaming drops final reply When block streaming succeeds, final replies are dropped but TTS was only applied to final replies. Fix by accumulating block text during streaming and generating TTS-only audio after streaming completes. Also: - Change truncate vs skip behavior when summary OFF (now truncates) - Align TTS limits with Telegram max (4096 chars) - Improve /tts command help messages with examples - Add newline separator between accumulated blocks * fix(tts): add error handling for accumulated block TTS * feat(tts): add descriptive inline menu with action descriptions - Add value/label support for command arg choices - TTS menu now shows descriptive title listing each action - Capitalize button labels (On, Off, Status, etc.) - Update Telegram, Discord, and Slack handlers to use labels Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(gateway): gracefully handle AbortError and transient network errors Addresses issues #1851, #1997, and #2034. During config reload (SIGUSR1), in-flight requests are aborted, causing AbortError exceptions. Similarly, transient network errors (fetch failed, ECONNRESET, ETIMEDOUT, etc.) can crash the gateway unnecessarily. This change: - Adds isAbortError() to detect intentional cancellations - Adds isTransientNetworkError() to detect temporary connectivity issues - Logs these errors appropriately instead of crashing - Handles nested cause chains and AggregateError AbortError is logged as a warning (expected during shutdown). Network errors are logged as non-fatal errors (will resolve on their own). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): update commands-registry test expectations Update test expectations to match new ResolvedCommandArgChoice format (choices now return {label, value} objects instead of plain strings). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: harden unhandled rejection handling and tts menus (#2451) (thanks @Glucksberg) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Shadow <hi@shadowing.dev>
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import type { ClawdbotConfig } from "../config/types.js";
|
|
|
|
export type CommandScope = "text" | "native" | "both";
|
|
|
|
export type CommandArgType = "string" | "number" | "boolean";
|
|
|
|
export type CommandArgChoiceContext = {
|
|
cfg?: ClawdbotConfig;
|
|
provider?: string;
|
|
model?: string;
|
|
command: ChatCommandDefinition;
|
|
arg: CommandArgDefinition;
|
|
};
|
|
|
|
export type CommandArgChoice = string | { value: string; label: string };
|
|
|
|
export type CommandArgChoicesProvider = (context: CommandArgChoiceContext) => CommandArgChoice[];
|
|
|
|
export type CommandArgDefinition = {
|
|
name: string;
|
|
description: string;
|
|
type: CommandArgType;
|
|
required?: boolean;
|
|
choices?: CommandArgChoice[] | CommandArgChoicesProvider;
|
|
captureRemaining?: boolean;
|
|
};
|
|
|
|
export type CommandArgMenuSpec = {
|
|
arg: string;
|
|
title?: string;
|
|
};
|
|
|
|
export type CommandArgValue = string | number | boolean | bigint;
|
|
export type CommandArgValues = Record<string, CommandArgValue>;
|
|
|
|
export type CommandArgs = {
|
|
raw?: string;
|
|
values?: CommandArgValues;
|
|
};
|
|
|
|
export type CommandArgsParsing = "none" | "positional";
|
|
|
|
export type ChatCommandDefinition = {
|
|
key: string;
|
|
nativeName?: string;
|
|
description: string;
|
|
textAliases: string[];
|
|
acceptsArgs?: boolean;
|
|
args?: CommandArgDefinition[];
|
|
argsParsing?: CommandArgsParsing;
|
|
formatArgs?: (values: CommandArgValues) => string | undefined;
|
|
argsMenu?: CommandArgMenuSpec | "auto";
|
|
scope: CommandScope;
|
|
};
|
|
|
|
export type NativeCommandSpec = {
|
|
name: string;
|
|
description: string;
|
|
acceptsArgs: boolean;
|
|
args?: CommandArgDefinition[];
|
|
};
|
|
|
|
export type CommandNormalizeOptions = {
|
|
botUsername?: string;
|
|
};
|
|
|
|
export type CommandDetection = {
|
|
exact: Set<string>;
|
|
regex: RegExp;
|
|
};
|
|
|
|
export type ShouldHandleTextCommandsParams = {
|
|
cfg: ClawdbotConfig;
|
|
surface: string;
|
|
commandSource?: "text" | "native";
|
|
};
|