refactor: 移除多余依赖,统一 MUI 为唯一 UI 库

- 移除 radix-ui、clsx、tailwind-merge、class-variance-authority、react-router-dom

- 前后端全面适配 MUI 组件,清理残留 Tailwind 工具类引用

- 优化 Agent Loop 引擎、IPC 处理器、Provider Adapter 等后端模块

- 新增 Agent 网络工具通用设计文档 v2
This commit is contained in:
thzxx
2026-07-05 19:15:48 +08:00
parent ba85328c4f
commit f4532a2bb2
50 changed files with 1474 additions and 2042 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ export class ConfigService {
*/
set(key: string, value: unknown): void {
const db = this.getDB();
const jsonValue = typeof value === 'string' ? value : JSON.stringify(value);
const jsonValue = JSON.stringify(value);
// 查询已有 category,避免 INSERT OR REPLACE 覆盖为默认值
const existing = db.prepare('SELECT category FROM app_config WHERE key = ?').get(key) as ConfigRow | undefined;
+12 -4
View File
@@ -227,16 +227,24 @@ export class DatabaseService {
try {
db.exec('ALTER TABLE messages ADD COLUMN attachments TEXT');
log.info('[DB] Migration: added attachments column to messages');
} catch {
// 列已存在,忽略
} catch (error) {
// 只忽略 "duplicate column" 错误(列已存在),其他错误必须抛出
const msg = error instanceof Error ? error.message : String(error);
if (!msg.includes('duplicate column')) {
throw error;
}
}
// 迁移 2: audit_logs 表添加 iteration 列
try {
db.exec('ALTER TABLE audit_logs ADD COLUMN iteration INTEGER');
log.info('[DB] Migration: added iteration column to audit_logs');
} catch {
// 列已存在,忽略
} catch (error) {
// 只忽略 "duplicate column" 错误(列已存在),其他错误必须抛出
const msg = error instanceof Error ? error.message : String(error);
if (!msg.includes('duplicate column')) {
throw error;
}
}
}
+16 -5
View File
@@ -86,7 +86,7 @@ export class SessionService {
ORDER BY pinned DESC, updated_at DESC
`).all(archived ? 1 : 0) as SessionRow[];
return rows.map(this.toSessionInfo);
return rows.map((row) => this.toSessionInfo(row));
}
/**
@@ -183,7 +183,7 @@ export class SessionService {
ORDER BY created_at ASC
`).all(sessionId) as MessageRow[];
return rows.map(this.toMessageInfo);
return rows.map((row) => this.toMessageInfo(row));
}
/**
@@ -316,11 +316,22 @@ export class SessionService {
role: row.role,
content: row.content,
reasoningContent: row.reasoning_content ?? undefined,
toolCalls: row.tool_calls ? JSON.parse(row.tool_calls) : undefined,
toolResult: row.tool_result ? JSON.parse(row.tool_result) : undefined,
attachments: row.attachments ? JSON.parse(row.attachments) : undefined,
toolCalls: row.tool_calls ? this.safeJsonParse(row.tool_calls) as unknown[] : undefined,
toolResult: row.tool_result ? this.safeJsonParse(row.tool_result) : undefined,
attachments: row.attachments ? this.safeJsonParse(row.attachments) as unknown[] : undefined,
iteration: row.iteration ?? undefined,
timestamp: row.created_at,
};
}
/**
* 安全 JSON 解析:解析失败时返回 undefined 而非抛出异常
*/
private safeJsonParse(json: string): unknown {
try {
return JSON.parse(json);
} catch {
return undefined;
}
}
}
+7 -3
View File
@@ -40,8 +40,8 @@ const AUTO_CREATED_DIRS = ['logs', 'traces', '.metona'] as const;
const MEMORY_TEMPLATE = `# MEMORY.md — AI 持久记忆
#
# 格式版本: 1.0
# 创建时间: ${new Date().toISOString()}
# 最后更新: ${new Date().toISOString()}
# 创建时间: __CREATED_AT__
# 最后更新: __UPDATED_AT__
# 工作空间: __WORKSPACE_PATH__
#
# 此文件由 Metona Agent 自动维护,用户可手动编辑。
@@ -287,7 +287,11 @@ export class WorkspaceService {
switch (fileName) {
case 'MEMORY.md': {
const content = MEMORY_TEMPLATE.replace('__WORKSPACE_PATH__', this.workspacePath);
const now = new Date().toISOString();
const content = MEMORY_TEMPLATE
.replace('__WORKSPACE_PATH__', this.workspacePath)
.replace('__CREATED_AT__', now)
.replace('__UPDATED_AT__', now);
writeFileSync(filePath, content, 'utf-8');
break;
}