refactor(beaver): 移除Hermes相关引用和迁移代码,完善Beaver后端主线实现

移除了所有Hermes相关的命名引用,包括:
- 从.gitignore中清理相关构建缓存文件
- 将README中的beaver-home路径配置更新
- 完善backend/README.md文档说明Beaver后端主线实现
- 移除Hermes风格的相关注释和兼容性代码
- 清理nanobot环境变量兼容性处理
- 删除技能迁移和服务迁移相关功能代码
- 更新测试用例中相关命名和函数名

BREAKING CHANGE: 移除了Hermes迁移相关API和CLI命令,不再支持nanobot环境变量兼容性
This commit is contained in:
2026-05-14 17:20:32 +08:00
parent b59968167e
commit 3b0af173cc
57 changed files with 245 additions and 4109 deletions

View File

@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { buildOfficeTaskList, buildOfficeView } from '@/lib/office';
import { buildTaskRuntimeView } from '@/lib/task-runtime';
import type { ProcessArtifact, ProcessEvent, ProcessRun, Session } from '@/types';
describe('office view builders', () => {
describe('runtime view builders', () => {
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-03-24T12:00:00.000Z'));
@ -13,7 +13,7 @@ describe('office view builders', () => {
vi.useRealTimers();
});
it('builds an office view from a root run tree', () => {
it('builds a runtime view from a root run tree', () => {
const sessions: Session[] = [
{
key: 'web:default',
@ -118,26 +118,21 @@ describe('office view builders', () => {
},
];
const office = buildOfficeView('run-root', {
const runtime = buildTaskRuntimeView('run-root', {
sessions,
processRuns,
processEvents,
processArtifacts,
});
expect(office).not.toBeNull();
expect(office?.taskId).toBe('run-root');
expect(office?.title).toBe('整理竞品研究并给出结论');
expect(office?.sourceSessionLabel).toBe('需求讨论');
expect(office?.members).toHaveLength(3);
expect(office?.tasks).toHaveLength(3);
expect(office?.assignments).toHaveLength(1);
expect(office?.progress.label).toBe('已完成子任务 1 / 3');
expect(office?.currentStageLabel).toBe('分析结果');
expect(office?.stats.artifactCount).toBe(1);
expect(office?.zones.find((zone) => zone.id === 'workspace')?.memberIds).toContain('main-agent');
expect(office?.zones.find((zone) => zone.id === 'collab')?.memberIds).toContain('research-agent');
expect(office?.zones.find((zone) => zone.id === 'research')?.memberIds).toContain('search-mcp');
expect(runtime).not.toBeNull();
expect(runtime?.taskId).toBe('run-root');
expect(runtime?.title).toBe('整理竞品研究并给出结论');
expect(runtime?.sourceSessionLabel).toBe('需求讨论');
expect(runtime?.tasks).toHaveLength(3);
expect(runtime?.progress.label).toBe('已完成子任务 1 / 3');
expect(runtime?.stats.artifactCount).toBe(1);
expect(runtime?.stats.alertCount).toBe(0);
});
it('marks stale waiting tasks as blocked and emits alerts', () => {
@ -155,109 +150,14 @@ describe('office view builders', () => {
},
];
const office = buildOfficeView('run-blocked', {
const runtime = buildTaskRuntimeView('run-blocked', {
sessions: [],
processRuns,
processEvents: [],
processArtifacts: [],
});
expect(office?.status).toBe('blocked');
expect(office?.alerts).toHaveLength(1);
expect(office?.alerts[0].level).toBe('warn');
expect(office?.members[0].zoneId).toBe('collab');
});
it('builds a filtered task list and sorts active tasks ahead of finished ones', () => {
const sessions: Session[] = [
{ key: 'web:alpha', path: 'Alpha Session' },
{ key: 'web:beta', path: 'Beta Session' },
];
const processRuns: ProcessRun[] = [
{
run_id: 'run-active',
parent_run_id: null,
session_id: 'web:alpha',
actor_type: 'agent',
actor_id: 'agent-a',
actor_name: 'Agent A',
title: '执行活跃任务',
status: 'running',
started_at: '2026-03-24T11:20:00.000Z',
},
{
run_id: 'run-done',
parent_run_id: null,
session_id: 'web:alpha',
actor_type: 'agent',
actor_id: 'agent-b',
actor_name: 'Agent B',
title: '已结束任务',
status: 'done',
started_at: '2026-03-24T10:00:00.000Z',
finished_at: '2026-03-24T10:08:00.000Z',
},
{
run_id: 'run-other-session',
parent_run_id: null,
session_id: 'web:beta',
actor_type: 'agent',
actor_id: 'agent-c',
actor_name: 'Agent C',
title: '其他会话任务',
status: 'running',
started_at: '2026-03-24T11:00:00.000Z',
},
];
const tasks = buildOfficeTaskList({
sessionId: 'web:alpha',
sessions,
processRuns,
processEvents: [],
processArtifacts: [],
});
expect(tasks).toHaveLength(2);
expect(tasks[0].taskId).toBe('run-active');
expect(tasks[1].taskId).toBe('run-done');
expect(tasks[0].sessionLabel).toBe('Alpha Session');
});
it('keeps office tasks visible when the root run inherits session from descendants', () => {
const tasks = buildOfficeTaskList({
sessionId: 'web:alpha',
sessions: [{ key: 'web:alpha', path: 'Alpha Session' }],
processRuns: [
{
run_id: 'run-root-no-session',
parent_run_id: null,
actor_type: 'agent',
actor_id: 'agent-a',
actor_name: 'Agent A',
title: '根任务缺少会话字段',
status: 'running',
started_at: '2026-03-24T11:20:00.000Z',
},
{
run_id: 'run-child-with-session',
parent_run_id: 'run-root-no-session',
session_id: 'web:alpha',
actor_type: 'agent',
actor_id: 'agent-b',
actor_name: 'Agent B',
title: '子任务仍带着会话字段',
status: 'running',
started_at: '2026-03-24T11:21:00.000Z',
},
],
processEvents: [],
processArtifacts: [],
});
expect(tasks).toHaveLength(1);
expect(tasks[0].taskId).toBe('run-root-no-session');
expect(tasks[0].sessionId).toBe('web:alpha');
expect(runtime?.status).toBe('blocked');
expect(runtime?.stats.alertCount).toBe(1);
});
});