/** * IM 入站消息终态:分类、用户可见文案、结构化日志字段。 */ export type InboundTrigger = "user" | "cron" | "tool" | "heartbeat" | "system" | "runtime_continue"; export type TerminalState = "success" | "no_reply" | "timeout" | "runtime_error" | "precheck_error" | "compaction_failed" | "delivery_failed" | "cancelled" | "superseded"; export type RuntimeErrorHint = { errorType: TerminalState; errorMessage: string; }; export declare function classifyRuntimeErrorMessage(message: string): RuntimeErrorHint; export declare function classifyRuntimeError(err: unknown): RuntimeErrorHint; export { buildTerminalUserMessage } from "./user-facing-errors.js"; export type { TerminalMessageContext } from "./user-facing-errors.js"; export type TerminalLogFields = { message_id: string; group_id: string; session_key: string; run_id?: string; trigger: InboundTrigger; terminal_state: TerminalState; sent_to_im: boolean; error_type?: TerminalState; error_message?: string; no_reply_cause?: NoReplyCause; deliver_invoke_count?: number; deliver_call_count?: number; normalizer_silent_skip?: boolean; normalizer_heartbeat_skip?: boolean; http_suppressed_reason?: "intentional_silent" | "heartbeat_only"; }; export declare function formatTerminalLogLine(fields: TerminalLogFields): string; /** 终态为 no_reply 时的细分原因(用于日志与是否发 HTTP 兜底)。 */ export type NoReplyCause = "intentional_silent" | "heartbeat_only" | "zero_deliver" | "all_deliver_skipped" | "unknown"; export type ResolveTerminalStateInput = { hasBusinessReply: boolean; timeoutFired: boolean; dispatchThrew: boolean; dispatchError?: unknown; lastDeliverError?: unknown; beforeAgentRunBlocked?: boolean; compactionShown: boolean; compactionIncomplete: boolean; runtimeErrorHint?: RuntimeErrorHint; deliverInvokeCount: number; deliverCallCount: number; /** OpenClaw normalizer 因 NO_REPLY / silent token 跳过 payload(onSkip reason=silent) */ normalizerSilentSkip?: boolean; /** normalizer 因 HEARTBEAT_OK 等跳过(onSkip reason=heartbeat) */ normalizerHeartbeatSkip?: boolean; }; export declare function resolveHttpSuppressedReason(state: TerminalState, input: Pick): "intentional_silent" | "heartbeat_only" | undefined; /** * 是否允许对 IM 发终态 HTTP。 * 不发:no_reply / timeout / compaction_failed(避免自造话或通道计时器误导)。 * 可发:投递失败、取消/覆盖、以及带上游原文的确认错误(文案为空时 trySend 仍会跳过)。 */ export declare function shouldSendTerminalHttpForState(state: TerminalState, _input?: Pick): boolean; export declare function resolveNoReplyCause(input: ResolveTerminalStateInput): NoReplyCause | undefined; /** 在 finally 阶段根据观测信号推断终态(success 由 hasBusinessReply 在外层短路)。 */ export declare function resolveTerminalState(input: ResolveTerminalStateInput): TerminalState; export declare function hasGlobalTerminalSent(messageId: string): boolean; export declare function markGlobalTerminalSent(messageId: string, state: TerminalState): void; export declare function peekGlobalTerminalSent(messageId: string): TerminalState | undefined; /** 测试用:清空进程级幂等表。 */ export declare function resetGlobalTerminalSentForTests(): void; //# sourceMappingURL=inbound-terminal-state.d.ts.map