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:
@@ -43,6 +43,9 @@ import {
|
||||
} from '@mui/material';
|
||||
import { ShieldAlert, ChevronDown, Timer, RefreshCw } from 'lucide-react';
|
||||
import { useAgentStore } from '@renderer/stores/agent-store';
|
||||
// v0.7.2 P4-15: 文案出层(字典含注册副作用,须在 t() 使用前 import)
|
||||
import { t } from '@renderer/lib/i18n';
|
||||
import '@renderer/lib/i18n-strings';
|
||||
|
||||
interface ConfirmationRequest {
|
||||
toolCallId: string;
|
||||
@@ -390,8 +393,12 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
// 综合风险文案
|
||||
const batchReason =
|
||||
totalCount > 1
|
||||
? `检测到 ${totalCount} 个并行工具调用请求确认(涉及 ${grouped.length} 个不同工具)。综合最高风险:${highestRisk}`
|
||||
: (requests[0]?.reason ?? 'Agent 正在请求执行工具');
|
||||
? t('confirm.batchReason', {
|
||||
count: totalCount,
|
||||
groups: grouped.length,
|
||||
risk: highestRisk,
|
||||
})
|
||||
: (requests[0]?.reason ?? t('confirm.defaultReason'));
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -421,10 +428,11 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
<DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<ShieldAlert size={20} color="var(--mui-palette-warning-main)" />
|
||||
<Typography variant="h6" component="span">
|
||||
工具执行确认 {totalCount > 1 && `(${totalCount} 个并行请求)`}
|
||||
{t('confirm.title')}
|
||||
{totalCount > 1 && ` ${t('confirm.parallelSuffix', { count: totalCount })}`}
|
||||
</Typography>
|
||||
<Box sx={{ flex: 1 }} />
|
||||
<Tooltip title="刷新 pending 列表">
|
||||
<Tooltip title={t('confirm.refreshList')}>
|
||||
<IconButton size="small" onClick={() => refreshPending()}>
|
||||
<RefreshCw size={16} />
|
||||
</IconButton>
|
||||
@@ -441,13 +449,14 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
<Alert severity="info" sx={{ mb: 2 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: 1 }}>
|
||||
<Typography variant="caption" sx={{ fontWeight: 600 }}>
|
||||
本会话中已记住拒绝的工具({Math.ceil(rememberedDenials[0].expiresInSeconds / 60)}{' '}
|
||||
分钟后自动恢复询问):
|
||||
{t('confirm.rememberedDenials', {
|
||||
minutes: Math.ceil(rememberedDenials[0].expiresInSeconds / 60),
|
||||
})}
|
||||
</Typography>
|
||||
{rememberedDenials.map((d) => (
|
||||
<Chip
|
||||
key={d.toolName}
|
||||
label={`${d.toolName} — 重新询问`}
|
||||
label={`${d.toolName} — ${t('confirm.askAgain')}`}
|
||||
size="small"
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
@@ -481,7 +490,7 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
},
|
||||
}}
|
||||
>
|
||||
{totalCount > 1 ? '最早过期 ' : '剩余 '}
|
||||
{totalCount > 1 ? t('confirm.earliestExpiry') : t('confirm.remaining')}
|
||||
{remainingSec}s
|
||||
</Typography>
|
||||
<LinearProgress
|
||||
@@ -496,13 +505,13 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
{/* 选择控制条 */}
|
||||
<Box sx={{ mb: 1, display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<Button size="small" onClick={handleSelectAll} disabled={allSelected}>
|
||||
全选
|
||||
{t('confirm.selectAll')}
|
||||
</Button>
|
||||
<Button size="small" onClick={handleDeselectAll} disabled={selectedCount === 0}>
|
||||
全不选
|
||||
{t('confirm.deselectAll')}
|
||||
</Button>
|
||||
<Typography variant="caption" color="text.secondary" sx={{ ml: 'auto' }}>
|
||||
已选 {selectedCount} / {totalCount}
|
||||
{t('confirm.selectedCount', { selected: selectedCount, total: totalCount })}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
@@ -618,7 +627,7 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
))}
|
||||
{Object.keys(req.args).length === 0 && (
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
(无参数)
|
||||
{t('confirm.noArgs')}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
@@ -645,7 +654,7 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
}
|
||||
label={
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
在本次会话中记住此决定(同工具不再询问)
|
||||
{t('confirm.rememberSession')}
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
@@ -667,18 +676,16 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
}
|
||||
label={
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
永久自动执行选中工具(跨会话不再询问,可在设置中关闭)
|
||||
{t('confirm.autoExecuteLabel')}
|
||||
{selectedCount > 0 && autoExecute && (
|
||||
<Box component="span" sx={{ color: 'warning.main', ml: 1 }}>
|
||||
· 将应用到{' '}
|
||||
{
|
||||
new Set(
|
||||
{t('confirm.autoExecuteApplies', {
|
||||
count: new Set(
|
||||
Array.from(selectedIds)
|
||||
.map((id) => requests.find((r) => r.toolCallId === id)?.toolName)
|
||||
.filter(Boolean) as string[],
|
||||
).size
|
||||
}{' '}
|
||||
个工具
|
||||
).size,
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
</Typography>
|
||||
@@ -693,9 +700,9 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
color="error"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
title={isExpired ? '已超时,点击立即清理全部请求' : '拒绝全部请求'}
|
||||
title={isExpired ? t('confirm.denyAllExpiredTitle') : t('confirm.denyAllTitle')}
|
||||
>
|
||||
拒绝全部 ({totalCount})
|
||||
{t('confirm.denyAll', { count: totalCount })}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleRespond(true, false)}
|
||||
@@ -703,9 +710,15 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
variant="outlined"
|
||||
size="small"
|
||||
disabled={isExpired || allSelected}
|
||||
title={isExpired ? '已超时(批准不再生效)' : allSelected ? '已全部选中,请使用"批准选中"' : '批准全部请求'}
|
||||
title={
|
||||
isExpired
|
||||
? t('confirm.approveAllExpiredTitle')
|
||||
: allSelected
|
||||
? t('confirm.approveAllDisabledTitle')
|
||||
: t('confirm.approveAllTitle')
|
||||
}
|
||||
>
|
||||
批准全部
|
||||
{t('confirm.approveAll')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleRespond(true, true)}
|
||||
@@ -714,13 +727,13 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
size="small"
|
||||
autoFocus
|
||||
disabled={isExpired || selectedCount === 0}
|
||||
title={isExpired ? '已超时,将自动拒绝;如需重新触发请等待 Agent 重试' : undefined}
|
||||
title={isExpired ? t('confirm.expiredHint') : undefined}
|
||||
>
|
||||
{isExpired
|
||||
? '已超时'
|
||||
? t('confirm.expired')
|
||||
: selectedCount === totalCount
|
||||
? `确认执行 (${selectedCount})`
|
||||
: `批准选中 (${selectedCount})`}
|
||||
? t('confirm.confirmExecution', { count: selectedCount })
|
||||
: t('confirm.approveSelected', { count: selectedCount })}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
@@ -739,19 +752,18 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
fullWidth
|
||||
onKeyDown={(e) => e.stopPropagation()}
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: 14 }}>确认永久自动执行?</DialogTitle>
|
||||
<DialogTitle sx={{ fontSize: 14 }}>{t('confirm.autoExecConfirmTitle')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
|
||||
勾选后,选中的工具将永久自动执行(跨会话不再询问),包括未来的潜在危险操作。此设置可在「设置
|
||||
→ 工具管理」中关闭。
|
||||
{t('confirm.autoExecConfirmBody')}
|
||||
</Typography>
|
||||
<Typography variant="body2" sx={{ mt: 1, color: 'warning.main', fontWeight: 600 }}>
|
||||
确定要启用吗?
|
||||
{t('confirm.autoExecConfirmQuestion')}
|
||||
</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setConfirmAutoExecute(false)} color="inherit">
|
||||
取消
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
@@ -763,7 +775,7 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
color="warning"
|
||||
variant="contained"
|
||||
>
|
||||
确认自动执行
|
||||
{t('confirm.autoExecConfirmYes')}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user