diff --git a/taicpp/Makefile b/taicpp/Makefile index 081c557..dcb130d 100644 --- a/taicpp/Makefile +++ b/taicpp/Makefile @@ -1,7 +1,7 @@ CXX ?= g++ CXXSTD = -std=c++23 WARN = -Wall -Wextra -CXXFLAGS ?= $(CXXSTD) $(WARN) -O2 +CXXFLAGS ?= $(CXXSTD) $(WARN) -O2 -I../../moloapp/src BUILD = build VERSION = $(shell cat VERSION) BIN = $(BUILD)/detz @@ -30,7 +30,7 @@ $(BIN): $(MAIN_OBJ) $(ALL_OBJS) $(CXX) $(CXXFLAGS) $(MAIN_OBJ) $(ALL_OBJS) -lsqlite3 -lcurl -o $@ static: $(MAIN_OBJ) $(ALL_OBJS) - $(CXX) $(CXXFLAGS) -pthread -static $(MAIN_OBJ) $(ALL_OBJS) /tmp/curlb/inst/lib/libcurl.a /usr/lib/x86_64-linux-gnu/libsqlite3.a -lssl -lcrypto /tmp/jent/libjitterentropy.a -lzstd -lz -lnghttp2 -lpsl -lbrotlidec -lidn2 -lrtmp -o build/detz-static + $(CXX) $(CXXFLAGS) -pthread -static $(MAIN_OBJ) $(ALL_OBJS) third_party/curl/libcurl.a third_party/sqlite/libsqlite3.a -lssl -lcrypto third_party/jitterentropy/libjitterentropy.a -lzstd -lz -lnghttp2 -lpsl -lbrotlidec -lidn2 -lrtmp -o build/detz-static $(BUILD)/store_test: tests/store_test.cpp src/store/store.cpp @mkdir -p $(BUILD) $(CXX) $(CXXFLAGS) -Isrc/store tests/store_test.cpp src/store/store.cpp -lsqlite3 -lcurl -o $@ diff --git a/taicpp/main.cpp b/taicpp/main.cpp index bf8815c..fd3acd6 100644 --- a/taicpp/main.cpp +++ b/taicpp/main.cpp @@ -8,7 +8,7 @@ #include int main(int argc, char** argv){ detz::cli::Parser p; auto cmd = p.parse(argc, argv); - if(cmd.opts.version){ std::puts(std::string(detz::kVersion).c_str()); return 0; } + if(cmd.opts.version){ std::puts(("tai " + std::string(detz::kVersion)).c_str()); return 0; } if(cmd.opts.cap_manifest){ std::fputs("# tai CAP agent manifest\n", stdout); return 0; } if(cmd.name=="run" && !cmd.args.empty()){ detz::agent::ToolRegistry reg; detz::agent::RegisterAll(reg, "."); diff --git a/taicpp/src/cli/cli.cpp b/taicpp/src/cli/cli.cpp index df7915a..5121c2c 100644 --- a/taicpp/src/cli/cli.cpp +++ b/taicpp/src/cli/cli.cpp @@ -4,18 +4,97 @@ #include namespace detz::cli { std::string Parser::helpText() { - return std::string("usage: tai [options] [prompt...]\n\noptions:\n" - " --profile P --yes --yolo --auto --continue --debug [SINK] --debug-format FORMAT\n" - " --env E --no-opencode --update-models --eval-retrieval --stats-rag --version\n" - " --cap-manifest --cap-speak --cap-cwd DIR --cap-model MODEL\n" - " --cap-permission-mode MODE --cap-max-turns N --cap COMMAND...\n" - " --serve-mcp KEY --mcp-port PORT --mcp-bind HOST\n" - " --telegram --scheduler --install --install-telegram --uninstall-telegram\n" - " --plexer-wrap --mplex COMMAND... --demo --demo-shot --tui --tui-local --theme NAME\n" - " --model MODEL --task TASK --cwd DIR --driver D --binary B --argv A\n" - " --allow-tool T --deny-tool T --max-risk R --auto-answer A\n" - " --help (-h)\n version ") + std::string(kVersion) + "\n"; + return std::string( + std::string( + "usage: tai [-h] [--profile PROFILE] [--yes] [--yolo] [--auto] [--continue]\n" + " [--debug [SINK]] [--debug-format FORMAT] [--env ENV]\n" + " [--no-opencode] [--update-models] [--eval-retrieval] [--stats-rag]\n" + " [--version] [--cap-manifest] [--cap-speak] [--cap-cwd DIR]\n" + " [--cap-model MODEL]\n" + " [--cap-permission-mode {none,confirm,interactive}]\n" + " [--cap-max-turns N] [--cap ...] [--serve-mcp KEY] [--mcp-port PORT]\n" + " [--mcp-bind HOST] [--telegram] [--scheduler] [--install]\n" + " [--install-telegram] [--uninstall-telegram] [--plexer-wrap]\n" + " [--mplex ...] [--demo] [--demo-shot] [--tui] [--tui-local]\n" + " [--theme NAME]\n" + " [prompt ...]\n" + "\n" + "single-file autonomous agent, standard library only\n" + "\n" + "positional arguments:\n" + " prompt\n" + "\n" + "options:\n" + " -h, --help show this help message and exit\n" + " --profile PROFILE\n" + " --yes\n" + " --yolo\n" + " --auto\n" + " --continue\n" + " --debug [SINK] extensive debug logging to /debug.log (file),\n" + " stdout, or stderr, plus the vault logs table (see\n" + " logging.md)\n" + " --debug-format FORMAT\n" + " debug log line format, sentence or json (default\n" + " sentence, or TAI_DEBUG_FORMAT)\n" + " --env ENV\n" + " --no-opencode skip the opencode CLI backends for this run (same as\n" + " TAI_OPENCODE=0)\n" + " --update-models rediscover the free model lists of every provider,\n" + " drop models that are gone, and exit\n" + " --eval-retrieval score vault retrieval (Hit@K, MRR, nDCG, Context\n" + " Precision) on generated goldens plus implicit pairs,\n" + " print the report, and exit\n" + " --stats-rag print RAG usage and effectiveness stats (vault totals,\n" + " searches, reads, per-record context uses, retrieval\n" + " eval) and exit\n" + " --version\n" + " --cap-manifest print tai's CAP agent manifest (cap-agent.toml) and\n" + " exit\n" + " --cap-speak speak CAP stream-json on stdio as an agent (bulk\n" + " session config via CAP_SESSION_CONFIG)\n" + " --cap-cwd DIR speak session working directory (overrides\n" + " CAP_SESSION_CONFIG cwd)\n" + " --cap-model MODEL speak session model label (overrides\n" + " CAP_SESSION_CONFIG model)\n" + " --cap-permission-mode {none,confirm,interactive}\n" + " speak session permission mode (overrides\n" + " CAP_SESSION_CONFIG permission_mode)\n" + " --cap-max-turns N speak session turn cap (overrides CAP_SESSION_CONFIG\n" + " max_turns)\n" + " --cap ... orchestrator: resolve, chat or run fleet commands (see\n" + " cap.md)\n" + " --serve-mcp KEY serve MCP over HTTP (Streamable HTTP): all native\n" + " tools plus chat/completions, Bearer KEY required (see\n" + " mcp.md)\n" + " --mcp-port PORT serve-mcp port (default TAI_MCP_PORT else 8765)\n" + " --mcp-bind HOST serve-mcp bind address (default TAI_MCP_BIND else\n" + " 127.0.0.1)\n" + " --telegram\n" + " --scheduler\n" + " --install\n" + " --install-telegram\n" + " --uninstall-telegram\n" + " --plexer-wrap internal: invoked by the bashrc plexer hook, not meant\n" + " to be run by hand\n" + " --mplex ... terminal multiplexer: any mplex command (new-session,\n" + " attach-session, list-keys ...); bare --mplex starts a\n" + " session. Config: ~/.tai/mplex.toml\n" + " --demo run the fullscreen TUI framework showcase\n" + " --demo-shot print one composed demo frame as text and exit\n" + " --tui run the fullscreen grr client (bots, chats,\n" + " automations, library, projects, settings) against the\n" + " grr server; address in GRR_URL\n" + " --tui-local run the fullscreen Telegram-style chat UI on the local\n" + " vault, no server needed\n" + " --theme NAME TUI theme: dark, light, nord, gruvbox, ansi (or\n" + " TAI_THEME)\n") + + std::string("\n version ") + std::string(kVersion) + std::string("\n")); } + + + + Options Parser::parseOpts(int argc, char** argv) { Options o; for (int i = 1; i < argc; ++i) { @@ -81,7 +160,7 @@ Command Parser::parse(int argc, char** argv) { return c; } int Command::run() { - if (opts.version || name=="--version") { std::puts(std::string(kVersion).c_str()); return 0; } + if (opts.version || name=="--version") { std::puts(("tai " + std::string(kVersion)).c_str()); return 0; } std::fputs(Parser::helpText().c_str(), stdout); return 0; } diff --git a/taicpp/src/cli/cli.h b/taicpp/src/cli/cli.h index 3b38901..63511b9 100644 --- a/taicpp/src/cli/cli.h +++ b/taicpp/src/cli/cli.h @@ -2,6 +2,8 @@ #include #include #include +#include "tenancy/strategy.h" +#include "tenancy/tenant.h" namespace detz::cli { struct Options { std::optional profile; @@ -31,5 +33,21 @@ struct Options { struct Command { std::string name{"--help"}; std::vector args; Options opts; int run(); }; class Parser { public: Options parseOpts(int argc, char** argv); Command parse(int argc, char** argv); static std::string helpText(); }; class DetzCli { public: int run(int argc, char** argv); }; -class MoloSubcommand { public: const char* name() const { return "detz"; } }; +class MoloSubcommand { + public: + explicit MoloSubcommand(std::string profile = "default") : profile_(std::move(profile)) {} + // Maps a detz --profile to a molo tenancy Tenant: profile becomes the + // tenant slug, strategy shared-schema, status active. Header-only, no I/O. + const char* name() const { return "detz"; } + const std::string& profile() const { return profile_; } + std::string tenantSlug() const { return profile_.empty() ? "default" : profile_; } + // Real molo tenancy object: profile slug, shared-schema, active. + molo::tenancy::Tenant tenant() const { + return molo::tenancy::Tenant("detz-" + tenantSlug(), tenantSlug(), + molo::tenancy::Strategy::SharedSchema, + molo::tenancy::TenantStatus::Active, 0, 0, 0); + } + private: + std::string profile_; +}; } // namespace detz::cli diff --git a/taicpp/third_party/curl/libcurl.a b/taicpp/third_party/curl/libcurl.a new file mode 100644 index 0000000..6eb529d Binary files /dev/null and b/taicpp/third_party/curl/libcurl.a differ diff --git a/taicpp/third_party/jitterentropy/libjitterentropy.a b/taicpp/third_party/jitterentropy/libjitterentropy.a new file mode 100644 index 0000000..aaf66a0 Binary files /dev/null and b/taicpp/third_party/jitterentropy/libjitterentropy.a differ diff --git a/taicpp/third_party/sqlite/libsqlite3.a b/taicpp/third_party/sqlite/libsqlite3.a new file mode 100644 index 0000000..b94d59d Binary files /dev/null and b/taicpp/third_party/sqlite/libsqlite3.a differ