chore: complete clean Agent Desk source snapshot
This commit is contained in:
36
web/lib/agent-activity-state.ts
Normal file
36
web/lib/agent-activity-state.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
export type AgentActivityInfo = {
|
||||
conversationId: number
|
||||
stepCode: string
|
||||
toolName?: string
|
||||
}
|
||||
|
||||
export type AgentActivityEventPayload = {
|
||||
conversationId?: number
|
||||
stepCode?: string
|
||||
toolName?: string
|
||||
status?: string
|
||||
}
|
||||
|
||||
export function resolveAgentActivityState(
|
||||
current: AgentActivityInfo | null,
|
||||
activeConversationId: number | undefined,
|
||||
payload: AgentActivityEventPayload | null | undefined
|
||||
): AgentActivityInfo | null {
|
||||
if (
|
||||
!payload ||
|
||||
!activeConversationId ||
|
||||
!payload.conversationId ||
|
||||
payload.conversationId !== activeConversationId ||
|
||||
!payload.stepCode
|
||||
) {
|
||||
return current
|
||||
}
|
||||
if (payload.status === "completed" || payload.status === "failed") {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
conversationId: payload.conversationId,
|
||||
stepCode: payload.stepCode,
|
||||
...(payload.toolName ? { toolName: payload.toolName } : {}),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user