feat: v0.7.0 四阶段全量迭代 — 修复面收口 · 安全纵深 · 架构还债 · 能力演进
P1 修复面收口: v0.6.3 截断自愈推全量(Anthropic/Ollama/非流式/引擎兜底); SSE 上游错误帧检测进重试通道; clearMessages 摘要游标根治; truncateResult 内联图片白名单统一; 前端四 bug(确认弹窗锁死/MemoryViewer/ Virtuoso Footer/abort 尾部过滤) + reasoning 缓冲跨迭代污染; 托盘通知过滤与新建会话死链接线 P2 安全纵深: MCP 审批闭环(ConfirmationHook×PolicyEngine 联动+重名拒注册); SSRF 收敛 ssrf-guard 共享模块 (web_fetch 双通道校验+重定向终态复检); Electron 加固(preload CJS 化→sandbox:true/CSP/权限白名单/will-navigate); run_command cmd.exe 白名单通道元字符守门; diff_viewer 10MB 预检; Anthropic thinking 预算下限; Agnes 思考显式关闭 P3 架构还债: OpenAICompatibleAdapter 中间基类收敛四家样板; 错误分类单轨化(删 mapError/getFetchSignal, 超时显式 ETIMEDOUT); PRAGMA user_version 迁移版本化; 死代码清理专项(cn.ts/SHORTCUTS/ContextMenu 分支/ getWindowState/modifiedArgs/sandbox 空壳); i18next 引入; a11y 第一轮; SearXNG 页批量草稿模型统一 P4 能力演进: Ollama pull 可取消/capabilities 探测/num_ctx 实测缓存; UpdateService feed 比对式自动更新 (app:updateCheck IPC + StatusBar 入口); MiMo providerOptions(web_search 服务端工具/strict JSON); web_fetch extract_mode=markdown(turndown); network.proxyUrl 全局代理(Chromium sessions+undici dispatcher) 测试: 264 → 507 用例(Electron ABI 全绿零跳过), 覆盖引擎压缩管线/重试竞速/MEMORY.md 闸门/file_editor 五操作/ filesystem 七工具实体夹具/git 真实仓库/SSE 错误帧/全线截断自愈/Provider 请求形态矩阵/SSRF 表测/钩子分级矩阵/ OutputValidator 全量/SLO 指标/MCP 安全纯函数/task_manager 链路/渲染层纯域/i18n 桥契约
This commit is contained in:
@@ -35,6 +35,7 @@ import type {
|
||||
import { MetonaStreamEventType, MetonaErrorCode } from '../types';
|
||||
import { estimateMessagesTokens } from '../utils/token-estimator';
|
||||
import { ContentFilterError } from '../adapters/base-adapter';
|
||||
import { truncatedArgumentsPayload } from '../adapters/shared/sse-stream';
|
||||
import log from 'electron-log';
|
||||
|
||||
/**
|
||||
@@ -513,9 +514,13 @@ export class AgentLoopEngine extends EventEmitter {
|
||||
break;
|
||||
|
||||
case MetonaStreamEventType.ERROR:
|
||||
// RETRY 已在循环入口过滤,此处只处理真正的错误
|
||||
// RETRY 已在循环入口过滤,此处只处理真正的错误。
|
||||
// v0.6.4: 保留结构化错误码 —— finish() 据 code 区分 content_filtered 等
|
||||
// 类型化终止(原实现全部 new Error(message),信息被压缩为 UNKNOWN)。
|
||||
if (event.error) {
|
||||
throw new Error(event.error.message);
|
||||
const streamError = new Error(event.error.message);
|
||||
(streamError as Error & { code?: string }).code = event.error.code;
|
||||
throw streamError;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -689,8 +694,12 @@ export class AgentLoopEngine extends EventEmitter {
|
||||
let args: Record<string, unknown>;
|
||||
try {
|
||||
args = buf.argsBuffer ? JSON.parse(buf.argsBuffer) : {};
|
||||
} catch {
|
||||
args = {};
|
||||
} catch (err) {
|
||||
// v0.6.4: 引擎侧兜底缓冲的截断自愈对齐 —— 此处是全链路最后一个
|
||||
// "解析失败静默 args={}" 的残留点。统一转为 _truncatedArguments,
|
||||
// 保证任何 Provider 路径的截断工具调用都能触发模型自愈而非静默丢失。
|
||||
const sample = buf.argsBuffer.slice(-120);
|
||||
args = truncatedArgumentsPayload((err as Error).message, sample);
|
||||
}
|
||||
step.toolCalls.push({
|
||||
id: `tc_${nanoid(8)}`,
|
||||
@@ -1320,7 +1329,10 @@ export class AgentLoopEngine extends EventEmitter {
|
||||
// 此处用 emit('streamEvent', { type: ERROR }) 不会触发 EventEmitter 的同步 throw
|
||||
if ((reason === TerminationReason.ERROR || reason === TerminationReason.DEAD_LOOP) && error) {
|
||||
// v0.3.17: 识别 ContentFilterError,映射为 CONTENT_FILTERED 错误码 + 友好消息
|
||||
const isContentFilter = error instanceof ContentFilterError;
|
||||
// v0.6.4: 流式路径的拦截以 err.code='content_filtered' 抵达(无 instanceof 上下文),一并识别
|
||||
const isContentFilter =
|
||||
error instanceof ContentFilterError ||
|
||||
(error as Error & { code?: string }).code === MetonaErrorCode.CONTENT_FILTERED;
|
||||
this.emit('streamEvent', {
|
||||
type: MetonaStreamEventType.ERROR,
|
||||
requestId: this.currentRequestId,
|
||||
|
||||
Reference in New Issue
Block a user