openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
33 lines (32 loc) • 1.68 kB
JavaScript
import { o as getPluginRuntimeGatewayRequestScope } from "./gateway-request-scope-DV3FHtde.mjs";
import { r as logVerbose } from "./globals-yEiTitH8.mjs";
import { l as readChannelContextGatewayContextResolver } from "./admission-evidence-CcY0jAvs.mjs";
import { n as commandReply } from "./command-gates-DXl2hvMx.mjs";
//#region src/auto-reply/reply/commands-system-agent.ts
const handleSystemAgentCommand = async (params, allowTextCommands) => {
if (!allowTextCommands) return null;
const host = (readChannelContextGatewayContextResolver(params.rootCtx ?? params.ctx) ?? getPluginRuntimeGatewayRequestScope()?.resolveGatewayContext)?.()?.hostLifecycle;
const { extractSystemAgentRescueMessage, runSystemAgentRescueMessage } = await import("./system-agent/rescue-message.js");
if (extractSystemAgentRescueMessage(params.command.commandBodyNormalized) === null) return null;
if (!params.command.isAuthorizedSender) {
logVerbose(`Ignoring /openclaw from unauthorized sender: ${params.command.senderId || "<unknown>"}`);
return { shouldContinue: false };
}
return commandReply(await runSystemAgentRescueMessage({
cfg: params.cfg,
command: params.command,
commandBody: params.command.commandBodyNormalized,
agentId: params.agentId,
isGroup: params.isGroup,
assertCurrent: () => params.commandInvocationSignal?.throwIfAborted(),
deps: {
setupSurface: "gateway",
gatewayHostLifecycle: host && { request: (action, assertCaller) => host.request(action, () => {
params.commandInvocationSignal?.throwIfAborted();
assertCaller();
}) }
}
}) ?? "OpenClaw did not find a rescue request.");
};
//#endregion
export { handleSystemAgentCommand as t };