Files
openclaw/src/gateway/session-patch-hooks.ts
Gio Della-Libera dccf5f6842 fix(gateway): fire session:patch hooks for model changes (#82257)
* Fire session patch hooks for model changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: refresh CI after main repairs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-15 22:44:01 -07:00

36 lines
983 B
TypeScript

import type { SessionEntry } from "../config/sessions.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import {
hasInternalHookListeners,
triggerInternalHook,
type SessionPatchHookContext,
type SessionPatchHookEvent,
} from "../hooks/internal-hooks.js";
import type { SessionsPatchParams } from "./protocol/index.js";
export function triggerSessionPatchHook(params: {
cfg: OpenClawConfig;
sessionEntry: SessionEntry;
sessionKey: string;
patch: SessionsPatchParams;
}): void {
if (!hasInternalHookListeners("session", "patch")) {
return;
}
const hookContext: SessionPatchHookContext = structuredClone({
sessionEntry: params.sessionEntry,
patch: params.patch,
cfg: params.cfg,
});
const hookEvent: SessionPatchHookEvent = {
type: "session",
action: "patch",
sessionKey: params.sessionKey,
context: hookContext,
timestamp: new Date(),
messages: [],
};
void triggerInternalHook(hookEvent);
}