refactor: 删除工具面板开关,Tool Calling 代码写死永久开启
This commit is contained in:
@@ -21,16 +21,6 @@ export function initToolsModal(): void {
|
|||||||
if (e.target === modalEl) closeToolsModal();
|
if (e.target === modalEl) closeToolsModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Tool Calling 始终开启,不可关闭
|
|
||||||
const toggleToolCalling = modalEl.querySelector('#toggleToolCalling') as HTMLInputElement;
|
|
||||||
if (toggleToolCalling) {
|
|
||||||
toggleToolCalling.checked = true;
|
|
||||||
toggleToolCalling.disabled = true;
|
|
||||||
state.set('toolCallingEnabled', true);
|
|
||||||
const db = state.get<ChatDB | null>(KEYS.DB);
|
|
||||||
if (db) db.saveSetting('toolCallingEnabled', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// run_command 模式下拉框
|
// run_command 模式下拉框
|
||||||
const selectMode = modalEl.querySelector('#selectRunCommandMode') as HTMLSelectElement;
|
const selectMode = modalEl.querySelector('#selectRunCommandMode') as HTMLSelectElement;
|
||||||
if (selectMode) {
|
if (selectMode) {
|
||||||
@@ -63,13 +53,6 @@ function updateRunCommandBadge(mode: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function openToolsModal(): void {
|
export function openToolsModal(): void {
|
||||||
// 同步开关状态 — 始终开启
|
|
||||||
const toggleTC = modalEl.querySelector('#toggleToolCalling') as HTMLInputElement;
|
|
||||||
if (toggleTC) {
|
|
||||||
toggleTC.checked = true;
|
|
||||||
toggleTC.disabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandMode = state.get<string>('runCommandMode', 'confirm');
|
const runCommandMode = state.get<string>('runCommandMode', 'confirm');
|
||||||
const selectMode = modalEl.querySelector('#selectRunCommandMode') as HTMLSelectElement;
|
const selectMode = modalEl.querySelector('#selectRunCommandMode') as HTMLSelectElement;
|
||||||
if (selectMode) selectMode.value = runCommandMode;
|
if (selectMode) selectMode.value = runCommandMode;
|
||||||
|
|||||||
@@ -441,15 +441,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div style="display:flex;align-items:center;gap:10px;margin-bottom:12px;padding:8px 12px;background:var(--bg-layer);border-radius:var(--radius-control);border:1px solid var(--border-subtle);">
|
<p class="text-muted" style="font-size:12px;margin-bottom:12px;">AI 始终可在对话中自主调用以下工具(Tool Calling 永久开启)。高风险操作需用户确认。</p>
|
||||||
<span style="font-size:13px;font-weight:600;">工具调用(始终开启)</span>
|
|
||||||
<label class="toggle-label" style="margin:0;">
|
|
||||||
<input type="checkbox" id="toggleToolCalling">
|
|
||||||
<span class="toggle-slider"></span>
|
|
||||||
</label>
|
|
||||||
<span class="text-muted" style="font-size:11px;margin-left:auto;">始终开启,所有对话均通过 Agent Loop</span>
|
|
||||||
</div>
|
|
||||||
<p class="text-muted" style="font-size:12px;margin-bottom:12px;">启用后,AI 可在对话中自主调用以下工具。高风险操作需用户确认。系统关键路径自动屏蔽。</p>
|
|
||||||
<div class="tools-grid">
|
<div class="tools-grid">
|
||||||
<div class="tool-card">
|
<div class="tool-card">
|
||||||
<div class="tool-card-header"><span class="tool-card-icon">📄</span><span class="tool-card-name">read_file</span><span class="tool-card-badge auto">自动</span></div>
|
<div class="tool-card-header"><span class="tool-card-icon">📄</span><span class="tool-card-name">read_file</span><span class="tool-card-badge auto">自动</span></div>
|
||||||
|
|||||||
@@ -394,14 +394,11 @@ async function init(): Promise<void> {
|
|||||||
(document.querySelector('#inputMCPTimeout') as HTMLInputElement).value = mcpTimeout >= 0 ? String(mcpTimeout) : '';
|
(document.querySelector('#inputMCPTimeout') as HTMLInputElement).value = mcpTimeout >= 0 ? String(mcpTimeout) : '';
|
||||||
logInit(`超时设置: HTTP=${httpTimeout>=0?httpTimeout:30}s 流式=${streamTimeout>=0?streamTimeout:300}s MCP=${mcpTimeout>=0?mcpTimeout:60}s`);
|
logInit(`超时设置: HTTP=${httpTimeout>=0?httpTimeout:30}s 流式=${streamTimeout>=0?streamTimeout:300}s MCP=${mcpTimeout>=0?mcpTimeout:60}s`);
|
||||||
|
|
||||||
// ── Tool Calling 设置 ──
|
// ── Tool Calling 设置(永久开启,不可关闭)──
|
||||||
const toolCallingEnabled = await db.getSetting('toolCallingEnabled', true);
|
state.set('toolCallingEnabled', true);
|
||||||
const runCommandMode = await db.getSetting('runCommandMode', 'confirm') as 'auto' | 'confirm' | 'disabled';
|
const runCommandMode = await db.getSetting('runCommandMode', 'confirm') as 'auto' | 'confirm' | 'disabled';
|
||||||
state.set('toolCallingEnabled', toolCallingEnabled);
|
|
||||||
state.set('runCommandMode', runCommandMode);
|
state.set('runCommandMode', runCommandMode);
|
||||||
setRunCommandMode(runCommandMode);
|
setRunCommandMode(runCommandMode);
|
||||||
const toggleTC = document.querySelector<HTMLInputElement>('#toggleToolCalling');
|
|
||||||
if (toggleTC) toggleTC.checked = toolCallingEnabled;
|
|
||||||
|
|
||||||
// ── MCP 工具注册 ──
|
// ── MCP 工具注册 ──
|
||||||
await startAllMCPServers();
|
await startAllMCPServers();
|
||||||
|
|||||||
Reference in New Issue
Block a user