diff --git a/packages/page-agent/src/PageAgent.ts b/packages/page-agent/src/PageAgent.ts index 5e8919b..ee8e882 100644 --- a/packages/page-agent/src/PageAgent.ts +++ b/packages/page-agent/src/PageAgent.ts @@ -184,6 +184,7 @@ export class PageAgent extends EventTarget { */ pushObservation(content: string): void { this.history.push({ type: 'observation', content }) + this.panel.update({ type: 'observation', content }) } async execute(task: string): Promise { diff --git a/packages/ui/src/Panel.module.css b/packages/ui/src/Panel.module.css index 840643c..4e807b7 100644 --- a/packages/ui/src/Panel.module.css +++ b/packages/ui/src/Panel.module.css @@ -352,6 +352,11 @@ background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(255, 214, 0, 0.05)); } + &.observation { + border-left-color: rgb(147, 51, 234); + background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(147, 51, 234, 0.05)); + } + /* 突出显示 done 成功结果 */ &.doneSuccess { background: linear-gradient( diff --git a/packages/ui/src/Panel.ts b/packages/ui/src/Panel.ts index 1c6a201..7c6ef70 100644 --- a/packages/ui/src/Panel.ts +++ b/packages/ui/src/Panel.ts @@ -27,6 +27,7 @@ export type PanelUpdate = | { type: 'completed' } | { type: 'toolExecuting'; toolName: string; args: any } | { type: 'toolCompleted'; toolName: string; args: any; result?: string; duration?: number } + | { type: 'observation'; content: string } /** * Agent control panel @@ -196,6 +197,8 @@ export class Panel { duration: data.duration, } } + case 'observation': + return { type: 'observation', displayText: data.content } } } @@ -581,7 +584,7 @@ export class Panel { typeClass = styles.error statusIcon = '❌' } else if (step.type === 'tool_executing') { - statusIcon = '⚙️' + statusIcon = '🔨' } else if (step.type === 'output') { typeClass = styles.output statusIcon = '🤖' @@ -591,6 +594,9 @@ export class Panel { } else if (step.type === 'retry') { typeClass = styles.retry statusIcon = '🔄' + } else if (step.type === 'observation') { + typeClass = styles.observation + statusIcon = '👁️' } else { statusIcon = '🧠' } diff --git a/packages/ui/src/UIState.ts b/packages/ui/src/UIState.ts index 59b2db9..1782e1b 100644 --- a/packages/ui/src/UIState.ts +++ b/packages/ui/src/UIState.ts @@ -6,7 +6,15 @@ export interface Step { id: string stepNumber: number timestamp: Date - type: 'thinking' | 'tool_executing' | 'completed' | 'error' | 'output' | 'input' | 'retry' + type: + | 'thinking' + | 'tool_executing' + | 'completed' + | 'error' + | 'output' + | 'input' + | 'retry' + | 'observation' // Tool execution related toolName?: string