feat: v5.0 全面进化 — 浏览器控制 + 训练数据导出 + Cron 定时任务

新增功能:

1. 🌐 浏览器控制(8 个工具)
   - 主进程 browser.ts: 基于隐藏 BrowserWindow 的浏览器引擎
   - browser_open: 加载 URL,返回标题和最终 URL
   - browser_screenshot: 页面截图(base64 PNG)
   - browser_evaluate: 执行任意 JS,支持 DOM 操作
   - browser_extract: 提取页面文本 + 链接(最多 50 条)
   - browser_click: CSS 选择器点击
   - browser_type: 输入框文本输入
   - browser_scroll: 上下滚动/顶部/底部
   - browser_close: 关闭浏览器释放资源
   - 应用退出时自动清理 (before-quit)
   - 工具总数:34 个

2. 📚 训练数据导出
   - training-export.ts: 从 traces + messages 提取 SFT 格式训练数据
   - 输出 JSONL 格式(instruction/input/output/tools/observations/metadata)
   - 设置面板一键导出,Electron 原生文件对话框选择保存位置

3.  Cron 定时任务
   - cron-manager.ts: one-shot(指定时间)+ recurring(周期性)
   - 任务配置持久化到 settings
   - 设置面板添加/删除/启用/禁用
   - 任务触发时自动填入聊天输入框 + toast 通知
   - 应用启动时自动恢复所有已启用任务

新增文件:browser.ts, cron-manager.ts, training-export.ts
修改文件:ipc.ts, main.ts, settings-modal.ts, index.html, main.ts(渲染), tool-registry.ts
This commit is contained in:
thzxx
2026-04-18 09:29:29 +08:00
parent 374d86086e
commit 889d34b484
9 changed files with 730 additions and 3 deletions
+21
View File
@@ -347,6 +347,27 @@
<button class="btn btn-outline" id="btnDoctor" style="margin-bottom:8px;">🩺 一键诊断</button>
<div id="doctorResults" style="display:none;margin-top:8px;padding:10px;background:var(--bg-layer);border-radius:var(--radius-control);font-size:12px;max-height:200px;overflow-y:auto;"></div>
</div>
<div class="setting-group">
<label class="setting-label">📚 训练数据导出</label>
<button class="btn btn-outline" id="btnExportTraining" style="margin-bottom:4px;">📥 导出训练数据 (JSONL)</button>
<p class="text-muted" style="margin-top:4px;font-size:11px;">将 Agent 执行轨迹导出为 SFT 格式,可用于模型微调训练。包含成功的工具调用链和对话记录。</p>
</div>
<div class="setting-group">
<label class="setting-label">⏰ 定时任务 (Cron)</label>
<div style="display:flex;gap:8px;margin-bottom:8px;">
<input class="setting-input" id="inputCronName" type="text" placeholder="任务名称" style="margin-bottom:0;flex:1;">
<select id="selectCronType" class="setting-input" style="width:auto;margin-bottom:0;padding:4px 8px;">
<option value="oneshot">一次性</option>
<option value="recurring">周期性</option>
</select>
</div>
<div style="display:flex;gap:8px;margin-bottom:8px;">
<input class="setting-input" id="inputCronSchedule" type="text" placeholder="时间 (如: 2026-04-18T10:00 或 every 30m)" style="margin-bottom:0;flex:1;">
<button class="btn btn-sm btn-outline" id="btnAddCronTask"> 添加</button>
</div>
<input class="setting-input" id="inputCronMessage" type="text" placeholder="任务描述(将作为 Agent 指令)" style="margin-bottom:8px;">
<div id="cronTaskList" style="font-size:12px;"></div>
</div>
</div>
</div>
</div>