chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -2,9 +2,7 @@ import { normalizeChannelId } from "../channels/registry.js";
|
||||
import { normalizeAccountId } from "../routing/session-key.js";
|
||||
import type { ClawdbotConfig } from "./config.js";
|
||||
|
||||
function normalizeCapabilities(
|
||||
capabilities: string[] | undefined,
|
||||
): string[] | undefined {
|
||||
function normalizeCapabilities(capabilities: string[] | undefined): string[] | undefined {
|
||||
if (!capabilities) return undefined;
|
||||
const normalized = capabilities.map((entry) => entry.trim()).filter(Boolean);
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
@@ -24,20 +22,14 @@ function resolveAccountCapabilities(params: {
|
||||
if (accounts && typeof accounts === "object") {
|
||||
const direct = accounts[normalizedAccountId];
|
||||
if (direct) {
|
||||
return (
|
||||
normalizeCapabilities(direct.capabilities) ??
|
||||
normalizeCapabilities(cfg.capabilities)
|
||||
);
|
||||
return normalizeCapabilities(direct.capabilities) ?? normalizeCapabilities(cfg.capabilities);
|
||||
}
|
||||
const matchKey = Object.keys(accounts).find(
|
||||
(key) => key.toLowerCase() === normalizedAccountId.toLowerCase(),
|
||||
);
|
||||
const match = matchKey ? accounts[matchKey] : undefined;
|
||||
if (match) {
|
||||
return (
|
||||
normalizeCapabilities(match.capabilities) ??
|
||||
normalizeCapabilities(cfg.capabilities)
|
||||
);
|
||||
return normalizeCapabilities(match.capabilities) ?? normalizeCapabilities(cfg.capabilities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +46,7 @@ export function resolveChannelCapabilities(params: {
|
||||
if (!cfg || !channel) return undefined;
|
||||
|
||||
const channelsConfig = cfg.channels as Record<string, unknown> | undefined;
|
||||
const channelConfig = (channelsConfig?.[channel] ??
|
||||
(cfg as Record<string, unknown>)[channel]) as
|
||||
const channelConfig = (channelsConfig?.[channel] ?? (cfg as Record<string, unknown>)[channel]) as
|
||||
| {
|
||||
accounts?: Record<string, { capabilities?: string[] }>;
|
||||
capabilities?: string[];
|
||||
|
||||
Reference in New Issue
Block a user