feat(engine): 添加技能查看工具并优化异步任务管理 - 添加SkillViewTool到引擎加载器中,增强技能管理功能 - 在AgentLoop中引入_active_direct_task来跟踪活跃任务 - 实现直接任务执行时的同步处理逻辑 - 更新工具实例化方式以支持依赖注入 feat(config): 增加智能体运行时参数配置支持 - 扩展AgentDefaultsConfig添加max_tokens和temperature字段 - 实现配置解析函数_first_config_value处理多个配置源 - 支持通过Web API动态更新智能体运行时参数 - 添加前端页面配置表单和验证逻辑 refactor(provider): 统一最大令牌数参数类型为可选整型 - 将所有LLM提供者的max_tokens参数改为int | None类型 - 为AnthropicProvider实现模型特定的最大令牌数默认值 - 调整参数传递逻辑,优先级:调用参数 > 配置文件 > 模型默认值 - 移除硬编码的默认值,改用条件判断 feat(process): 增强事件投影功能 - 添加工具调用开始/结束事件的映射逻辑 - 实现技能激活事件的识别和展示 - 添加辅助函数处理工具调用名称和参数提取 - 优化运行记录关联逻辑,提升事件匹配准确性 fix(web): 更新网络请求客户端信任环境设置 - 将WebFetchTool和WebSearchTool的trust_env参数设为True - 确保HTTP客户端能够正确使用系统代理配置 - 修复可能的网络连接问题 test: 添加配置加载和事件投影相关测试 - 新增智能体默认参数配置测试用例 - 实现API配置持久化和重载测试 - 添加技能卡片和工具事件的投影测试 ```
103 lines
4.2 KiB
TypeScript
103 lines
4.2 KiB
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
import { ArrowLeft, CheckCircle2, MessageSquare } from 'lucide-react';
|
|
|
|
import { TaskRuntimeStatusBadge, formatTaskRuntimeDuration, formatTaskRuntimeTime } from '@/components/task-runtime/TaskRuntimeShared';
|
|
import { Badge } from '@/components/ui/badge';
|
|
import { Button } from '@/components/ui/button';
|
|
import { pickAppText } from '@/lib/i18n/core';
|
|
import { useAppI18n } from '@/lib/i18n/provider';
|
|
import type { TaskRuntimeStatus } from '@/lib/task-runtime';
|
|
import type { BackendTask } from '@/types';
|
|
|
|
type Props = {
|
|
task: BackendTask;
|
|
activeLabel: string;
|
|
durationMs: number | null;
|
|
reviewTargetId?: string;
|
|
};
|
|
|
|
const RUNTIME_STATUSES = new Set<string>(['queued', 'running', 'waiting', 'blocked', 'done', 'error', 'cancelled']);
|
|
|
|
function isRuntimeStatus(status: string): status is TaskRuntimeStatus {
|
|
return RUNTIME_STATUSES.has(status);
|
|
}
|
|
|
|
function humanTaskStatus(status: string, locale: 'zh-CN' | 'en-US') {
|
|
const map: Record<string, [string, string]> = {
|
|
open: ['已创建', 'Open'],
|
|
running: ['执行中', 'Running'],
|
|
awaiting_acceptance: ['等待验收', 'Awaiting acceptance'],
|
|
needs_revision: ['需要修改', 'Needs revision'],
|
|
closed: ['已完成', 'Closed'],
|
|
abandoned: ['已放弃', 'Abandoned'],
|
|
};
|
|
const item = map[status];
|
|
return item ? pickAppText(locale, item[0], item[1]) : status;
|
|
}
|
|
|
|
export function TaskLiveHeader({ task, activeLabel, durationMs, reviewTargetId }: Props) {
|
|
const { locale } = useAppI18n();
|
|
const title = task.short_title || String(task.metadata?.short_title || '') || task.description || task.goal || task.task_id;
|
|
const showReviewLink = Boolean(reviewTargetId && ['awaiting_acceptance', 'needs_revision'].includes(task.status));
|
|
|
|
return (
|
|
<header className="sticky top-0 z-20 border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">
|
|
<div className="mx-auto flex max-w-7xl flex-col gap-3 px-4 py-3 sm:px-6">
|
|
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<Button asChild variant="outline" size="sm">
|
|
<Link href="/tasks">
|
|
<ArrowLeft className="mr-2 h-4 w-4" />
|
|
{pickAppText(locale, '返回任务', 'Back to tasks')}
|
|
</Link>
|
|
</Button>
|
|
<Button asChild variant="ghost" size="sm">
|
|
<Link href="/">
|
|
<MessageSquare className="mr-2 h-4 w-4" />
|
|
{pickAppText(locale, '对话', 'Chat')}
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
{isRuntimeStatus(task.status) ? (
|
|
<TaskRuntimeStatusBadge status={task.status} />
|
|
) : (
|
|
<Badge variant="outline" className="text-[11px]">
|
|
{humanTaskStatus(task.status, locale)}
|
|
</Badge>
|
|
)}
|
|
{activeLabel ? <Badge variant="secondary">{activeLabel}</Badge> : null}
|
|
{showReviewLink ? (
|
|
<Button asChild variant="default" size="sm">
|
|
<a href={`#${reviewTargetId}`}>
|
|
<CheckCircle2 className="mr-2 h-4 w-4" />
|
|
{pickAppText(locale, '验收', 'Review')}
|
|
</a>
|
|
</Button>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-2 lg:flex-row lg:items-end lg:justify-between">
|
|
<div className="min-w-0">
|
|
<h1 className="truncate text-xl font-semibold leading-tight">{title}</h1>
|
|
{task.description && task.description !== title ? (
|
|
<p className="mt-1 line-clamp-2 text-sm text-muted-foreground">{task.description}</p>
|
|
) : null}
|
|
</div>
|
|
<div className="flex shrink-0 flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground">
|
|
<span>
|
|
{pickAppText(locale, '更新', 'Updated')}: {formatTaskRuntimeTime(task.updated_at, locale)}
|
|
</span>
|
|
<span>
|
|
{pickAppText(locale, '耗时', 'Duration')}: {formatTaskRuntimeDuration(durationMs, locale)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|