refactor: rename AgentStep to AgentStepEventErrorEvent to AgentErrorEvent

This commit is contained in:
Simon
2026-01-22 14:59:35 +08:00
parent 0cd04db40f
commit 3ffcd6482d
2 changed files with 10 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ import {
AgentActivity, AgentActivity,
AgentReflection, AgentReflection,
AgentStatus, AgentStatus,
AgentStep, AgentStepEvent,
ExecutionResult, ExecutionResult,
HistoricalEvent, HistoricalEvent,
MacroToolInput, MacroToolInput,
@@ -256,7 +256,7 @@ export class PageAgentCore extends EventTarget {
next_goal: input.next_goal, next_goal: input.next_goal,
} }
const actionName = Object.keys(input.action)[0] const actionName = Object.keys(input.action)[0]
const action: AgentStep['action'] = { const action: AgentStepEvent['action'] = {
name: actionName, name: actionName,
input: input.action[actionName], input: input.action[actionName],
output: output, output: output,
@@ -269,7 +269,7 @@ export class PageAgentCore extends EventTarget {
action, action,
usage: result.usage, usage: result.usage,
rawResponse: result.rawResponse, rawResponse: result.rawResponse,
} as AgentStep) } as AgentStepEvent)
this.#emitHistoryChange() this.#emitHistoryChange()
console.log(chalk.green('Step finished:'), actionName) console.log(chalk.green('Step finished:'), actionName)

View File

@@ -33,7 +33,7 @@ export interface MacroToolResult {
/** /**
* A single agent step with reflection and action * A single agent step with reflection and action
*/ */
export interface AgentStep { export interface AgentStepEvent {
type: 'step' type: 'step'
stepIndex: number stepIndex: number
reflection: Partial<AgentReflection> reflection: Partial<AgentReflection>
@@ -71,7 +71,7 @@ export interface UserTakeoverEvent {
/** /**
* Error event (retry or error from LLM) * Error event (retry or error from LLM)
*/ */
export interface ErrorEvent { export interface AgentErrorEvent {
type: 'error' type: 'error'
errorType: 'retry' | 'error' errorType: 'retry' | 'error'
message: string message: string
@@ -83,7 +83,11 @@ export interface ErrorEvent {
/** /**
* Union type for all history events * Union type for all history events
*/ */
export type HistoricalEvent = AgentStep | ObservationEvent | UserTakeoverEvent | ErrorEvent export type HistoricalEvent =
| AgentStepEvent
| ObservationEvent
| UserTakeoverEvent
| AgentErrorEvent
/** /**
* Agent execution status * Agent execution status