chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -1,9 +1,6 @@
import { createActionGate } from "../../../agents/tools/common.js";
import { listEnabledDiscordAccounts } from "../../../discord/accounts.js";
import type {
ChannelMessageActionAdapter,
ChannelMessageActionName,
} from "../types.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
import { handleDiscordMessageAction } from "./discord/handle-action.js";
export const discordMessageActions: ChannelMessageActionAdapter = {
@@ -78,8 +75,7 @@ export const discordMessageActions: ChannelMessageActionAdapter = {
return to ? { to } : null;
}
if (action === "threadReply") {
const channelId =
typeof args.channelId === "string" ? args.channelId.trim() : "";
const channelId = typeof args.channelId === "string" ? args.channelId.trim() : "";
return channelId ? { to: `channel:${channelId}` } : null;
}
return null;

View File

@@ -12,9 +12,7 @@ type Ctx = Pick<ChannelMessageActionContext, "action" | "params" | "cfg">;
export async function tryHandleDiscordMessageActionGuildAdmin(params: {
ctx: Ctx;
resolveChannelId: () => string;
readParentIdParam: (
params: Record<string, unknown>,
) => string | null | undefined;
readParentIdParam: (params: Record<string, unknown>) => string | null | undefined;
}): Promise<AgentToolResult<unknown> | undefined> {
const { ctx, resolveChannelId, readParentIdParam } = params;
const { action, params: actionParams, cfg } = ctx;
@@ -24,10 +22,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
const guildId = readStringParam(actionParams, "guildId", {
required: true,
});
return await handleDiscordAction(
{ action: "memberInfo", guildId, userId },
cfg,
);
return await handleDiscordAction({ action: "memberInfo", guildId, userId }, cfg);
}
if (action === "role-info") {
@@ -125,8 +120,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
const position = readNumberParam(actionParams, "position", {
integer: true,
});
const nsfw =
typeof actionParams.nsfw === "boolean" ? actionParams.nsfw : undefined;
const nsfw = typeof actionParams.nsfw === "boolean" ? actionParams.nsfw : undefined;
return await handleDiscordAction(
{
action: "channelCreate",
@@ -152,8 +146,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
integer: true,
});
const parentId = readParentIdParam(actionParams);
const nsfw =
typeof actionParams.nsfw === "boolean" ? actionParams.nsfw : undefined;
const nsfw = typeof actionParams.nsfw === "boolean" ? actionParams.nsfw : undefined;
const rateLimitPerUser = readNumberParam(actionParams, "rateLimitPerUser", {
integer: true,
});
@@ -176,10 +169,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
const channelId = readStringParam(actionParams, "channelId", {
required: true,
});
return await handleDiscordAction(
{ action: "channelDelete", channelId },
cfg,
);
return await handleDiscordAction({ action: "channelDelete", channelId }, cfg);
}
if (action === "channel-move") {
@@ -247,10 +237,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
const categoryId = readStringParam(actionParams, "categoryId", {
required: true,
});
return await handleDiscordAction(
{ action: "categoryDelete", categoryId },
cfg,
);
return await handleDiscordAction({ action: "categoryDelete", categoryId }, cfg);
}
if (action === "voice-status") {
@@ -258,10 +245,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
required: true,
});
const userId = readStringParam(actionParams, "userId", { required: true });
return await handleDiscordAction(
{ action: "voiceStatus", guildId, userId },
cfg,
);
return await handleDiscordAction({ action: "voiceStatus", guildId, userId }, cfg);
}
if (action === "event-list") {
@@ -335,9 +319,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
});
const channelId = readStringParam(actionParams, "channelId");
const includeArchived =
typeof actionParams.includeArchived === "boolean"
? actionParams.includeArchived
: undefined;
typeof actionParams.includeArchived === "boolean" ? actionParams.includeArchived : undefined;
const before = readStringParam(actionParams, "before");
const limit = readNumberParam(actionParams, "limit", { integer: true });
return await handleDiscordAction(

View File

@@ -10,9 +10,7 @@ import { tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-a
const providerId = "discord";
function readParentIdParam(
params: Record<string, unknown>,
): string | null | undefined {
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");
@@ -24,8 +22,7 @@ export async function handleDiscordMessageAction(
const { action, params, cfg } = ctx;
const resolveChannelId = () =>
readStringParam(params, "channelId") ??
readStringParam(params, "to", { required: true });
readStringParam(params, "channelId") ?? readStringParam(params, "to", { required: true });
if (action === "send") {
const to = readStringParam(params, "to", { required: true });
@@ -52,10 +49,8 @@ export async function handleDiscordMessageAction(
const question = readStringParam(params, "pollQuestion", {
required: true,
});
const answers =
readStringArrayParam(params, "pollOption", { required: true }) ?? [];
const allowMultiselect =
typeof params.pollMulti === "boolean" ? params.pollMulti : undefined;
const answers = readStringArrayParam(params, "pollOption", { required: true }) ?? [];
const allowMultiselect = typeof params.pollMulti === "boolean" ? params.pollMulti : undefined;
const durationHours = readNumberParam(params, "pollDurationHours", {
integer: true,
});
@@ -76,8 +71,7 @@ export async function handleDiscordMessageAction(
if (action === "react") {
const messageId = readStringParam(params, "messageId", { required: true });
const emoji = readStringParam(params, "emoji", { allowEmpty: true });
const remove =
typeof params.remove === "boolean" ? params.remove : undefined;
const remove = typeof params.remove === "boolean" ? params.remove : undefined;
return await handleDiscordAction(
{
action: "react",
@@ -138,17 +132,10 @@ export async function handleDiscordMessageAction(
if (action === "pin" || action === "unpin" || action === "list-pins") {
const messageId =
action === "list-pins"
? undefined
: readStringParam(params, "messageId", { required: true });
action === "list-pins" ? undefined : readStringParam(params, "messageId", { required: true });
return await handleDiscordAction(
{
action:
action === "pin"
? "pinMessage"
: action === "unpin"
? "unpinMessage"
: "listPins",
action: action === "pin" ? "pinMessage" : action === "unpin" ? "unpinMessage" : "listPins",
channelId: resolveChannelId(),
messageId,
},
@@ -157,10 +144,7 @@ export async function handleDiscordMessageAction(
}
if (action === "permissions") {
return await handleDiscordAction(
{ action: "permissions", channelId: resolveChannelId() },
cfg,
);
return await handleDiscordAction({ action: "permissions", channelId: resolveChannelId() }, cfg);
}
if (action === "thread-create") {
@@ -205,7 +189,5 @@ export async function handleDiscordMessageAction(
});
if (adminResult !== undefined) return adminResult;
throw new Error(
`Action ${String(action)} is not supported for provider ${providerId}.`,
);
throw new Error(`Action ${String(action)} is not supported for provider ${providerId}.`);
}

View File

@@ -1,14 +1,8 @@
import {
createActionGate,
readStringParam,
} from "../../../agents/tools/common.js";
import { createActionGate, readStringParam } from "../../../agents/tools/common.js";
import { handleTelegramAction } from "../../../agents/tools/telegram-actions.js";
import type { ClawdbotConfig } from "../../../config/config.js";
import { listEnabledTelegramAccounts } from "../../../telegram/accounts.js";
import type {
ChannelMessageActionAdapter,
ChannelMessageActionName,
} from "../types.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
const providerId = "telegram";
@@ -49,8 +43,7 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
if (action !== "sendMessage") return null;
const to = typeof args.to === "string" ? args.to : undefined;
if (!to) return null;
const accountId =
typeof args.accountId === "string" ? args.accountId.trim() : undefined;
const accountId = typeof args.accountId === "string" ? args.accountId.trim() : undefined;
return { to, accountId };
},
handleAction: async ({ action, params, cfg, accountId }) => {
@@ -84,14 +77,12 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
required: true,
});
const emoji = readStringParam(params, "emoji", { allowEmpty: true });
const remove =
typeof params.remove === "boolean" ? params.remove : undefined;
const remove = typeof params.remove === "boolean" ? params.remove : undefined;
return await handleTelegramAction(
{
action: "react",
chatId:
readStringParam(params, "chatId") ??
readStringParam(params, "to", { required: true }),
readStringParam(params, "chatId") ?? readStringParam(params, "to", { required: true }),
messageId,
emoji,
remove,
@@ -101,8 +92,6 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
);
}
throw new Error(
`Action ${action} is not supported for provider ${providerId}.`,
);
throw new Error(`Action ${action} is not supported for provider ${providerId}.`);
},
};