refactor(agent): replace OMP with Claude Code kernel

This commit is contained in:
xiaohan.yuan committed 2026-10-20 14:47:56 +08:00
1 parent 0fb2226f8c
commit 9a1f182397
232 files changed
+2561 -25564

No files matched your search

+2 -8
View File
@@ -13,10 +13,9 @@ export function getMessageParts(message: ChatMessage): MessagePart[] {
/** 主进程持久化和渲染进程使用同一事件归约,避免重载前后内容顺序不同。 */
export function applyAssistantEvent(message: ChatMessage, event: ChatEvent): ChatMessage {
switch (event.type) {
case 'run_usage': return { ...message, runUsage: event.usage }
case 'usage': {
const contextUsage = normalizeContextUsageSnapshot({ usage: event.usage, contextWindow: event.contextWindow,
source:event.source,sampledAt:event.sampledAt,requestId:event.runId,modelId:event.modelId,nativeEntryId:event.nativeEntryId })
source:event.source,sampledAt:event.sampledAt,requestId:event.runId,modelId:event.modelId })
return contextUsage ? { ...message, contextUsage } : message
}
case 'context_breakdown': {
@@ -32,7 +31,6 @@ export function applyAssistantEvent(message: ChatMessage, event: ChatEvent): Cha
if (part.type === 'plan') return `plan:${part.plan.id}`
if (part.type === 'task') return `task:${part.task.id}`
if (part.type === 'artifact') return `artifact:${part.artifact.id}`
if (part.type === 'subagent') return `subagent:${part.agent.id}`
return undefined
}
const key = identity(event.part)
@@ -94,11 +92,7 @@ export function applyAssistantEvent(message: ChatMessage, event: ChatEvent): Cha
tool.status === 'running' ? { ...tool, status } : tool
)
const interactions = message.interactions?.map((item) => item.status === 'pending' || item.status === 'responding' ? { ...item, status: 'cancelled' as const } : item)
const parts = message.parts?.map((part): MessagePart => part.type === 'subagent' && ['queued', 'running'].includes(part.agent.status)
? { ...part, agent: { ...part.agent, status: 'cancelled', finishedAt: Date.now(),
tools: part.agent.tools.map(tool => tool.status === 'running' ? { ...tool, status: 'cancelled' } : tool),
events: part.agent.events.map(item => item.status === 'running' ? { ...item, status: 'cancelled' } : item) } } : part)
return { ...message, tools, interactions, parts, status, error: event.type === 'error' ? event.message : message.error, ...terminalDuration(event) }
return { ...message, tools, interactions, parts: message.parts, status, error: event.type === 'error' ? event.message : message.error, ...terminalDuration(event) }
}
default:
return message