fix(tools): harden tool schemas for strict providers
This commit is contained in:
@@ -13,6 +13,14 @@ import type {
|
||||
|
||||
const providerId = "discord";
|
||||
|
||||
function readParentIdParam(
|
||||
params: Record<string, unknown>,
|
||||
): string | null | undefined {
|
||||
if (params.clearParent === true) return null;
|
||||
if (params.parentId === null) return null;
|
||||
return readStringParam(params, "parentId");
|
||||
}
|
||||
|
||||
export const discordMessageActions: ProviderMessageActionAdapter = {
|
||||
listActions: ({ cfg }) => {
|
||||
const accounts = listEnabledDiscordAccounts(cfg).filter(
|
||||
@@ -462,8 +470,7 @@ export const discordMessageActions: ProviderMessageActionAdapter = {
|
||||
const guildId = readStringParam(params, "guildId", { required: true });
|
||||
const name = readStringParam(params, "name", { required: true });
|
||||
const type = readNumberParam(params, "type", { integer: true });
|
||||
const parentId =
|
||||
params.parentId === null ? null : readStringParam(params, "parentId");
|
||||
const parentId = readParentIdParam(params);
|
||||
const topic = readStringParam(params, "topic");
|
||||
const position = readNumberParam(params, "position", { integer: true });
|
||||
const nsfw = typeof params.nsfw === "boolean" ? params.nsfw : undefined;
|
||||
@@ -489,8 +496,7 @@ export const discordMessageActions: ProviderMessageActionAdapter = {
|
||||
const name = readStringParam(params, "name");
|
||||
const topic = readStringParam(params, "topic");
|
||||
const position = readNumberParam(params, "position", { integer: true });
|
||||
const parentId =
|
||||
params.parentId === null ? null : readStringParam(params, "parentId");
|
||||
const parentId = readParentIdParam(params);
|
||||
const nsfw = typeof params.nsfw === "boolean" ? params.nsfw : undefined;
|
||||
const rateLimitPerUser = readNumberParam(params, "rateLimitPerUser", {
|
||||
integer: true,
|
||||
@@ -525,8 +531,7 @@ export const discordMessageActions: ProviderMessageActionAdapter = {
|
||||
const channelId = readStringParam(params, "channelId", {
|
||||
required: true,
|
||||
});
|
||||
const parentId =
|
||||
params.parentId === null ? null : readStringParam(params, "parentId");
|
||||
const parentId = readParentIdParam(params);
|
||||
const position = readNumberParam(params, "position", { integer: true });
|
||||
return await handleDiscordAction(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user