fix: resolve PR comment by removing unsafe ApprovalMode type assertion

This commit is contained in:
Akhilesh Kumar
2026-03-05 18:27:59 +00:00
parent 5b19819529
commit 058c93b9e3
+5 -6
View File
@@ -12,7 +12,6 @@ import type {
} from '../scheduler/types.js'; } from '../scheduler/types.js';
import type { ToolRegistry } from '../tools/tool-registry.js'; import type { ToolRegistry } from '../tools/tool-registry.js';
import type { EditorType } from '../utils/editor.js'; import type { EditorType } from '../utils/editor.js';
import type { ApprovalMode } from '../policy/types.js';
/** /**
* Options for scheduling agent tools. * Options for scheduling agent tools.
@@ -61,12 +60,12 @@ export async function scheduleAgentTools(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const agentConfig: Config = Object.create(config); const agentConfig: Config = Object.create(config);
agentConfig.getToolRegistry = () => toolRegistry; agentConfig.getToolRegistry = () => toolRegistry;
// Apply any subagent-specific approval mode override, fallback to the main config mode. // Apply any subagent-specific approval mode override, fallback to the main config mode.
const override = config.getAgentsSettings()?.overrides?.[agentName]; const overrideMode =
if (override?.approvalMode) { config.getAgentsSettings()?.overrides?.[agentName]?.approvalMode;
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion if (overrideMode) {
agentConfig.getApprovalMode = () => override.approvalMode as ApprovalMode; agentConfig.getApprovalMode = () => overrideMode;
} else { } else {
// Subagents follow the global approval mode by default. // Subagents follow the global approval mode by default.
agentConfig.getApprovalMode = () => config.getApprovalMode(); agentConfig.getApprovalMode = () => config.getApprovalMode();