feat: update historical event types
This commit is contained in:
@@ -99,8 +99,7 @@ export class PageAgentCore extends EventTarget {
|
|||||||
this.emitActivity({ type: 'retrying', attempt, maxAttempts })
|
this.emitActivity({ type: 'retrying', attempt, maxAttempts })
|
||||||
// Also push to history for panel rendering
|
// Also push to history for panel rendering
|
||||||
this.history.push({
|
this.history.push({
|
||||||
type: 'error',
|
type: 'retry',
|
||||||
errorType: 'retry',
|
|
||||||
message: `LLM retry attempt ${attempt} of ${maxAttempts}`,
|
message: `LLM retry attempt ${attempt} of ${maxAttempts}`,
|
||||||
attempt,
|
attempt,
|
||||||
maxAttempts,
|
maxAttempts,
|
||||||
@@ -114,7 +113,6 @@ export class PageAgentCore extends EventTarget {
|
|||||||
// Also push to history for panel rendering
|
// Also push to history for panel rendering
|
||||||
this.history.push({
|
this.history.push({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
errorType: 'error',
|
|
||||||
message,
|
message,
|
||||||
rawResponse: (error as InvokeError).rawResponse,
|
rawResponse: (error as InvokeError).rawResponse,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -69,14 +69,21 @@ export interface UserTakeoverEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error event (retry or error from LLM)
|
* Retry event - LLM call is being retried
|
||||||
|
*/
|
||||||
|
export interface RetryEvent {
|
||||||
|
type: 'retry'
|
||||||
|
message: string
|
||||||
|
attempt: number
|
||||||
|
maxAttempts: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error event - fatal error from LLM or execution
|
||||||
*/
|
*/
|
||||||
export interface AgentErrorEvent {
|
export interface AgentErrorEvent {
|
||||||
type: 'error'
|
type: 'error'
|
||||||
errorType: 'retry' | 'error'
|
|
||||||
message: string
|
message: string
|
||||||
attempt?: number
|
|
||||||
maxAttempts?: number
|
|
||||||
rawResponse?: unknown
|
rawResponse?: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +94,7 @@ export type HistoricalEvent =
|
|||||||
| AgentStepEvent
|
| AgentStepEvent
|
||||||
| ObservationEvent
|
| ObservationEvent
|
||||||
| UserTakeoverEvent
|
| UserTakeoverEvent
|
||||||
|
| RetryEvent
|
||||||
| AgentErrorEvent
|
| AgentErrorEvent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -608,6 +608,13 @@ export class Panel {
|
|||||||
)
|
)
|
||||||
} else if (event.type === 'user_takeover') {
|
} else if (event.type === 'user_takeover') {
|
||||||
cards.push(createCard({ icon: '👤', content: 'User takeover', meta, type: 'input' }))
|
cards.push(createCard({ icon: '👤', content: 'User takeover', meta, type: 'input' }))
|
||||||
|
} else if (event.type === 'retry') {
|
||||||
|
const retryInfo = `${event.message || 'Retrying'} (${event.attempt}/${event.maxAttempts})`
|
||||||
|
cards.push(createCard({ icon: '🔄', content: retryInfo, meta, type: 'observation' }))
|
||||||
|
} else if (event.type === 'error') {
|
||||||
|
cards.push(
|
||||||
|
createCard({ icon: '❌', content: event.message || 'Error', meta, type: 'observation' })
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cards
|
return cards
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export interface PanelAgentAdapter extends EventTarget {
|
|||||||
|
|
||||||
/** History of agent events */
|
/** History of agent events */
|
||||||
readonly history: readonly {
|
readonly history: readonly {
|
||||||
type: 'step' | 'observation' | 'user_takeover' | 'error'
|
type: 'step' | 'observation' | 'user_takeover' | 'retry' | 'error'
|
||||||
stepIndex?: number
|
stepIndex?: number
|
||||||
/** For 'step' type */
|
/** For 'step' type */
|
||||||
reflection?: {
|
reflection?: {
|
||||||
@@ -49,6 +49,11 @@ export interface PanelAgentAdapter extends EventTarget {
|
|||||||
}
|
}
|
||||||
/** For 'observation' type */
|
/** For 'observation' type */
|
||||||
content?: string
|
content?: string
|
||||||
|
/** For 'retry' type */
|
||||||
|
attempt?: number
|
||||||
|
maxAttempts?: number
|
||||||
|
/** For 'retry' and 'error' types */
|
||||||
|
message?: string
|
||||||
}[]
|
}[]
|
||||||
|
|
||||||
/** Current task being executed */
|
/** Current task being executed */
|
||||||
|
|||||||
Reference in New Issue
Block a user