refactor(core,server): 统一模块职责并消除类型重复
- 统一 ToolStatus 类型(Core 导出,Server 引用) - 重命名 Server SessionManager 为 SessionMetadataManager - 扩展 Core PermissionContext 添加结构化字段 - 统一 Part 类型导出(Core 定义存储格式,Server 定义展示格式) - 简化 Message 格式(移除 MergedMessage,统一使用 Message) - 添加向后兼容的类型别名和 @deprecated 注释
This commit is contained in:
@@ -13,8 +13,12 @@ export interface Session {
|
||||
|
||||
/**
|
||||
* 工具调用状态
|
||||
* 与 Core 的 ToolStatus 保持一致
|
||||
*/
|
||||
export type ToolCallStatus = 'pending' | 'running' | 'completed' | 'error';
|
||||
export type ToolStatus = 'pending' | 'running' | 'completed' | 'error';
|
||||
|
||||
/** @deprecated 使用 ToolStatus 代替 */
|
||||
export type ToolCallStatus = ToolStatus;
|
||||
|
||||
/**
|
||||
* 工具调用信息
|
||||
@@ -23,7 +27,7 @@ export interface ToolCallInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
arguments: Record<string, unknown>;
|
||||
status: ToolCallStatus;
|
||||
status: ToolStatus;
|
||||
result?: unknown;
|
||||
error?: string;
|
||||
duration?: number; // 执行时长 ms
|
||||
@@ -48,7 +52,7 @@ export interface ToolMessagePart {
|
||||
id: string;
|
||||
toolCallId: string;
|
||||
toolName: string;
|
||||
status: ToolCallStatus;
|
||||
status: ToolStatus;
|
||||
arguments: Record<string, unknown>;
|
||||
result?: unknown;
|
||||
error?: string;
|
||||
@@ -977,7 +981,7 @@ export type SubagentEventPayload =
|
||||
export interface SubagentToolInfo {
|
||||
id: string;
|
||||
toolName: string;
|
||||
status: ToolCallStatus;
|
||||
status: ToolStatus;
|
||||
args: Record<string, unknown>;
|
||||
result?: unknown;
|
||||
error?: string;
|
||||
|
||||
@@ -22,7 +22,7 @@ import { fadeInUp, smoothTransition } from '../utils/animations';
|
||||
import { getAgentDisplayName } from '../utils/agent';
|
||||
import { Markdown } from './Markdown';
|
||||
import { FileMentionText } from './FileMentionTag';
|
||||
import type { Message, ToolCallInfo, ToolCallStatus, ToolMessagePart } from '../api/types.js';
|
||||
import type { Message, ToolCallInfo, ToolStatus, ToolMessagePart } from '../api/types.js';
|
||||
|
||||
interface ChatMessageProps {
|
||||
message: Message;
|
||||
@@ -319,7 +319,7 @@ function ToolPartItem({ part }: ToolPartItemProps) {
|
||||
/**
|
||||
* 获取工具状态图标
|
||||
*/
|
||||
function getStatusIcon(status: ToolCallStatus) {
|
||||
function getStatusIcon(status: ToolStatus) {
|
||||
switch (status) {
|
||||
case 'pending':
|
||||
return <Clock size={14} className="text-yellow-500" />;
|
||||
|
||||
Reference in New Issue
Block a user