// Copyright (C) 2025-2026 Petr Mironychev // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include namespace QodeAssist { class ClaudeMessage : public QObject { Q_OBJECT public: explicit ClaudeMessage(QObject *parent = nullptr); void handleContentBlockStart(int index, const QString &blockType, const QJsonObject &data); void handleContentBlockDelta(int index, const QString &deltaType, const QJsonObject &delta); void handleContentBlockStop(int index); void handleStopReason(const QString &stopReason); QJsonObject toProviderFormat() const; QJsonArray createToolResultsContent(const QHash &toolResults) const; PluginLLMCore::MessageState state() const { return m_state; } QList getCurrentToolUseContent() const; QList getCurrentThinkingContent() const; QList getCurrentRedactedThinkingContent() const; const QList &getCurrentBlocks() const { return m_currentBlocks; } void startNewContinuation(); private: QString m_stopReason; PluginLLMCore::MessageState m_state = PluginLLMCore::MessageState::Building; QList m_currentBlocks; QHash m_pendingToolInputs; void updateStateFromStopReason(); template T *addCurrentContent(Args &&...args) { T *content = new T(std::forward(args)...); content->setParent(this); m_currentBlocks.append(content); return content; } }; } // namespace QodeAssist