Skip to content

Commit

Permalink
Update codingrabbitai.cpp
Browse files Browse the repository at this point in the history
refactored engine.
  • Loading branch information
bearycoolAI authored Jan 6, 2025
1 parent 7c03a86 commit 5af3a34
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions .devcontainer/codingrabbitai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <curl/curl.h> // For HTTP requests

// Version Info
const std::string VERSION = "3.0.0";
const std::string VERSION = "3.1.0";

// OAuth Token (Secure Storage Recommended)
const std::string OAUTH_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InBFbExHcnRHWHVCMjVWc1RUUGp3VSJ9..."; // Truncated for brevity
Expand Down Expand Up @@ -76,6 +76,8 @@ namespace Utils {
}

curl_easy_cleanup(curl);
} else {
Utils::log("CURL initialization failed");
}

return response;
Expand All @@ -95,7 +97,11 @@ namespace RabbitAI {

void run() {
Utils::log("Running task: " + name);
action();
try {
action();
} catch (const std::exception& e) {
Utils::log("Error in task " + name + ": " + e.what());
}
}
};

Expand Down Expand Up @@ -162,8 +168,12 @@ namespace RabbitAI {
public:
void execute(const std::string& command) {
Utils::log("Executing command: " + command);
std::string result = Utils::executeCommand(command);
std::cout << result << std::endl;
try {
std::string result = Utils::executeCommand(command);
std::cout << result << std::endl;
} catch (const std::exception& e) {
Utils::log("Error executing command: " + std::string(e.what()));
}
}
};
}
Expand All @@ -177,17 +187,26 @@ int main() {

// Initialize Environment
Environment env;
env.loadFromFile(".env");
env.print();
try {
env.loadFromFile(".env");
env.print();
} catch (const std::exception& e) {
Utils::log("Error loading environment: " + std::string(e.what()));
}

// Task Scheduler
Scheduler scheduler;

// Add OAuth-Integrated Tasks
scheduler.addTask(Task("Fetch OAuth-Protected Resource", []() {
std::string url = "https://dev-sfpqxik0rm3hw5f1.us.auth0.com/api/v2/users";
std::string response = Utils::apiRequest(url);
Utils::log("API Response: " + response);
std::string response;
try {
response = Utils::apiRequest(url);
Utils::log("API Response: " + response);
} catch (const std::exception& e) {
Utils::log("Error fetching resource: " + std::string(e.what()));
}
}));

// Add RabbitProtocol Tasks
Expand Down

0 comments on commit 5af3a34

Please sign in to comment.