mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-21 06:02:13 +00:00
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:
49
extensions/feishu/src/feishu-command-handler.ts
Normal file
49
extensions/feishu/src/feishu-command-handler.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user