mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 15:54:58 +00:00
refactor: unify typing dispatch lifecycle and policy boundaries
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { createTypingKeepaliveLoop } from "../../channels/typing-lifecycle.js";
|
||||
import { createTypingStartGuard } from "../../channels/typing-start-guard.js";
|
||||
import { isSilentReplyPrefixText, isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js";
|
||||
|
||||
export type TypingController = {
|
||||
@@ -99,15 +100,16 @@ export function createTypingController(params: {
|
||||
|
||||
const isActive = () => active && !sealed;
|
||||
|
||||
const startGuard = createTypingStartGuard({
|
||||
isSealed: () => sealed,
|
||||
shouldBlock: () => runComplete,
|
||||
rethrowOnError: true,
|
||||
});
|
||||
|
||||
const triggerTyping = async () => {
|
||||
if (sealed) {
|
||||
return;
|
||||
}
|
||||
// Late callbacks after a run completed should never restart typing.
|
||||
if (runComplete) {
|
||||
return;
|
||||
}
|
||||
await onReplyStart?.();
|
||||
await startGuard.run(async () => {
|
||||
await onReplyStart?.();
|
||||
});
|
||||
};
|
||||
|
||||
const typingLoop = createTypingKeepaliveLoop({
|
||||
|
||||
Reference in New Issue
Block a user