mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix: repair Feishu reset hook typing and stabilize secret resolver timeout
This commit is contained in:
@@ -450,7 +450,11 @@ function formatSubMessageContent(content: string, contentType: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
function checkBotMentioned(event: FeishuMessageEvent, botOpenId?: string, botName?: string): boolean {
|
||||
function checkBotMentioned(
|
||||
event: FeishuMessageEvent,
|
||||
botOpenId?: string,
|
||||
botName?: string,
|
||||
): boolean {
|
||||
if (!botOpenId) return false;
|
||||
// Check for @all (@_all in Feishu) — treat as mentioning every bot
|
||||
const rawContent = event.message.content ?? "";
|
||||
@@ -886,7 +890,7 @@ export async function handleFeishuMessage(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
let ctx = parseFeishuMessageEvent(event, botOpenId, botName ?? account.config?.botName);
|
||||
let ctx = parseFeishuMessageEvent(event, botOpenId, botName);
|
||||
const isGroup = ctx.chatType === "group";
|
||||
const isDirect = !isGroup;
|
||||
const senderUserId = event.sender.sender_id.user_id?.trim() || undefined;
|
||||
|
||||
@@ -1,49 +1,59 @@
|
||||
import type { PluginHookRunner } from "openclaw/plugin-sdk";
|
||||
import { DEFAULT_RESET_TRIGGERS } from "../../../config/sessions/types.js";
|
||||
const DEFAULT_RESET_TRIGGERS = ["/new", "/reset"] as const;
|
||||
|
||||
type FeishuBeforeResetContext = {
|
||||
cfg: Record<string, unknown>;
|
||||
sessionEntry: Record<string, unknown>;
|
||||
previousSessionEntry?: Record<string, unknown>;
|
||||
commandSource: string;
|
||||
timestamp: number;
|
||||
};
|
||||
|
||||
type FeishuBeforeResetEvent = {
|
||||
type: "command";
|
||||
action: "new" | "reset";
|
||||
context: FeishuBeforeResetContext;
|
||||
};
|
||||
|
||||
type FeishuBeforeResetRunner = {
|
||||
runBeforeReset: (
|
||||
event: FeishuBeforeResetEvent,
|
||||
ctx: { agentId: string; sessionKey: string },
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle Feishu command messages and trigger appropriate hooks
|
||||
* Handle Feishu command messages and trigger reset hooks.
|
||||
*/
|
||||
export async function handleFeishuCommand(
|
||||
messageText: string,
|
||||
sessionKey: string,
|
||||
hookRunner: PluginHookRunner,
|
||||
context: {
|
||||
cfg: any;
|
||||
sessionEntry: any;
|
||||
previousSessionEntry?: any;
|
||||
commandSource: string;
|
||||
timestamp: number;
|
||||
}
|
||||
hookRunner: FeishuBeforeResetRunner,
|
||||
context: FeishuBeforeResetContext,
|
||||
): 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} `)
|
||||
const isResetCommand = DEFAULT_RESET_TRIGGERS.some(
|
||||
(trigger) => trimmed === trigger || trimmed.startsWith(`${trigger} `),
|
||||
);
|
||||
if (!isResetCommand) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const command = trimmed.split(" ")[0];
|
||||
const action: "new" | "reset" = command === "/new" ? "new" : "reset";
|
||||
await hookRunner.runBeforeReset(
|
||||
{
|
||||
type: "command",
|
||||
action,
|
||||
context: {
|
||||
...context,
|
||||
commandSource: "feishu",
|
||||
},
|
||||
},
|
||||
{
|
||||
agentId: "main",
|
||||
sessionKey,
|
||||
},
|
||||
);
|
||||
|
||||
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
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ describe("secret ref resolver", () => {
|
||||
source: "exec",
|
||||
command: scriptPath,
|
||||
passEnv: ["PATH"],
|
||||
timeoutMs: 500,
|
||||
timeoutMs: 1500,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user