fix: add session-memory hook support for Feishu provider (#31437)

* fix: add session-memory hook support for Feishu provider

Issue #31275: Session-memory hook not triggered when using /new command in Feishu

- Added command handler to Feishu provider
- Integrated with OpenClaw's before_reset hook system
- Ensures session memory is saved when /new or /reset commands are used

* Changelog: note Feishu session-memory hook parity

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Andy Tien
2026-03-03 12:19:24 +08:00
committed by GitHub
parent a5a7239182
commit cad06faafe
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import type { PluginHookRunner } from "openclaw/plugin-sdk";
import { DEFAULT_RESET_TRIGGERS } from "../../../config/sessions/types.js";
/**
* Handle Feishu command messages and trigger appropriate hooks
*/
export async function handleFeishuCommand(
messageText: string,
sessionKey: string,
hookRunner: PluginHookRunner,
context: {
cfg: any;
sessionEntry: any;
previousSessionEntry?: any;
commandSource: string;
timestamp: number;
}
): Promise<boolean> {
// Check if message is a reset command
const trimmed = messageText.trim().toLowerCase();
const isResetCommand = DEFAULT_RESET_TRIGGERS.some(trigger =>
trimmed === trigger || trimmed.startsWith(`${trigger} `)
);
if (isResetCommand) {
// Extract the actual command (without arguments)
const command = trimmed.split(' ')[0];
// Trigger the before_reset hook
await hookRunner.runBeforeReset(
{
type: "command",
action: command.replace('/', '') as "new" | "reset",
context: {
...context,
commandSource: "feishu"
}
},
{
agentId: "main", // or extract from sessionKey
sessionKey
}
);
return true; // Command was handled
}
return false; // Not a command we handle
}