mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 16:40:35 +00:00
refactor: unify typing dispatch lifecycle and policy boundaries
This commit is contained in:
35
src/auto-reply/reply/typing-policy.ts
Normal file
35
src/auto-reply/reply/typing-policy.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js";
|
||||
import type { TypingPolicy } from "../types.js";
|
||||
|
||||
export type ResolveRunTypingPolicyParams = {
|
||||
requestedPolicy?: TypingPolicy;
|
||||
suppressTyping?: boolean;
|
||||
isHeartbeat?: boolean;
|
||||
originatingChannel?: string;
|
||||
systemEvent?: boolean;
|
||||
};
|
||||
|
||||
export type ResolvedRunTypingPolicy = {
|
||||
typingPolicy: TypingPolicy;
|
||||
suppressTyping: boolean;
|
||||
};
|
||||
|
||||
export function resolveRunTypingPolicy(
|
||||
params: ResolveRunTypingPolicyParams,
|
||||
): ResolvedRunTypingPolicy {
|
||||
const typingPolicy = params.isHeartbeat
|
||||
? "heartbeat"
|
||||
: params.originatingChannel === INTERNAL_MESSAGE_CHANNEL
|
||||
? "internal_webchat"
|
||||
: params.systemEvent
|
||||
? "system_event"
|
||||
: (params.requestedPolicy ?? "auto");
|
||||
|
||||
const suppressTyping =
|
||||
params.suppressTyping === true ||
|
||||
typingPolicy === "heartbeat" ||
|
||||
typingPolicy === "system_event" ||
|
||||
typingPolicy === "internal_webchat";
|
||||
|
||||
return { typingPolicy, suppressTyping };
|
||||
}
|
||||
Reference in New Issue
Block a user