* @brief Returns AI-tool catalog derived from API::CommandRegistry, minus Blocked entries. */
| 1858 | * @brief Returns AI-tool catalog derived from API::CommandRegistry, minus Blocked entries. |
| 1859 | */ |
| 1860 | QJsonArray AI::ToolDispatcher::availableTools(const QString& category) const |
| 1861 | { |
| 1862 | QJsonArray tools; |
| 1863 | auto appendVirtual = [&tools, &category](const QVector<detail::AssistantToolDef>& defs) { |
| 1864 | for (const auto& def : defs) { |
| 1865 | if (!category.isEmpty() && !def.name.startsWith(category)) |
| 1866 | continue; |
| 1867 | |
| 1868 | QJsonObject tool; |
| 1869 | tool[QStringLiteral("name")] = def.name; |
| 1870 | tool[QStringLiteral("description")] = def.description; |
| 1871 | tool[QStringLiteral("inputSchema")] = def.inputSchema; |
| 1872 | tools.append(tool); |
| 1873 | } |
| 1874 | }; |
| 1875 | appendVirtual(assistantToolDefs()); |
| 1876 | appendVirtual(fsToolDefs()); |
| 1877 | |
| 1878 | const auto& commands = API::CommandRegistry::instance().commands(); |
| 1879 | const auto& aiReg = AI::CommandRegistry::instance(); |
| 1880 | |
| 1881 | for (auto it = commands.constBegin(); it != commands.constEnd(); ++it) { |
| 1882 | const auto& def = it.value(); |
| 1883 | if (aiReg.safetyOf(def.name) == Safety::Blocked) |
| 1884 | continue; |
| 1885 | |
| 1886 | if (!category.isEmpty() && !def.name.startsWith(category)) |
| 1887 | continue; |
| 1888 | |
| 1889 | QJsonObject tool; |
| 1890 | tool[QStringLiteral("name")] = def.name; |
| 1891 | tool[QStringLiteral("description")] = def.description; |
| 1892 | tool[QStringLiteral("inputSchema")] = def.inputSchema; |
| 1893 | tools.append(tool); |
| 1894 | } |
| 1895 | |
| 1896 | return tools; |
| 1897 | } |
| 1898 | |
| 1899 | /** |
| 1900 | * @brief Name + one-line description for every meta.* tool advertised by Conversation.cpp; must |
no test coverage detected