UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

35 lines (34 loc) 1.4 kB
import { n as shouldHandleTextCommands } from "./commands-text-routing-sBs1BOcS.js"; import { t as buildCommandContext } from "./commands-context-CzCiQCus.js"; import { n as resolveCommandContextText } from "./context-text-D3m6Fy9M.js"; import { n as handleApproveCommandFromContext } from "./commands-approve-Dn8bdIS5.js"; //#region src/auto-reply/reply/fast-approve.ts /** Resolve /approve before session admission so it can release the active run it reviews. */ async function tryFastApproveFromMessage(params) { const triggerBodyNormalized = resolveCommandContextText(params.ctx); if (!/^\/approve(?:@[^\s]+)?(?:\s|$)/i.test(triggerBodyNormalized)) return { handled: false }; const command = buildCommandContext({ ctx: params.ctx, cfg: params.cfg, agentId: params.agentId, sessionKey: params.sessionKey, isGroup: params.ctx.ChatType === "group" || params.ctx.ChatType === "channel", triggerBodyNormalized, commandAuthorized: params.ctx.CommandAuthorized }); const result = await handleApproveCommandFromContext({ cfg: params.cfg, ctx: params.ctx, command }, shouldHandleTextCommands({ cfg: params.cfg, surface: command.surface, commandSource: params.ctx.CommandSource })); return result && !result.shouldContinue ? { handled: true, ...result.reply ? { reply: result.reply } : {} } : { handled: false }; } //#endregion export { tryFastApproveFromMessage };