fix: 全面测试修复 — useTools TDZ 错误 + CSS 变量缺失

- agent-engine.ts: 修复 useTools 在声明前使用导致运行时 ReferenceError
- style.css: 补充 --primary, --primary-bg, --bg-hover 三个缺失的 CSS 变量
This commit is contained in:
thzxx
2026-04-18 09:55:32 +08:00
parent 8ea7a056f3
commit c6fc8b116c
2 changed files with 7 additions and 3 deletions
+4 -3
View File
@@ -367,6 +367,10 @@ export async function runAgentLoop(
// 检查模型是否支持 Tool Calling // 检查模型是否支持 Tool Calling
const modelSupportsTools = state.get<boolean>('modelSupportsTools', false); const modelSupportsTools = state.get<boolean>('modelSupportsTools', false);
// 提前获取工具列表,供后续系统 prompt 构建使用
const tools = getEnabledToolDefinitions();
const useTools = tools.length > 0;
const messages: OllamaMessage[] = []; const messages: OllamaMessage[] = [];
let systemPromptParts: string[] = []; let systemPromptParts: string[] = [];
@@ -449,9 +453,6 @@ export async function runAgentLoop(
}; };
messages.push(userMsg); messages.push(userMsg);
const tools = getEnabledToolDefinitions();
const useTools = tools.length > 0;
logInfo(`ReAct Agent Loop 启动: ${model}`, `工具: ${useTools ? '开启' : '关闭'}, 记忆: ${isMemoryEnabled() ? '开启' : '关闭'}`); logInfo(`ReAct Agent Loop 启动: ${model}`, `工具: ${useTools ? '开启' : '关闭'}, 记忆: ${isMemoryEnabled() ? '开启' : '关闭'}`);
let loopCount = 0; let loopCount = 0;
+3
View File
@@ -30,6 +30,9 @@
--accent-hover: #D4623A; --accent-hover: #D4623A;
--accent-subtle: rgba(232, 115, 74, 0.08); --accent-subtle: rgba(232, 115, 74, 0.08);
--accent-subtle-hover: rgba(232, 115, 74, 0.14); --accent-subtle-hover: rgba(232, 115, 74, 0.14);
--primary: #E8734A;
--primary-bg: rgba(232, 115, 74, 0.08);
--bg-hover: #FFF8F0;
--critical: #D94F5C; --critical: #D94F5C;
--critical-bg: rgba(217, 79, 92, 0.08); --critical-bg: rgba(217, 79, 92, 0.08);