Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pangea-Agent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gavin-Group
Pangea-Agent
Commits
39fed4a2
Commit
39fed4a2
authored
Dec 21, 2025
by
ligaowei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shared type definitions and utility functions for timeline events
parent
998f1d1d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
0 deletions
+154
-0
timeline.ts
frontend/src/types/timeline.ts
+60
-0
timelineUtils.ts
frontend/src/utils/timelineUtils.ts
+39
-0
typeGuards.ts
frontend/src/utils/typeGuards.ts
+55
-0
No files found.
frontend/src/types/timeline.ts
0 → 100644
View file @
39fed4a2
// 统一的时间轴事件类型定义
export
interface
BaseTimelineEvent
{
type
:
string
;
title
:
string
;
timestamp
:
number
;
metadata
?:
Record
<
string
,
any
>
;
}
export
interface
ThoughtEvent
extends
BaseTimelineEvent
{
content
:
string
;
thinkingType
?:
string
;
}
export
interface
ToolCallEvent
extends
BaseTimelineEvent
{
toolName
:
string
;
toolAction
?:
string
;
toolInput
?:
any
;
toolStatus
:
string
;
}
export
interface
ToolResultEvent
extends
BaseTimelineEvent
{
toolName
:
string
;
toolAction
?:
string
;
toolOutput
?:
any
;
toolStatus
:
string
;
executionTime
?:
number
;
}
export
interface
ToolErrorEvent
extends
BaseTimelineEvent
{
toolName
:
string
;
errorMessage
:
string
;
errorCode
?:
string
;
}
export
interface
EmbedEvent
extends
BaseTimelineEvent
{
embedUrl
:
string
;
embedType
?:
string
;
embedTitle
:
string
;
embedHtmlContent
?:
string
;
}
export
type
TimelineEvent
=
|
ThoughtEvent
|
ToolCallEvent
|
ToolResultEvent
|
ToolErrorEvent
|
EmbedEvent
|
BaseTimelineEvent
;
// 事件类型标签映射
export
const
eventTypeLabels
:
Record
<
string
,
string
>
=
{
thought
:
'🧠 思考'
,
tool_call
:
'🔧 工具调用'
,
tool_result
:
'✅ 工具结果'
,
tool_error
:
'❌ 工具错误'
,
embed
:
'🌐 网页预览'
,
log
:
'📝 日志'
,
result
:
'🎯 最终答案'
,
observation
:
'🔍 观察'
};
\ No newline at end of file
frontend/src/utils/timelineUtils.ts
0 → 100644
View file @
39fed4a2
// 时间轴工具函数库
/**
* 检查是否为工具事件类型
* @param type 事件类型
* @returns 是否为工具事件类型
*/
export
function
isToolEventType
(
type
:
string
):
boolean
{
return
[
'tool_call'
,
'tool_result'
,
'tool_error'
].
includes
(
type
);
}
/**
* 检查工具输入是否有效
* @param event 事件对象
* @returns 工具输入是否有效
*/
export
function
hasValidToolInput
(
event
:
any
):
boolean
{
return
event
.
type
===
'tool_call'
&&
event
.
toolInput
!==
null
&&
event
.
toolInput
!==
undefined
;
}
/**
* 检查工具输出是否有效
* @param event 事件对象
* @returns 工具输出是否有效
*/
export
function
hasValidToolOutput
(
event
:
any
):
boolean
{
return
event
.
type
===
'tool_result'
&&
event
.
toolOutput
!==
null
&&
event
.
toolOutput
!==
undefined
;
}
/**
* 截断标题
* @param title 标题
* @param maxLength 最大长度
* @returns 截断后的标题
*/
export
function
truncateTitle
(
title
:
string
,
maxLength
:
number
=
30
):
string
{
if
(
!
title
)
return
''
;
return
title
.
length
>
maxLength
?
title
.
substring
(
0
,
maxLength
)
+
'...'
:
title
;
}
\ No newline at end of file
frontend/src/utils/typeGuards.ts
0 → 100644
View file @
39fed4a2
// 类型守卫函数
import
type
{
TimelineEvent
,
ThoughtEvent
,
ToolCallEvent
,
ToolResultEvent
,
ToolErrorEvent
,
EmbedEvent
}
from
'../types/timeline'
;
/**
* 检查是否为思考事件
* @param event 事件对象
* @returns 是否为思考事件
*/
export
function
isThoughtEvent
(
event
:
TimelineEvent
):
event
is
ThoughtEvent
{
return
event
.
type
===
'thought'
;
}
/**
* 检查是否为工具调用事件
* @param event 事件对象
* @returns 是否为工具调用事件
*/
export
function
isToolCallEvent
(
event
:
TimelineEvent
):
event
is
ToolCallEvent
{
return
event
.
type
===
'tool_call'
;
}
/**
* 检查是否为工具结果事件
* @param event 事件对象
* @returns 是否为工具结果事件
*/
export
function
isToolResultEvent
(
event
:
TimelineEvent
):
event
is
ToolResultEvent
{
return
event
.
type
===
'tool_result'
;
}
/**
* 检查是否为工具错误事件
* @param event 事件对象
* @returns 是否为工具错误事件
*/
export
function
isToolErrorEvent
(
event
:
TimelineEvent
):
event
is
ToolErrorEvent
{
return
event
.
type
===
'tool_error'
;
}
/**
* 检查是否为嵌入事件
* @param event 事件对象
* @returns 是否为嵌入事件
*/
export
function
isEmbedEvent
(
event
:
TimelineEvent
):
event
is
EmbedEvent
{
return
event
.
type
===
'embed'
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment