#pragma once #include "tool.hpp" #include #include #include class QProcess; class QTimer; namespace ZShell::llm { class LlmClient; class ShellTool : public LlmTool { Q_OBJECT public: explicit ShellTool(LlmClient* client, QObject* parent = nullptr); ~ShellTool() override; QString name() const override; QString description() const override; QJsonObject parameters() const override; void execute( const QString& toolCallId, const QJsonObject& args, int outputBudgetChars, std::function done) override; void cancel() override; static constexpr int DefaultTimeoutSeconds = 60; static constexpr int MaxTimeoutSeconds = 300; private: struct Job { QPointer process; QPointer timer; int timeoutSeconds = DefaultTimeoutSeconds; int outputBudgetChars = 0; std::function done; QString startError; bool timedOut = false; bool cancelled = false; bool finished = false; }; static QStringList sandboxArguments(const QString& workspace); void finishJob(Job* job); QPointer m_client; QList m_jobs; }; } // namespace ZShell::llm