feat: queue-based graph engine

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN-
2025-08-22 03:29:46 +08:00
parent f04844435f
commit 8c35663220
363 changed files with 20911 additions and 8927 deletions

View File

@ -21,7 +21,7 @@ const AgentLogTrigger = ({
<div
className='cursor-pointer rounded-[10px] bg-components-button-tertiary-bg'
onClick={() => {
onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)
onShowAgentOrToolLog({ message_id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)
}}
>
<div className='system-2xs-medium-uppercase flex items-center px-3 pt-2 text-text-tertiary'>

View File

@ -16,7 +16,7 @@ const AgentResultPanel = ({
}: AgentResultPanelProps) => {
const { t } = useTranslation()
const top = agentOrToolLogItemStack[agentOrToolLogItemStack.length - 1]
const list = agentOrToolLogListMap[top.id]
const list = agentOrToolLogListMap[top.message_id]
return (
<div className='overflow-y-auto bg-background-section'>
@ -29,7 +29,7 @@ const AgentResultPanel = ({
{
list.map(item => (
<AgentLogItem
key={item.id}
key={item.message_id}
item={item}
onShowAgentOrToolLog={onShowAgentOrToolLog}
/>

View File

@ -59,9 +59,9 @@ export const useLogs = () => {
agentOrToolLogItemStackRef.current = []
return
}
const { id, children } = detail
const { message_id: id, children } = detail
let currentAgentOrToolLogItemStack = agentOrToolLogItemStackRef.current.slice()
const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.id === id)
const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.message_id === id)
if (index > -1)
currentAgentOrToolLogItemStack = currentAgentOrToolLogItemStack.slice(0, index + 1)

View File

@ -9,10 +9,10 @@ const remove = (node: AgentLogItemWithChildren, removeId: string) => {
if (!children || children.length === 0)
return
const hasCircle = !!children.find(c => c.id === removeId)
const hasCircle = !!children.find(c => c.message_id === removeId)
if (hasCircle) {
node.hasCircle = true
node.children = node.children.filter(c => c.id !== removeId)
node.children = node.children.filter(c => c.message_id !== removeId)
children = node.children
}
@ -28,9 +28,9 @@ const removeRepeatedSiblings = (list: AgentLogItemWithChildren[]) => {
const result: AgentLogItemWithChildren[] = []
const addedItemIds: string[] = []
list.forEach((item) => {
if (!addedItemIds.includes(item.id)) {
if (!addedItemIds.includes(item.message_id)) {
result.push(item)
addedItemIds.push(item.id)
addedItemIds.push(item.message_id)
}
})
return result
@ -39,15 +39,15 @@ const removeRepeatedSiblings = (list: AgentLogItemWithChildren[]) => {
const removeCircleLogItem = (log: AgentLogItemWithChildren) => {
const newLog = cloneDeep(log)
newLog.children = removeRepeatedSiblings(newLog.children)
let { id, children } = newLog
let { message_id: id, children } = newLog
if (!children || children.length === 0)
return log
// check one step circle
const hasOneStepCircle = !!children.find(c => c.id === id)
const hasOneStepCircle = !!children.find(c => c.message_id === id)
if (hasOneStepCircle) {
newLog.hasCircle = true
newLog.children = newLog.children.filter(c => c.id !== id)
newLog.children = newLog.children.filter(c => c.message_id !== id)
children = newLog.children
}
@ -66,7 +66,7 @@ const listToTree = (logs: AgentLogItem[]) => {
logs.forEach((log) => {
const hasParent = !!log.parent_id
if (hasParent) {
const parent = logs.find(item => item.id === log.parent_id) as AgentLogItemWithChildren
const parent = logs.find(item => item.message_id === log.parent_id) as AgentLogItemWithChildren
if (parent) {
if (!parent.children)
parent.children = []