feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -1,29 +1,24 @@
|
||||
/**
|
||||
|
||||
* 对话页:Agent tool_run_progress 能力轮询(文件检核等异步任务进度卡片)。
|
||||
|
||||
* 依赖:useToolRunProgress、toolRunProgressConfig、ChatMessage。
|
||||
|
||||
* 逻辑:仅当 chat_logs.run_id 已绑定(消息含 run_id 或 for-log 已解析到批次)时展示进度卡片;未绑定时不展示等待条,后台仍轮询 for-log。
|
||||
|
||||
* features/chat/page/useChatPageToolRun.ts
|
||||
*
|
||||
* 用途:对话页 Agent tool_run_progress 能力轮询(文件检核等异步任务进度卡片)。
|
||||
* 依赖:useToolRunProgress、toolRunProgressConfig、agent-registry.utils、ChatMessage。
|
||||
* 逻辑:仅当 chat_logs.run_id 已绑定(消息含 run_id 或 for-log 已解析到批次)时展示进度卡片。
|
||||
*/
|
||||
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import type { ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
|
||||
import { getToolRunProgress } from '../api/toolRunProgress.api';
|
||||
|
||||
import type { ToolRunProgressConfig } from '../composables/useToolRunProgress';
|
||||
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
|
||||
import type { Ref } from 'vue';
|
||||
import { computed, nextTick, ref, watch, type Ref } from 'vue';
|
||||
|
||||
import {
|
||||
|
||||
agentHasTaskProgress,
|
||||
resolveToolRunProgressView,
|
||||
type AgentRegistryFields,
|
||||
} from '@/shared/utils/agent-registry.utils';
|
||||
import type { ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
import { getToolRunProgress } from '../api/toolRunProgress.api';
|
||||
import type { ToolRunProgressConfig } from '../composables/useToolRunProgress';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import {
|
||||
assistantMessageHasError,
|
||||
|
||||
buildFileCheckDetailUrl,
|
||||
buildFileCheckLogProgressUrl,
|
||||
collectAssistantProgressTargets,
|
||||
@@ -35,11 +30,8 @@ import {
|
||||
resolveToolRunProgressOptions,
|
||||
} from '../utils/toolRunProgressConfig';
|
||||
|
||||
|
||||
|
||||
export interface ChatPageToolRunContext {
|
||||
|
||||
currentAgent: Ref<{ id?: number; extra_config?: Record<string, unknown> } | null>;
|
||||
currentAgent: Ref<AgentRegistryFields | null>;
|
||||
|
||||
conversationId: Ref<string | null>;
|
||||
|
||||
@@ -69,47 +61,41 @@ export function useChatPageToolRun(ctx: ChatPageToolRunContext) {
|
||||
|
||||
|
||||
|
||||
const rawToolRunConfig = computed(() => {
|
||||
|
||||
const extra = ctx.currentAgent.value?.extra_config || {};
|
||||
|
||||
const raw = extra.tool_run_progress;
|
||||
|
||||
return raw && typeof raw === 'object' ? (raw as ToolRunProgressConfig) : null;
|
||||
|
||||
});
|
||||
|
||||
|
||||
const rawToolRunConfig = computed(() => resolveToolRunProgressView(ctx.currentAgent.value));
|
||||
|
||||
const toolRunProgressConfig = computed<ToolRunProgressConfig | null>(() => {
|
||||
const agent = ctx.currentAgent.value;
|
||||
if (!agent || !agentHasTaskProgress(agent)) return null;
|
||||
|
||||
const extra = ctx.currentAgent.value?.extra_config || {};
|
||||
const cfg = resolveToolRunProgressView(agent) || {};
|
||||
const handlerConfig = agent.handler_config && typeof agent.handler_config === 'object'
|
||||
? agent.handler_config
|
||||
: {};
|
||||
const boundTaskId = agent.bound_schedule_task_id;
|
||||
const pollRaw = Number(handlerConfig.poll_interval_seconds ?? cfg.poll_interval_seconds);
|
||||
const pollInterval = Number.isFinite(pollRaw) && pollRaw > 0 ? pollRaw : undefined;
|
||||
const lockRaw = handlerConfig.lock_input_when_running ?? cfg.lock_input_when_running;
|
||||
const lockInput = typeof lockRaw === 'boolean' ? lockRaw : undefined;
|
||||
|
||||
const capabilities = Array.isArray(extra.capabilities)
|
||||
|
||||
? extra.capabilities.map((item: unknown) => String(item))
|
||||
|
||||
: [];
|
||||
|
||||
if (!capabilities.includes('tool_run_progress')) return null;
|
||||
|
||||
const cfg = rawToolRunConfig.value;
|
||||
|
||||
if (!cfg) return null;
|
||||
const scheduleTaskId = boundTaskId ?? resolveScheduleTaskId(cfg);
|
||||
if (!scheduleTaskId) return null;
|
||||
|
||||
return {
|
||||
|
||||
...cfg,
|
||||
|
||||
schedule_task_id: resolveScheduleTaskId(cfg),
|
||||
|
||||
schedule_task_id: scheduleTaskId,
|
||||
poll_interval_seconds: pollInterval,
|
||||
lock_input_when_running: lockInput,
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const boundScheduleTaskId = computed(() => resolveScheduleTaskId(rawToolRunConfig.value));
|
||||
const boundScheduleTaskId = computed(() => {
|
||||
const agent = ctx.currentAgent.value;
|
||||
const fromColumn = Number(agent?.bound_schedule_task_id);
|
||||
if (Number.isFinite(fromColumn) && fromColumn > 0) return fromColumn;
|
||||
return resolveScheduleTaskId(rawToolRunConfig.value);
|
||||
});
|
||||
|
||||
const progressPollOptions = computed(() => resolveToolRunProgressOptions(rawToolRunConfig.value));
|
||||
|
||||
|
||||
Reference in new issue
Block a user