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:
@@ -39,6 +39,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Plugin command/runtime hardening: validate and normalize plugin command name/description at registration boundaries, and guard Telegram native menu normalization paths so malformed plugin command specs cannot crash startup (`trim` on undefined). (#31997) Fixes #31944. Thanks @liuxiaopai-ai.
|
||||
- Telegram: guard duplicate-token checks and gateway startup token normalization when account tokens are missing, preventing `token.trim()` crashes during status/start flows. (#31973) Thanks @ningding97.
|
||||
- Discord/lifecycle startup status: push an immediate `connected` status snapshot when the gateway is already connected before lifecycle debug listeners attach, with abort-guarding to avoid contradictory status flips during pre-aborted startup. (#32336) Thanks @mitchmcalister.
|
||||
- Feishu/session-memory hook parity: trigger the shared `before_reset` session-memory hook path when Feishu `/new` and `/reset` commands execute so reset flows preserve memory behavior consistent with other channels. (#31437) Thanks @Linux2010.
|
||||
- Feishu/LINE group system prompts: forward per-group `systemPrompt` config into inbound context `GroupSystemPrompt` for Feishu and LINE group/room events so configured group-specific behavior actually applies at dispatch time. (#31713) Thanks @whiskyboy.
|
||||
- Mentions/Slack formatting hardening: add null-safe guards for runtime text normalization paths so malformed/undefined text payloads do not crash mention stripping or mrkdwn conversion. (#31865) Thanks @stone-jin.
|
||||
- Feishu/Plugin sdk compatibility: add safe webhook default fallbacks when loading Feishu monitor state so mixed-version installs no longer crash if older `openclaw/plugin-sdk` builds omit webhook default constants. (#31606)
|
||||
|
||||
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