openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
38 lines (37 loc) • 1.59 kB
JavaScript
import { $ as validateCommandsListParams } from "./src-D6kL8tMP.mjs";
import { t as ErrorCodes } from "./gateway-error-details-gTekQWj2.mjs";
import { d as errorShape } from "./error-codes-D0WRV4Bq.mjs";
import { r as defineValidatedGatewayMethod } from "./validation-UW_NLjlV.mjs";
import { t as resolveAgentIdOrRespondError } from "./agent-id-shared-BvQwtL4x.mjs";
import { t as buildCommandsListResult } from "./commands-list-result-DSlleEVk.mjs";
import { t as withSessionDiscoveryAccess } from "./session-discovery-access-Dym9yyxj.mjs";
//#region src/gateway/server-methods/commands.ts
/** Gateway handler for enumerating available chat/native commands. */
const commandsHandlers = { "commands.list": defineValidatedGatewayMethod("commands.list", validateCommandsListParams, async ({ params, respond, context, client, signal, hasCurrentClientAuthority }) => {
const resolved = resolveAgentIdOrRespondError({
rawAgentId: params.agentId,
respond,
cfg: context.getRuntimeConfig()
});
if (!resolved) return;
await withSessionDiscoveryAccess({
client,
context,
respond,
signal,
hasCurrentClientAuthority,
sessionKey: params.sessionKey,
agentId: resolved.agentId,
changedError: errorShape(ErrorCodes.UNAVAILABLE, "Session changed while preparing its commands. Retry the request.")
}, (sessionEntry) => buildCommandsListResult({
cfg: resolved.cfg,
agentId: resolved.agentId,
provider: params.provider,
scope: params.scope,
includeArgs: params.includeArgs,
sessionKey: params.sessionKey,
sessionEntry
}));
}) };
//#endregion
export { commandsHandlers };