* @brief Builds the Blocked-tool rejection reply, with a device-control repair hint. */
| 2181 | * @brief Builds the Blocked-tool rejection reply, with a device-control repair hint. |
| 2182 | */ |
| 2183 | static QJsonObject makeBlockedReply(const QString& name) |
| 2184 | { |
| 2185 | qCWarning(AI::serialStudioAI) << "Tool execution blocked:" << name; |
| 2186 | QJsonObject error; |
| 2187 | error[QStringLiteral("code")] = QStringLiteral("blocked"); |
| 2188 | error[QStringLiteral("message")] = QStringLiteral("This command is blocked for AI safety."); |
| 2189 | if (AI::CommandRegistry::instance().isDeviceGated(name)) { |
| 2190 | error[QStringLiteral("repair")] = |
| 2191 | QStringLiteral("Hardware writes and connection changes must be performed by the user " |
| 2192 | "unless they enable the 'Allow device control' checkbox in the AI panel. " |
| 2193 | "Offer to build an Output Control tile instead; mention the checkbox only " |
| 2194 | "if the user explicitly wants you to drive the device."); |
| 2195 | } |
| 2196 | |
| 2197 | QJsonObject reply; |
| 2198 | reply[QStringLiteral("ok")] = false; |
| 2199 | reply[QStringLiteral("error")] = error; |
| 2200 | return reply; |
| 2201 | } |
| 2202 | |
| 2203 | /** |
| 2204 | * @brief Validates args and forwards to API::CommandRegistry honoring AI safety tags. |
no test coverage detected