mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-22 14:30:53 +08:00
24 lines
703 B
TypeScript
24 lines
703 B
TypeScript
import type { MessageEntry } from './sessionService.js'
|
|
|
|
export function collectErroredToolUseIds(messages: MessageEntry[]): Set<string> {
|
|
const erroredToolUseIds = new Set<string>()
|
|
|
|
for (const message of messages) {
|
|
if (message.type !== 'tool_result' || !Array.isArray(message.content)) continue
|
|
|
|
for (const block of message.content) {
|
|
if (!block || typeof block !== 'object') continue
|
|
const record = block as Record<string, unknown>
|
|
if (
|
|
record.type === 'tool_result' &&
|
|
record.is_error === true &&
|
|
typeof record.tool_use_id === 'string'
|
|
) {
|
|
erroredToolUseIds.add(record.tool_use_id)
|
|
}
|
|
}
|
|
}
|
|
|
|
return erroredToolUseIds
|
|
}
|