feat: run_command 改为下拉框设置自动/需确认/禁用三种模式
- 替换原有开关为下拉选择框(selectRunCommandMode) - 新增 setRunCommandMode() 动态控制确认行为 - 需确认模式:弹窗确认后执行 - 自动模式:直接执行,无需确认 - 禁用模式:工具不可用 - 新增 .tool-card-badge.disabled 样式 - 状态从 runCommandEnabled(bool) 迁移为 runCommandMode(string)
This commit is contained in:
@@ -356,9 +356,24 @@ export const TOOL_DEFINITIONS: ToolDefinition[] = [
|
||||
const CONFIRM_TOOLS = ['run_command'];
|
||||
|
||||
export function needsConfirmation(toolName: string): boolean {
|
||||
if (toolName === 'run_command') {
|
||||
// run_command 确认模式由 runCommandMode 状态控制
|
||||
const runCommandMode = (window as any).__runCommandMode || 'confirm';
|
||||
return runCommandMode === 'confirm';
|
||||
}
|
||||
return CONFIRM_TOOLS.includes(toolName);
|
||||
}
|
||||
|
||||
/** 设置 run_command 执行模式 */
|
||||
export function setRunCommandMode(mode: 'auto' | 'confirm' | 'disabled'): void {
|
||||
(window as any).__runCommandMode = mode;
|
||||
if (mode === 'disabled') {
|
||||
setToolEnabled('run_command', false);
|
||||
} else {
|
||||
setToolEnabled('run_command', true);
|
||||
}
|
||||
}
|
||||
|
||||
let enabledTools: Set<string> = new Set([
|
||||
'read_file', 'list_directory', 'search_files',
|
||||
'write_file', 'create_directory', 'delete_file',
|
||||
|
||||
Reference in New Issue
Block a user