fix: tighten lowercase helper typing

This commit is contained in:
Peter Steinberger
2026-04-07 13:01:13 +01:00
parent 18acfe7352
commit 65aab4bb27
3 changed files with 5 additions and 3 deletions

View File

@@ -33,7 +33,9 @@ export function sanitizeToolName(raw: string): string {
export function normalizeReservedToolNames(names?: Iterable<string>): Set<string> {
return new Set(
Array.from(names ?? [], (name) => normalizeOptionalLowercaseString(name)).filter(Boolean),
Array.from(names ?? [], (name) => normalizeOptionalLowercaseString(name)).filter(
(name): name is string => Boolean(name),
),
);
}

View File

@@ -75,7 +75,7 @@ function isLegacyFoundryVisionModelCandidate(params: {
const normalizedCandidates = [params.modelId, params.modelName]
.filter((value): value is string => typeof value === "string")
.map((value) => normalizeOptionalLowercaseString(value))
.filter(Boolean);
.filter((value): value is string => Boolean(value));
return normalizedCandidates.some(
(candidate) =>
candidate.startsWith("gpt-") ||

View File

@@ -77,7 +77,7 @@ export function createSessionsListTool(opts?: {
const kindsRaw = readStringArrayParam(params, "kinds")
?.map((value) => normalizeOptionalLowercaseString(value))
.filter(Boolean);
.filter((value): value is string => Boolean(value));
const allowedKindsList = (kindsRaw ?? []).filter((value) =>
["main", "group", "cron", "hook", "node", "other"].includes(value),
);