chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -7,11 +7,21 @@ function throwAbortError(): never {
}
function combineAbortSignals(a?: AbortSignal, b?: AbortSignal): AbortSignal | undefined {
if (!a && !b) return undefined;
if (a && !b) return a;
if (b && !a) return b;
if (a?.aborted) return a;
if (b?.aborted) return b;
if (!a && !b) {
return undefined;
}
if (a && !b) {
return a;
}
if (b && !a) {
return b;
}
if (a?.aborted) {
return a;
}
if (b?.aborted) {
return b;
}
if (typeof AbortSignal.any === "function") {
return AbortSignal.any([a as AbortSignal, b as AbortSignal]);
}
@@ -26,14 +36,20 @@ export function wrapToolWithAbortSignal(
tool: AnyAgentTool,
abortSignal?: AbortSignal,
): AnyAgentTool {
if (!abortSignal) return tool;
if (!abortSignal) {
return tool;
}
const execute = tool.execute;
if (!execute) return tool;
if (!execute) {
return tool;
}
return {
...tool,
execute: async (toolCallId, params, signal, onUpdate) => {
const combined = combineAbortSignals(signal, abortSignal);
if (combined?.aborted) throwAbortError();
if (combined?.aborted) {
throwAbortError();
}
return await execute(toolCallId, params, combined, onUpdate);
},
};