Full port of the Store (17 tables, FTS5, per-profile slices, sessions, turn state, bots, settings, MCP registry), DebugLog, SETTINGS_CATALOG and boot_settings, ShellSession (as ShellContext), Conversation persistence, Repl/Boot, and the PlexerController family with FlowValidator/PlexerFlow. Verified by replaying 643 operations through tai.py and the C++ code (results, tables, FTS, schema, files identical) and by restarting the REPL under per-pane shells and checking the vault. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
// The real Repl on the real Conversation and Store, with a scripted host in
|
|
// place of the model loop (no model is called). Used by tests/repl_persist.py,
|
|
// which starts it repeatedly under chosen shells and checks the vault.
|
|
//
|
|
// repl_probe [--profile NAME] [--continue] [--yolo] [--oneshot TEXT]
|
|
//
|
|
// Host behaviour: every input line becomes a user message plus the assistant
|
|
// reply "echo: <line>"; the input "CRASH" saves a checkpoint with the turn
|
|
// still open and kills the process (an interrupted turn for --continue).
|
|
#include <unistd.h>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include "config/config.h"
|
|
#include "repl/boot.h"
|
|
#include "repl/repl.h"
|
|
#include "session/conversation.h"
|
|
#include "session/shell_context.h"
|
|
#include "store/store.h"
|
|
using namespace detz;
|
|
|
|
class EchoHost : public repl::ReplHost {
|
|
public:
|
|
explicit EchoHost(session::Conversation& conv) : conv_(conv) {}
|
|
std::string run_turn(const std::string& text) override {
|
|
conv_.begin_turn(text);
|
|
conv_.add_message("user", text);
|
|
if (text == "CRASH") {
|
|
conv_.checkpoint();
|
|
std::fflush(stdout);
|
|
::_exit(9);
|
|
}
|
|
std::string reply = "echo: " + text;
|
|
conv_.add_message("assistant", reply);
|
|
conv_.close_turn();
|
|
return reply;
|
|
}
|
|
|
|
private:
|
|
session::Conversation& conv_;
|
|
};
|
|
|
|
int main(int argc, char** argv) {
|
|
std::string profile = "default", oneshot;
|
|
bool resume = false, yolo = false, has_oneshot = false;
|
|
for (int i = 1; i < argc; i++) {
|
|
std::string a = argv[i];
|
|
if (a == "--profile" && i + 1 < argc) profile = argv[++i];
|
|
else if (a == "--continue") resume = true;
|
|
else if (a == "--yolo") yolo = true;
|
|
else if (a == "--oneshot" && i + 1 < argc) { oneshot = argv[++i]; has_oneshot = true; }
|
|
}
|
|
repl::BootOptions boot;
|
|
boot.profile = profile;
|
|
boot.yolo = yolo;
|
|
boot.version = "probe";
|
|
boot.mode = has_oneshot ? "one-shot" : "repl";
|
|
auto session = repl::Boot::open(boot);
|
|
session::Conversation& conv = *session->conversation;
|
|
EchoHost host(conv);
|
|
repl::Repl::Options options;
|
|
options.version = "probe";
|
|
options.resume = resume;
|
|
repl::Repl app(conv, host, options);
|
|
if (has_oneshot) return app.oneshot(oneshot);
|
|
return app.run();
|
|
}
|