feat: v0.7.2 安全收口 · 断链接线 · 观测补洞 — 230 用例扩充与全量回归
P1 修复面收口: /clear 全链路根治(前端清空联动 DB messages+摘要游标+TRACE 快照, IPC 语义改"操作完成"; 流式中拒绝); web_browser open 补 SSRF 校验(Chromium 旁路关闭, 与 web_fetch/http_request 同源 validateSSRF); MCP 工具结果纳入注入扫描(mcp_* 前缀 按网络来源同级 full 模式, 收敛 resolveScanMode 单点); Trace 落库/入 store 双重瘦身 (tool_result base64/超长字段剥离, metadata 防 MB 级膨胀); 文本附件 512KB 闸门 (file.slice 首段读取+truncated 标志随消息持久化+主进程附件提示感知截断); 单实例锁(requestSingleInstanceLock + second-instance 聚焦已有窗口) P2 安全纵深: ConfirmationHook 多窗口化(确认请求/超时提示改全窗口广播, getAllWindows 空时回退 mainWindow, fail-closed 判定升级双通道); mcp_servers.headers 全链路接线(safeParseHeaders 容错解析+SSE/StreamableHTTP requestInit 注入+IPC 逐项 校验+设置页 JSON 输入, 远程 MCP 鉴权头可用) P3 断链接线: llm:listModels IPC(六家 adapter 动态模型发现首次接线, 配置完整性 前置校验); Ollama pullModel IPC+设置页下载卡片(进度/取消/能力徽标, v0.7.0 死代码 激活); 后台会话运行指示(sessionRunStates 图+Sidebar 状态点, 多会话并发可见); IR 卫生(移除 THINKING_START/END 死枚举, constraints 标注预留) P4 质量与文档: i18n 第二阶段(确认弹框/侧栏/状态栏/AgentMonitor/终止原因出层, 外观设置 zh-CN/en-US 切换, ui.locale 持久化, 渲染时求值规避异步注册); README/D1 文档对齐(http_request 风险等级/用例数/实现状态注记); 版本号 0.7.2 测试: 507 → 737 用例(+230, 11 个新文件)。覆盖补齐: context-builder/consolidator/ orchestrator/workspace.service/session-recorder/config-layering/secure-config/ network-proxy + IPC mcp/tasks/memory/app/data 域 + 渲染层 store 与流事件管线纯函数。 测试驱动修复: workspace.appendMemory 中文分区 \b 词边界失效(JS \b 不含 CJK), 固化条目恒追加文件末尾产生重复分区头 → (?=\n|$) 前瞻断言根治 回归: typecheck 双端 0 错误; ESLint 0/0; 系统 Node 687 通过 50 跳过; Electron ABI 全量 737/737 零跳过
This commit is contained in:
+175
-4
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* 集中文案字典(v0.6.4 P3-5 第一轮)
|
||||
* 集中文案字典(v0.6.4 P3-5 第一轮 → v0.7.2 P4-15 第二阶段)
|
||||
*
|
||||
* 目标:把散落在数据层(hooks/store)的高频硬编码文案收敛为稳定 key,
|
||||
* 第一轮覆盖 useAgentStream 的系统消息/错误提示与 StreamIndicator 通用文案。
|
||||
* 组件层(chat/settings 等)文案按此模式渐进迁移 —— 每迁一处,删除一处字面量。
|
||||
* 目标:把散落在数据层与核心组件的硬编码文案收敛为稳定 key。
|
||||
* 第二阶段覆盖:useAgentStream 终止原因(含此前硬编码的"执行出错")、
|
||||
* 确认弹框(ConfirmationDialog)、侧边栏(Sidebar)、状态栏(StatusBar)、
|
||||
* AgentMonitor 与通用按钮文案。组件层按此模式渐进迁移 —— 每迁一处,删一处字面量。
|
||||
*/
|
||||
|
||||
import { registerTranslations } from './i18n';
|
||||
@@ -12,16 +13,186 @@ registerTranslations('zh-CN', {
|
||||
// ===== 会话终止(useAgentStream done 分支)=====
|
||||
'agent.terminated.max_iterations': '⏹ 已达到最大迭代轮次上限',
|
||||
'agent.terminated.timeout': '⏹ 任务执行超时',
|
||||
'agent.terminated.error': '执行出错',
|
||||
// ===== 确认/中断 =====
|
||||
'agent.system.stopped': '⏹ 会话已停止:{{reason}}',
|
||||
'agent.error.generic': '错误: {{message}}',
|
||||
'agent.error.content_filtered': '⚠️ {{message}}',
|
||||
|
||||
// ===== 通用 =====
|
||||
'common.cancel': '取消',
|
||||
'common.delete': '删除',
|
||||
'common.refresh': '刷新',
|
||||
|
||||
// ===== 工具确认弹框(ConfirmationDialog)=====
|
||||
'confirm.title': '工具执行确认',
|
||||
'confirm.parallelSuffix': '({{count}} 个并行请求)',
|
||||
'confirm.refreshList': '刷新 pending 列表',
|
||||
'confirm.batchReason':
|
||||
'检测到 {{count}} 个并行工具调用请求确认(涉及 {{groups}} 个不同工具)。综合最高风险:{{risk}}',
|
||||
'confirm.defaultReason': 'Agent 正在请求执行工具',
|
||||
'confirm.rememberedDenials': '本会话中已记住拒绝的工具({{minutes}} 分钟后自动恢复询问):',
|
||||
'confirm.askAgain': '重新询问',
|
||||
'confirm.earliestExpiry': '最早过期 ',
|
||||
'confirm.remaining': '剩余 ',
|
||||
'confirm.selectAll': '全选',
|
||||
'confirm.deselectAll': '全不选',
|
||||
'confirm.selectedCount': '已选 {{selected}} / {{total}}',
|
||||
'confirm.noArgs': '(无参数)',
|
||||
'confirm.rememberSession': '在本次会话中记住此决定(同工具不再询问)',
|
||||
'confirm.autoExecuteLabel': '永久自动执行选中工具(跨会话不再询问,可在设置中关闭)',
|
||||
'confirm.autoExecuteApplies': '· 将应用到 {{count}} 个工具',
|
||||
'confirm.autoExecConfirmTitle': '确认永久自动执行?',
|
||||
'confirm.autoExecConfirmBody':
|
||||
'勾选后,选中的工具将永久自动执行(跨会话不再询问),包括未来的潜在危险操作。此设置可在「设置 → 工具管理」中关闭。',
|
||||
'confirm.autoExecConfirmQuestion': '确定要启用吗?',
|
||||
'confirm.autoExecConfirmYes': '确认自动执行',
|
||||
'confirm.denyAll': '拒绝全部 ({{count}})',
|
||||
'confirm.denyAllTitle': '拒绝全部请求',
|
||||
'confirm.denyAllExpiredTitle': '已超时,点击立即清理全部请求',
|
||||
'confirm.approveAll': '批准全部',
|
||||
'confirm.approveAllTitle': '批准全部请求',
|
||||
'confirm.approveAllDisabledTitle': '已全部选中,请使用"批准选中"',
|
||||
'confirm.approveAllExpiredTitle': '已超时(批准不再生效)',
|
||||
'confirm.approveSelected': '批准选中 ({{count}})',
|
||||
'confirm.confirmExecution': '确认执行 ({{count}})',
|
||||
'confirm.expired': '已超时',
|
||||
'confirm.expiredHint': '已超时,将自动拒绝;如需重新触发请等待 Agent 重试',
|
||||
|
||||
// ===== 侧边栏(Sidebar)=====
|
||||
'sidebar.newSession': '新建会话',
|
||||
'sidebar.searchPlaceholder': '搜索会话标题与内容...',
|
||||
'sidebar.noMatch': '无匹配结果',
|
||||
'sidebar.empty': '暂无会话',
|
||||
'sidebar.archived': '已归档',
|
||||
'sidebar.count': '{{count}} 个',
|
||||
'sidebar.restore': '恢复',
|
||||
'sidebar.deleteTitle': '删除会话',
|
||||
'sidebar.deleteBody': '确定删除会话「{{title}}」?此操作不可恢复。',
|
||||
'sidebar.deleteSessionAria': '删除会话 {{title}}',
|
||||
'sidebar.messageCount': '{{count}} 条',
|
||||
'sidebar.matchCount': '({{count}} 处) ',
|
||||
'sidebar.toolManager': '工具管理',
|
||||
'sidebar.toolsReady': '{{count}} 就绪',
|
||||
'sidebar.toast.createFailed': '创建会话失败,请检查数据库状态',
|
||||
'sidebar.toast.bridgeUnavailable': 'IPC 桥不可用:无法创建会话',
|
||||
'sidebar.toast.deleteFailed': '删除会话失败,请重试',
|
||||
'sidebar.toast.restoreFailed': '恢复失败',
|
||||
'sidebar.toast.toolsLoadFailed': '加载工具列表失败',
|
||||
|
||||
// ===== 状态栏(StatusBar)=====
|
||||
'status.checkUpdate': '点击检查更新(当前 {{version}})',
|
||||
'status.checking': '检查中…',
|
||||
'status.newVersion': '发现新版本 {{version}},点击此通知或设置中打开下载页',
|
||||
'status.upToDate': '已是最新版本',
|
||||
'status.settings': '设置 (Ctrl+,)',
|
||||
'status.agent.idle': '空闲',
|
||||
'status.agent.thinking': '思考中...',
|
||||
'status.agent.executing': '执行中...',
|
||||
'status.agent.error': '错误',
|
||||
|
||||
// ===== Agent 状态监视(AgentMonitor)=====
|
||||
'monitor.agentStatus': 'Agent 状态',
|
||||
'monitor.subAgentTasks': 'SubAgent 任务',
|
||||
'monitor.count': '{{count}} 个',
|
||||
'monitor.provider': 'Provider',
|
||||
'monitor.model': '模型',
|
||||
'monitor.iteration': '迭代',
|
||||
'monitor.totalDuration': '总耗时',
|
||||
'monitor.sub.delegated': '已委派',
|
||||
'monitor.sub.running': '运行中',
|
||||
'monitor.sub.completed': '已完成',
|
||||
'monitor.sub.error': '失败',
|
||||
});
|
||||
|
||||
registerTranslations('en-US', {
|
||||
'agent.terminated.max_iterations': '⏹ Max iteration limit reached',
|
||||
'agent.terminated.timeout': '⏹ Task timed out',
|
||||
'agent.terminated.error': 'Execution error',
|
||||
'agent.system.stopped': '⏹ Session stopped: {{reason}}',
|
||||
'agent.error.generic': 'Error: {{message}}',
|
||||
'agent.error.content_filtered': '⚠️ {{message}}',
|
||||
|
||||
'common.cancel': 'Cancel',
|
||||
'common.delete': 'Delete',
|
||||
'common.refresh': 'Refresh',
|
||||
|
||||
'confirm.title': 'Tool Execution Confirmation',
|
||||
'confirm.parallelSuffix': ' ({{count}} parallel requests)',
|
||||
'confirm.refreshList': 'Refresh pending list',
|
||||
'confirm.batchReason':
|
||||
'{{count}} parallel tool calls are requesting confirmation ({{groups}} distinct tools). Highest risk: {{risk}}',
|
||||
'confirm.defaultReason': 'The agent is requesting to execute a tool',
|
||||
'confirm.rememberedDenials':
|
||||
'Tools remembered as denied in this session (asking again in {{minutes}} min):',
|
||||
'confirm.askAgain': 'Ask again',
|
||||
'confirm.earliestExpiry': 'Earliest expires in ',
|
||||
'confirm.remaining': 'Remaining ',
|
||||
'confirm.selectAll': 'Select all',
|
||||
'confirm.deselectAll': 'Deselect all',
|
||||
'confirm.selectedCount': 'Selected {{selected}} / {{total}}',
|
||||
'confirm.noArgs': '(no arguments)',
|
||||
'confirm.rememberSession': 'Remember this decision for this session (ask no more)',
|
||||
'confirm.autoExecuteLabel':
|
||||
'Always auto-execute selected tools (across sessions; disable in Settings)',
|
||||
'confirm.autoExecuteApplies': '· Applies to {{count}} tool(s)',
|
||||
'confirm.autoExecConfirmTitle': 'Enable permanent auto-execution?',
|
||||
'confirm.autoExecConfirmBody':
|
||||
'Once enabled, the selected tools will always run without asking — including potentially dangerous operations in the future. You can turn this off in Settings → Tools.',
|
||||
'confirm.autoExecConfirmQuestion': 'Are you sure?',
|
||||
'confirm.autoExecConfirmYes': 'Enable auto-execution',
|
||||
'confirm.denyAll': 'Deny all ({{count}})',
|
||||
'confirm.denyAllTitle': 'Deny all requests',
|
||||
'confirm.denyAllExpiredTitle': 'Expired — click to clean up all requests now',
|
||||
'confirm.approveAll': 'Approve all',
|
||||
'confirm.approveAllTitle': 'Approve all requests',
|
||||
'confirm.approveAllDisabledTitle': 'All selected — use "Approve selected" instead',
|
||||
'confirm.approveAllExpiredTitle': 'Expired (approval no longer applies)',
|
||||
'confirm.approveSelected': 'Approve selected ({{count}})',
|
||||
'confirm.confirmExecution': 'Confirm execution ({{count}})',
|
||||
'confirm.expired': 'Expired',
|
||||
'confirm.expiredHint': 'Expired and will be auto-denied; wait for the agent to retry if needed',
|
||||
|
||||
'sidebar.newSession': 'New Session',
|
||||
'sidebar.searchPlaceholder': 'Search session titles and content...',
|
||||
'sidebar.noMatch': 'No matches',
|
||||
'sidebar.empty': 'No sessions yet',
|
||||
'sidebar.archived': 'Archived',
|
||||
'sidebar.count': '{{count}}',
|
||||
'sidebar.restore': 'Restore',
|
||||
'sidebar.deleteTitle': 'Delete Session',
|
||||
'sidebar.deleteBody': 'Delete session "{{title}}"? This cannot be undone.',
|
||||
'sidebar.deleteSessionAria': 'Delete session {{title}}',
|
||||
'sidebar.messageCount': '{{count}} msgs',
|
||||
'sidebar.matchCount': '({{count}} hits) ',
|
||||
'sidebar.toolManager': 'Tools',
|
||||
'sidebar.toolsReady': '{{count}} ready',
|
||||
'sidebar.toast.createFailed': 'Failed to create session — check database status',
|
||||
'sidebar.toast.bridgeUnavailable': 'IPC bridge unavailable: cannot create session',
|
||||
'sidebar.toast.deleteFailed': 'Failed to delete session — please retry',
|
||||
'sidebar.toast.restoreFailed': 'Restore failed',
|
||||
'sidebar.toast.toolsLoadFailed': 'Failed to load tool list',
|
||||
|
||||
'status.checkUpdate': 'Click to check for updates (current {{version}})',
|
||||
'status.checking': 'Checking…',
|
||||
'status.newVersion':
|
||||
'New version {{version}} available — click this notification to open the download page',
|
||||
'status.upToDate': 'Up to date',
|
||||
'status.settings': 'Settings (Ctrl+,)',
|
||||
'status.agent.idle': 'Idle',
|
||||
'status.agent.thinking': 'Thinking...',
|
||||
'status.agent.executing': 'Executing...',
|
||||
'status.agent.error': 'Error',
|
||||
|
||||
'monitor.agentStatus': 'Agent Status',
|
||||
'monitor.subAgentTasks': 'SubAgent Tasks',
|
||||
'monitor.count': '{{count}}',
|
||||
'monitor.provider': 'Provider',
|
||||
'monitor.model': 'Model',
|
||||
'monitor.iteration': 'Iteration',
|
||||
'monitor.totalDuration': 'Total time',
|
||||
'monitor.sub.delegated': 'Delegated',
|
||||
'monitor.sub.running': 'Running',
|
||||
'monitor.sub.completed': 'Completed',
|
||||
'monitor.sub.error': 'Failed',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user