- 添加MinIO用户文件系统配置选项(BEAVER_MINIO_ROOT_USER等) - 更新外部连接器配置结构,包括BASE_URL和认证令牌设置 - 改进connector provider支持更多类型(official, feishu_bot等) - 实现Mistral模型推理模式支持reasoning_effort参数 - 增强外部连接器策略配置和运行时配置管理 - 添加connector bridge事件验证和安全保护机制 - 优化任务路由逻辑,区分simple_chat和new_task场景 - 更新初始技能工具提示配置,分离authoring admin功能
161 lines
4.5 KiB
TypeScript
161 lines
4.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { selectTaskProcess } from '@/lib/task-process';
|
|
import type { BackendTask, ProcessArtifact, ProcessEvent, ProcessRun } from '@/types';
|
|
|
|
function task(): BackendTask {
|
|
return {
|
|
task_id: 'task-1',
|
|
session_id: 'web:default',
|
|
description: 'Build report',
|
|
goal: 'Build report',
|
|
constraints: [],
|
|
priority: 0,
|
|
status: 'running',
|
|
creator: 'user',
|
|
created_at: '2026-06-04T00:00:00.000Z',
|
|
updated_at: '2026-06-04T00:01:00.000Z',
|
|
run_ids: ['main-run'],
|
|
skill_names: [],
|
|
feedback: [],
|
|
metadata: {},
|
|
process_runs: [
|
|
{
|
|
run_id: 'main-run',
|
|
session_id: 'web:default',
|
|
actor_type: 'agent',
|
|
actor_id: 'main',
|
|
actor_name: 'Main Agent',
|
|
title: 'Persisted main run',
|
|
status: 'waiting',
|
|
started_at: '2026-06-04T00:00:10.000Z',
|
|
metadata: { task_id: 'task-1' },
|
|
},
|
|
],
|
|
process_events: [
|
|
{
|
|
event_id: 'persisted-event',
|
|
run_id: 'main-run',
|
|
kind: 'task_planned',
|
|
actor_type: 'system',
|
|
actor_id: 'planner',
|
|
actor_name: 'Planner',
|
|
text: 'Persisted plan',
|
|
created_at: '2026-06-04T00:00:20.000Z',
|
|
metadata: { task_id: 'task-1' },
|
|
},
|
|
],
|
|
process_artifacts: [],
|
|
};
|
|
}
|
|
|
|
describe('selectTaskProcess', () => {
|
|
it('merges persisted and live task process data while excluding other tasks', () => {
|
|
const liveRuns: ProcessRun[] = [
|
|
{
|
|
run_id: 'main-run',
|
|
session_id: 'web:default',
|
|
actor_type: 'agent',
|
|
actor_id: 'main',
|
|
actor_name: 'Main Agent',
|
|
title: 'Live main run',
|
|
status: 'running',
|
|
started_at: '2026-06-04T00:00:10.000Z',
|
|
metadata: { task_id: 'task-1' },
|
|
},
|
|
{
|
|
run_id: 'child-run',
|
|
parent_run_id: 'main-run',
|
|
session_id: 'subagent:child',
|
|
actor_type: 'agent',
|
|
actor_id: 'child',
|
|
actor_name: 'Child Agent',
|
|
title: 'Child work',
|
|
status: 'done',
|
|
started_at: '2026-06-04T00:00:30.000Z',
|
|
},
|
|
{
|
|
run_id: 'other-run',
|
|
session_id: 'web:default',
|
|
actor_type: 'agent',
|
|
actor_id: 'other',
|
|
actor_name: 'Other Agent',
|
|
title: 'Other task',
|
|
status: 'running',
|
|
started_at: '2026-06-04T00:00:40.000Z',
|
|
metadata: { task_id: 'task-2' },
|
|
},
|
|
];
|
|
const liveEvents: ProcessEvent[] = [
|
|
{
|
|
event_id: 'child-event',
|
|
run_id: 'child-run',
|
|
parent_run_id: 'main-run',
|
|
kind: 'run_progress',
|
|
actor_type: 'agent',
|
|
actor_id: 'child',
|
|
actor_name: 'Child Agent',
|
|
text: 'Child finished',
|
|
created_at: '2026-06-04T00:00:50.000Z',
|
|
},
|
|
{
|
|
event_id: 'other-event',
|
|
run_id: 'other-run',
|
|
kind: 'run_progress',
|
|
actor_type: 'agent',
|
|
actor_id: 'other',
|
|
actor_name: 'Other Agent',
|
|
text: 'Other task progress',
|
|
created_at: '2026-06-04T00:00:55.000Z',
|
|
metadata: { task_id: 'task-2' },
|
|
},
|
|
];
|
|
const liveArtifacts: ProcessArtifact[] = [
|
|
{
|
|
artifact_id: 'child-artifact',
|
|
run_id: 'child-run',
|
|
actor_type: 'agent',
|
|
actor_id: 'child',
|
|
actor_name: 'Child Agent',
|
|
title: 'Child result',
|
|
artifact_type: 'text',
|
|
created_at: '2026-06-04T00:01:00.000Z',
|
|
},
|
|
{
|
|
artifact_id: 'other-artifact',
|
|
run_id: 'other-run',
|
|
actor_type: 'agent',
|
|
actor_id: 'other',
|
|
title: 'Other result',
|
|
artifact_type: 'text',
|
|
created_at: '2026-06-04T00:01:05.000Z',
|
|
},
|
|
];
|
|
|
|
const selected = selectTaskProcess({
|
|
task: task(),
|
|
liveRuns,
|
|
liveEvents,
|
|
liveArtifacts,
|
|
});
|
|
|
|
expect(selected.runs.map((run) => run.run_id)).toEqual(['main-run', 'child-run']);
|
|
expect(selected.runs[0].title).toBe('Live main run');
|
|
expect(selected.events.map((event) => event.event_id)).toEqual(['persisted-event', 'child-event']);
|
|
expect(selected.artifacts.map((artifact) => artifact.artifact_id)).toEqual(['child-artifact']);
|
|
});
|
|
|
|
it('returns persisted task process data when no live data is available', () => {
|
|
const selected = selectTaskProcess({
|
|
task: task(),
|
|
liveRuns: [],
|
|
liveEvents: [],
|
|
liveArtifacts: [],
|
|
});
|
|
|
|
expect(selected.runs.map((run) => run.run_id)).toEqual(['main-run']);
|
|
expect(selected.events.map((event) => event.event_id)).toEqual(['persisted-event']);
|
|
expect(selected.artifacts).toEqual([]);
|
|
});
|
|
});
|