import type { OpenClawConfig } from "../../config/types.openclaw.js" ;
import { fireAndForgetHook } from "../../hooks/fire-and-forget.js" ;
import { createInternalHookEvent, triggerInternalHook } from "../../hooks/internal-hooks.js" ;
import {
deriveInboundMessageHookContext,
toInternalMessagePreprocessedContext,
toInternalMessageTranscribedContext,
} from "../../hooks/message-hook-mappers.js" ;
import { normalizeOptionalString } from "../../shared/string-coerce.js" ;
import type { FinalizedMsgContext } from "../templating.js" ;
export function emitPreAgentMessageHooks(params: {
ctx: FinalizedMsgContext;
cfg: OpenClawConfig;
isFastTestEnv: boolean ;
}): void {
if (params.isFastTestEnv) {
return ;
}
const sessionKey = normalizeOptionalString(params.ctx.SessionKey);
if (!sessionKey) {
return ;
}
const canonical = deriveInboundMessageHookContext(params.ctx);
if (canonical.transcript) {
fireAndForgetHook(
triggerInternalHook(
createInternalHookEvent(
"message" ,
"transcribed" ,
sessionKey,
toInternalMessageTranscribedContext(canonical, params.cfg),
),
),
"get-reply: message:transcribed internal hook failed" ,
);
}
fireAndForgetHook(
triggerInternalHook(
createInternalHookEvent(
"message" ,
"preprocessed" ,
sessionKey,
toInternalMessagePreprocessedContext(canonical, params.cfg),
),
),
"get-reply: message:preprocessed internal hook failed" ,
);
}
Messung V0.5 in Prozent C=99 H=93 G=95
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland