| 43 | } |
| 44 | |
| 45 | QJsonObject ExecuteTerminalCommandTool::parametersSchema() const |
| 46 | { |
| 47 | QJsonObject definition; |
| 48 | definition["type"] = "object"; |
| 49 | |
| 50 | const QStringList allowed = getAllowedCommands(); |
| 51 | const QString allowedList = allowed.isEmpty() ? "none" : allowed.join(", "); |
| 52 | |
| 53 | QJsonObject properties; |
| 54 | properties["command"] = QJsonObject{ |
| 55 | {"type", "string"}, |
| 56 | {"description", |
| 57 | QString("Name of the executable to run, WITHOUT any arguments or flags. " |
| 58 | "Must be exactly one of the allowed commands: %1. " |
| 59 | "Put every flag and argument in the separate `args` field. " |
| 60 | "Correct: command=\"ls\", args=\"-R\". " |
| 61 | "Incorrect: command=\"ls -R\" (the whole line in one field will be rejected).") |
| 62 | .arg(allowedList)}}; |
| 63 | |
| 64 | properties["args"] = QJsonObject{ |
| 65 | {"type", "string"}, |
| 66 | {"description", |
| 67 | "Optional arguments and flags for the command, as a single string. Do NOT repeat the " |
| 68 | "command name here. Arguments with spaces should be quoted. " |
| 69 | "Example: args=\"--file \\\"path with spaces.txt\\\" --verbose\"."}}; |
| 70 | |
| 71 | definition["properties"] = properties; |
| 72 | definition["required"] = QJsonArray{"command"}; |
| 73 | |
| 74 | return definition; |
| 75 | } |
| 76 | |
| 77 | QFuture<LLMQore::ToolResult> ExecuteTerminalCommandTool::executeAsync(const QJsonObject &input) |
| 78 | { |