openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
37 lines (36 loc) • 1.41 kB
JavaScript
import { a as resolveCommandAuthorizationAsync } from "./command-auth-CC1Z19Eh.mjs";
import { t as shouldHandleTextCommands } from "./commands-text-routing-BYEg7XMZ.mjs";
import { n as resolveCommandContextText } from "./context-text-D9JfaJrk.mjs";
import { t as buildCommandContext } from "./commands-context-1C0vIajQ.mjs";
import { t as handleApproveCommandFromContext } from "./commands-approve-CNhM3BJz.mjs";
//#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(e) {
const t = resolveCommandContextText(e.ctx);
if (!/^\/approve(?:@[^\s]+)?(?:\s|$)/i.test(t)) return { handled: false };
const n = {
ctx: e.ctx,
cfg: e.cfg,
agentId: e.agentId,
sessionKey: e.sessionKey,
isGroup: e.ctx.ChatType === "group" || e.ctx.ChatType === "channel",
triggerBodyNormalized: t,
commandAuthorized: e.ctx.CommandAuthorized
};
const r = buildCommandContext(n, await resolveCommandAuthorizationAsync(n));
const i = await handleApproveCommandFromContext({
cfg: e.cfg,
ctx: e.ctx,
command: r
}, shouldHandleTextCommands({
cfg: e.cfg,
surface: r.surface,
commandSource: e.ctx.CommandSource
}));
return i && !i.shouldContinue ? {
handled: true,
...i.reply ? { reply: i.reply } : {}
} : { handled: false };
}
//#endregion
export { tryFastApproveFromMessage };