forked from ZoneCog/elizaos-central
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell_demo.cpp
More file actions
66 lines (51 loc) · 2.25 KB
/
shell_demo.cpp
File metadata and controls
66 lines (51 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "elizaos/agentshell.hpp"
#include "elizaos/agentlogger.hpp"
#include "elizaos/agentcomms.hpp"
#include <iostream>
#include <thread>
#include <chrono>
using namespace elizaos;
int main() {
std::cout << "ElizaOS C++ Interactive Shell Demo" << std::endl;
std::cout << "===================================" << std::endl;
std::cout << std::endl;
// Initialize logger
globalLogger->printHeader("AgentShell Demo", LogColor::GREEN);
// Register a custom command for demo
registerShellCommand("demo", [](const std::vector<std::string>& args) -> ShellCommandResult {
(void)args; // Suppress unused parameter warning
logInfo("This is a demo command!", "shell-demo");
logSuccess("AgentShell is working correctly!", "shell-demo");
return ShellCommandResult(true, "Demo command executed successfully!", "", 0);
});
// Register an agent command
registerShellCommand("agent", [](const std::vector<std::string>& args) -> ShellCommandResult {
if (args.size() < 2) {
return ShellCommandResult(false, "", "Usage: agent <command>", 1);
}
std::string subCommand = args[1];
if (subCommand == "start") {
logInfo("Starting agent systems...", "shell-demo");
initializeComms();
return ShellCommandResult(true, "Agent systems started", "", 0);
} else if (subCommand == "stop") {
logInfo("Stopping agent systems...", "shell-demo");
shutdownComms();
return ShellCommandResult(true, "Agent systems stopped", "", 0);
} else {
return ShellCommandResult(false, "", "Unknown agent command: " + subCommand, 1);
}
});
logInfo("Starting interactive shell...", "shell-demo");
logInfo("Try these commands: demo, agent start, agent stop, status, help, exit", "shell-demo");
// Start the shell and wait for it to finish
startInteractiveShell();
// Wait for shell to complete
while (globalShell->isRunning()) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
// Ensure proper cleanup
globalShell->stop();
logInfo("Shell session ended", "shell-demo");
return 0;
}