Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
file_tool.h
1
10#pragma once
11
12#include <agents-cpp/tool.h>
13
14namespace agents {
15namespace tools {
16
20class FileReadTool : public Tool {
21public:
26
32 ToolResult execute(const JsonObject& params) const override;
33
35protected:
39 void setupParameters();
40
46 bool validateFilePath(const String& filePath) const;
47
53 bool checkFileAccessibility(const String& filePath) const;
54
61 bool checkFileSize(const String& filePath, std::streamsize& fileSize) const;
62
69 String readFileContent(const String& filePath, std::streamsize fileSize) const;
70
78 ToolResult formatFileReadResult(const String& filePath, const String& content, std::streamsize fileSize) const;
80};
81
85class FileWriteTool : public Tool {
86public:
91
98 ToolResult execute(const JsonObject& params) const override;
99
101protected:
105 void setupParameters();
106
112 bool validateFilePath(const String& filePath) const;
113
119 bool validateContent(const String& content) const;
120
126 bool ensureDirectoryExists(const String& filePath) const;
127
134 bool writeFileContent(const String& filePath, const String& content) const;
135
142 bool verifyFileWrite(const String& filePath, std::streamsize& writtenSize) const;
143
151 ToolResult formatFileWriteResult(const String& filePath, const String& content, std::streamsize writtenSize) const;
153};
154
155} // namespace tools
156} // namespace agents
Tool(const String &name, const String &description)
Constructor.
ToolResult execute(const JsonObject &params) const override
Execute the file read tool.
FileReadTool()
Construct a new File Read Tool object.
ToolResult execute(const JsonObject &params) const override
Execute the file write tool.
FileWriteTool()
Construct a new File Write Tool object.
Tools Namespace.
Definition file_tool.h:15
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
Result of a tool execution.
Definition tool.h:22