Discord: add component v2 UI tool support (#17419)

This commit is contained in:
Shadow
2026-02-15 21:19:25 -06:00
committed by GitHub
parent b4a9eacd76
commit a61c2dc4bd
15 changed files with 2893 additions and 43 deletions

View File

@@ -395,10 +395,11 @@ async function handleSendAction(ctx: ResolvedActionContext): Promise<MessageActi
readStringParam(params, "path", { trim: false }) ??
readStringParam(params, "filePath", { trim: false });
const hasCard = params.card != null && typeof params.card === "object";
const hasComponents = params.components != null && typeof params.components === "object";
const caption = readStringParam(params, "caption", { allowEmpty: true }) ?? "";
let message =
readStringParam(params, "message", {
required: !mediaHint && !hasCard,
required: !mediaHint && !hasCard && !hasComponents,
allowEmpty: true,
}) ?? "";
if (message.includes("\\n")) {
@@ -464,7 +465,7 @@ async function handleSendAction(ctx: ResolvedActionContext): Promise<MessageActi
message = "";
}
}
if (!message.trim() && !mediaUrl && mergedMediaUrls.length === 0 && !hasCard) {
if (!message.trim() && !mediaUrl && mergedMediaUrls.length === 0 && !hasCard && !hasComponents) {
throw new Error("send requires text or media");
}
params.message = message;
@@ -501,6 +502,12 @@ async function handleSendAction(ctx: ResolvedActionContext): Promise<MessageActi
route: outboundRoute,
});
}
if (outboundRoute && !dryRun) {
params.__sessionKey = outboundRoute.sessionKey;
}
if (agentId) {
params.__agentId = agentId;
}
const mirrorMediaUrls =
mergedMediaUrls.length > 0 ? mergedMediaUrls : mediaUrl ? [mediaUrl] : undefined;
throwIfAborted(abortSignal);