feat(tools): require cancellation signal on every invocation

This commit is contained in:
Tianyi Cui
2026-07-19 23:38:54 +08:00
parent a99750f341
commit e8b95c8754
77 files changed
+1129 -446

No files matched your search

+2 -4
View File
@@ -54,8 +54,7 @@ export function apply(ctx: Context): void {
using d = deadline(exec.signal, timeoutMs, TOOL_TIMEOUT)
// Swap the derived deadline onto exec for dispatch, then restore the
// caller's own signal so post-execute listeners never see this plugin's
// (possibly already-aborted) timeout signal. `undefined` is not assignable to
// the optional `signal` under exactOptionalPropertyTypes, so branch on it.
// (possibly already-aborted) timeout signal.
const upstream = exec.signal
exec.signal = d.signal
try {
@@ -69,8 +68,7 @@ export function apply(ctx: Context): void {
}
return result
} finally {
if (upstream === undefined) delete exec.signal
else exec.signal = upstream
exec.signal = upstream
}
})
}