export function extractToolCalls(message) {
    return message.content.filter((content) => content.type === 'toolCall');
}
export function synthesizeOrphanedToolResults(message, errorText, ledger) {
    return extractToolCalls(message).map((toolCall) => {
        const existing = ledger.resultFor(toolCall.id);
        if (existing)
            return existing;
        return {
            role: 'toolResult',
            toolCallId: toolCall.id,
            toolName: toolCall.name,
            content: [{ type: 'text', text: errorText }],
            isError: true,
            timestamp: Date.now()
        };
    });
}
//# sourceMappingURL=agent-loop-orphan-repair.js.map