feat: Add agents and agents settings

This commit is contained in:
Petr Mironychev
2026-05-26 12:30:11 +02:00
parent 51ebe3e523
commit 97236c6069
70 changed files with 4308 additions and 296 deletions

View File

@@ -0,0 +1,11 @@
add_library(Common INTERFACE)
target_sources(Common INTERFACE
ContextData.hpp
)
target_include_directories(Common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(Common INTERFACE
Qt::Core
)

View File

@@ -0,0 +1,79 @@
// Copyright (C) 2024-2026 Petr Mironychev
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QJsonObject>
#include <QString>
#include <QVector>
#include <optional>
namespace QodeAssist::Templates {
struct ContentBlockEntry
{
enum class Kind {
Text,
Thinking,
RedactedThinking,
ToolUse,
ToolResult,
Image,
};
Kind kind = Kind::Text;
QString text; // Text
QString thinking; // Thinking
QString signature; // Thinking / RedactedThinking
QString toolUseId; // ToolUse / ToolResult
QString toolName; // ToolUse
QJsonObject toolInput; // ToolUse
QString result; // ToolResult
QString imageData; // Image (base64 or url)
QString mediaType; // Image
bool isImageUrl = false;
bool operator==(const ContentBlockEntry &) const = default;
};
struct Message
{
QString role;
QVector<ContentBlockEntry> blocks;
// Convenience for callers that only need a single text block.
static Message text(const QString &role, const QString &text)
{
Message m;
m.role = role;
ContentBlockEntry e;
e.kind = ContentBlockEntry::Kind::Text;
e.text = text;
m.blocks.append(std::move(e));
return m;
}
bool operator==(const Message &) const = default;
};
struct FileMetadata
{
QString filePath;
QString content;
bool operator==(const FileMetadata &) const = default;
};
struct ContextData
{
std::optional<QString> systemPrompt = std::nullopt;
std::optional<QString> prefix = std::nullopt;
std::optional<QString> suffix = std::nullopt;
std::optional<QString> fileContext = std::nullopt;
std::optional<QVector<Message>> history = std::nullopt;
std::optional<QList<FileMetadata>> filesMetadata = std::nullopt;
bool operator==(const ContextData &) const = default;
};
} // namespace QodeAssist::Templates