diff --git a/README.md b/README.md index 85c0c9f..5ebd63d 100644 --- a/README.md +++ b/README.md @@ -299,8 +299,8 @@ A bot cannot start a conversation - the user has to write first, otherwise the API answers `chat not found`. That is Telegram, not the harness. The bot registers the commands that actually exist with `setMyCommands`: -`/start`, `/help`, `/interview`, `/model`, `/connect`, every command a loaded -plugin registers +`/start`, `/help`, `/interview`, `/new`, `/model`, `/connect`, every command a +loaded plugin registers (`/goal`, `/recap`, `/tasks`, `/quota`, `/tmux`, ...) and every program in `~/.splinter/commands/` whose name is a valid Telegram command (lower-case, digits, underscore, at most 32). `/start` and `/help` answer with the short @@ -315,6 +315,9 @@ is split at tag boundaries, with the open tags closed and reopened per message, and a piece Telegram refuses to parse is sent as plain text instead. `SPLINTER_TG_MARKDOWN=0` turns the rendering off. +`/new` (or `/reset`) starts a fresh conversation and a fresh session file; the +old one stays on disk, and the system prompt is put back. + `/model` lists the models the config names (the main endpoint, every delegate with a model, every exit) as buttons and points the running transport at the one you press. The choice is written to `.d/90-model.conf`, so the next @@ -323,7 +326,8 @@ endpoint and takes another model from it. `/model probe` asks every endpoint `/v1/models` and offers what it really serves. The TUI has the same `/model` (list, or `/model `), without buttons. -`/connect` adds a provider in four answers — name, endpoint, model, key +`/connect` works the same in the TUI, one answer per line. It adds a provider +in four answers — name, endpoint, model, key variable (or `-` for none); `ollama` and `opencode` stand for their usual endpoint. It writes the line to `.d/20-connect.conf`, so the next start has the provider too, runs one tiny turn against it to prove endpoint, model diff --git a/docs/CONFIG.md b/docs/CONFIG.md index ec699cd..6cb6070 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -164,7 +164,8 @@ specific instruction. ## Adding a provider from the chat -`/connect` in the Telegram gateway asks for a name, an endpoint, a model and the +`/connect` — in the Telegram gateway and in the TUI (one answer per line) — +asks for a name, an endpoint, a model and the variable that holds the key, then writes one `delegate` line to `.d/20-connect.conf` — the drop-in next to the file that is in use, so `--config` works too. Adding the same name again replaces its line. The diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6ce3172..478b9d2 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -31,6 +31,9 @@ Stream. den Turn mit lcm bei 8 KiB und 32 KiB Budget und zählt die Kompressionen - **Tabellen im Chat**: `src/md.c` erkennt Kopf + Trenner, rechnet Spaltenbreiten und zeichnet ausgerichteten Text (`test_md`, `test_ui.sh`) +- **Neue Konversation**: `/new` bzw. `/reset` im Gateway und im TUI; neue + Sitzungsdatei, Konversation auf den System-Prompt zurueck + (`test_gateway.sh`, `test_ui.sh`); `/connect` auch im TUI - **Modelle wechseln und Provider anlegen**: `/model` liest die konfigurierten Modelle (Haupt-Endpoint, Delegates, Exits), haengt den Transport um, merkt die Wahl in `90-model.conf` und fragt per `/model probe` die Endpoints nach diff --git a/include/splinter.h b/include/splinter.h index ed6e7d6..cd8f751 100644 --- a/include/splinter.h +++ b/include/splinter.h @@ -99,6 +99,12 @@ int sp_conv_add(struct sp_conv *, const struct sp_msg *); int sp_conv_insert(struct sp_conv *, size_t at, const struct sp_msg *); int sp_conv_push(struct sp_conv *, const char *role, const char *name, const char *content); +/* + * Start over: drop every message and keep only the system prompt (may be + * NULL). The session file stays; it is the record of what was said, and a + * fresh session is a new file next to it. + */ +int sp_conv_reset(struct sp_conv *, const char *system_prompt); size_t sp_conv_bytes(const struct sp_conv *); int sp_conv_trim(struct sp_conv *, size_t keep_last); diff --git a/share/locale/de.msg b/share/locale/de.msg index 5a007f1..1cdf9e3 100644 --- a/share/locale/de.msg +++ b/share/locale/de.msg @@ -131,6 +131,10 @@ interview.written = Geschrieben: %s interview.error.nodir = interview: kein Sitzungsverzeichnis interview.error.write = interview: kann %s nicht schreiben # /model und /connect (Gateway) +session.new = Neue Konversation: %s +session.failed = Konnte keine neue Sitzung anlegen: %s +tg.cmd.new = neue Konversation + tg.cmd.model = ein Modell waehlen tg.cmd.connect = einen Provider hinzufuegen model.choose = Waehle ein Modell. Die Liste kommt aus der Konfiguration; die Wahl gilt fuer diese Sitzung. diff --git a/share/locale/en.msg b/share/locale/en.msg index 57cc13d..3398a24 100644 --- a/share/locale/en.msg +++ b/share/locale/en.msg @@ -130,6 +130,10 @@ interview.written = Written: %s interview.error.nodir = interview: no session directory interview.error.write = interview: cannot write %s # /model and /connect (gateway) +session.new = New conversation: %s +session.failed = Could not start a new session: %s +tg.cmd.new = new conversation + tg.cmd.model = choose a model tg.cmd.connect = add a provider model.choose = Choose a model. The list is the configuration; the choice lasts for this session. diff --git a/share/locale/pt_BR.msg b/share/locale/pt_BR.msg index 08f7595..4b8cb01 100644 --- a/share/locale/pt_BR.msg +++ b/share/locale/pt_BR.msg @@ -134,6 +134,10 @@ interview.written = Escrito: %s interview.error.nodir = interview: sem diretorio de sessao interview.error.write = interview: nao consigo escrever %s # /model e /connect (gateway) +session.new = Nova conversa: %s +session.failed = Nao consegui abrir uma sessao nova: %s +tg.cmd.new = nova conversa + tg.cmd.model = escolher um modelo tg.cmd.connect = adicionar um provedor model.choose = Escolha um modelo. A lista e a configuracao; a escolha vale para esta sessao. diff --git a/src/conv.c b/src/conv.c index 850cf75..7ef576d 100644 --- a/src/conv.c +++ b/src/conv.c @@ -20,6 +20,17 @@ sp_conv_init(struct sp_conv *c) memset(c, 0, sizeof(*c)); } +static void +msg_free(struct sp_msg *m) +{ + free(m->role); + free(m->name); + free(m->call_id); + free(m->content); + free(m->calls); + memset(m, 0, sizeof(*m)); +} + void sp_conv_free(struct sp_conv *c) { @@ -27,17 +38,27 @@ sp_conv_free(struct sp_conv *c) if (c == NULL) return; - for (i = 0; i < c->n; i++) { - free(c->v[i].role); - free(c->v[i].name); - free(c->v[i].call_id); - free(c->v[i].content); - free(c->v[i].calls); - } + for (i = 0; i < c->n; i++) + msg_free(&c->v[i]); free(c->v); memset(c, 0, sizeof(*c)); } +int +sp_conv_reset(struct sp_conv *c, const char *system_prompt) +{ + size_t i; + + if (c == NULL) + return -1; + for (i = 0; i < c->n; i++) + msg_free(&c->v[i]); + c->n = 0; + if (system_prompt != NULL && *system_prompt != '\0') + return sp_conv_push(c, "system", NULL, system_prompt); + return 0; +} + static char * dup_or_empty(const char *s) { diff --git a/src/telegram.c b/src/telegram.c index 27236d7..33db16c 100644 --- a/src/telegram.c +++ b/src/telegram.c @@ -533,6 +533,7 @@ tg_collect(struct sp_host *host, const char *sess_dir, struct tg_cmd *cmds, tg_add_cmd(cmds, n, "start", tg_known_desc("start")); tg_add_cmd(cmds, n, "help", tg_known_desc("help")); tg_add_cmd(cmds, n, "interview", sp_t("tg.cmd.interview")); + tg_add_cmd(cmds, n, "new", sp_t("tg.cmd.new")); tg_add_cmd(cmds, n, "model", sp_t("tg.cmd.model")); tg_add_cmd(cmds, n, "connect", sp_t("tg.cmd.connect")); if (sp_buf_init(&list) != 0) @@ -597,7 +598,7 @@ tg_help_text(struct sp_host *host, const char *sess_dir, struct sp_buf *out) char dir[700]; sp_buf_puts(out, sp_t("tg.help")); - sp_buf_puts(out, "\n\n/start /help /interview /model /connect "); + sp_buf_puts(out, "\n\n/start /help /interview /new /model /connect "); if (host != NULL) (void)sp_host_command_help(host, out); if (sp_cmdscript_dir(sess_dir, dir, sizeof(dir)) == 0 && @@ -775,6 +776,7 @@ tg_interview_answer(const char *token, long chat_id, const char *text, tg_interview_end(token, chat_id, session_dir, err); } + /* * /model: the models this run was configured with, as buttons. Nothing is * probed and nothing is written: the choice is one field of the transport, and @@ -1347,6 +1349,52 @@ tg_connect_answer(const char *token, long chat_id, const char *text, (void)tg_connect_ask(token, chat_id, err); } +/* + * /new: a fresh conversation and a fresh session file. The system prompt is + * part of the conversation, so it has to be put back; the old session file is + * left alone, it is the record of what was said. + */ +static void +tg_new_conversation(const char *token, long chat_id, struct sp_agent *ag, + struct sp_buf *err) +{ + static struct sp_session_info fresh; + struct sp_buf msg, serr; + char id[64], dir[512]; + + if (ag == NULL || ag->sess == NULL || ag->cfg == NULL) + return; + /* 'fresh' may be the current session: read the directory before it is + * cleared, or the second /new starts from an empty path */ + snprintf(dir, sizeof(dir), "%s", ag->sess->dir); + memset(&fresh, 0, sizeof(fresh)); + snprintf(id, sizeof(id), "sess-%ld-%d", (long)time(NULL), (int)getpid()); + sp_buf_init(&serr); + if (sp_session_open(&fresh, dir, id, &serr) != 0) { + if (sp_buf_init(&msg) == 0) { + sp_buf_printf(&msg, sp_t("session.failed"), + serr.p != NULL && serr.len > 0 ? serr.p : "?"); + (void)send_message(token, chat_id, msg.p, err); + sp_buf_free(&msg); + } + sp_buf_free(&serr); + return; + } + sp_buf_free(&serr); + if (sp_conv_reset(ag->conv, ag->cfg->system_prompt) != 0) { + (void)send_message(token, chat_id, sp_t("err.oom"), err); + return; + } + ag->sess = &fresh; + memset(&tg_iv, 0, sizeof(tg_iv)); + memset(&tg_cc, 0, sizeof(tg_cc)); + if (sp_buf_init(&msg) == 0) { + sp_buf_printf(&msg, sp_t("session.new"), fresh.id); + (void)send_message(token, chat_id, msg.p, err); + sp_buf_free(&msg); + } +} + /* * An inline keyboard answer: ack::yes|no for an approval, model: for a * model, mlater for "not now". The button travels as a callback_query, not a @@ -1756,6 +1804,13 @@ sp_telegram_run(struct sp_agent *ag, struct sp_host *host, const char *token, sp_buf_clear(err); continue; } + if (strcmp(text, "/new") == 0 || + strcmp(text, "/reset") == 0) { + tg_new_conversation(token, chat_id, ag, + err); + sp_buf_clear(err); + continue; + } if (strcmp(text, "/start") == 0 || strcmp(text, "/help") == 0) { struct sp_buf help; diff --git a/src/ui.c b/src/ui.c index f6fac3e..6e9b8c3 100644 --- a/src/ui.c +++ b/src/ui.c @@ -40,6 +40,8 @@ #include "splinter_plugin.h" #include "config.h" #include "providers.h" +#include +#include #include "md.h" #include "theme.h" #include "ui.h" @@ -84,6 +86,14 @@ struct ui_state { char cur_endpoint[512]; /* owned: /model moves them */ char cur_model[256]; struct sp_config *conf; /* for /model, may be NULL */ + struct ui_connect { /* /connect, one answer per line */ + int active; + int step; + char id[64]; + char endpoint[520]; + char model[260]; + char key_env[80]; + } cc; int quit; struct sp_theme theme; struct swarm *sw; /* local fleet, may be NULL/SWARM_NONE */ @@ -1670,6 +1680,114 @@ ui_shell(struct ui_state *s, struct sp_agent *ag, const char *cmd) * list what exists. Returns 1 when the line was handled; 0 when a program in * commands/ replaced it with text for the model, so a turn runs with 'input'. */ +/* /connect in the terminal: the same questions the gateway asks, per line */ +static void +ui_connect_ask(struct ui_state *s, struct sp_buf *out) +{ + switch (s->cc.step) { + case 1: + sp_buf_puts(out, sp_t("connect.endpoint")); + break; + case 2: + sp_buf_puts(out, sp_t("connect.model")); + break; + case 3: + if (s->cc.key_env[0] != '\0') + sp_buf_printf(out, sp_t("connect.key_named"), + s->cc.key_env); + else + sp_buf_puts(out, sp_t("connect.key")); + break; + default: + sp_buf_puts(out, sp_t("connect.name")); + break; + } +} + +/* returns 1: the line was an answer (handled), 0: no flow is running */ +static int +ui_connect_answer(struct ui_state *s, struct sp_agent *ag, const char *line, + struct sp_buf *out) +{ + (void)ag; + if (!s->cc.active) + return 0; + if (strcmp(line, "/cancel") == 0 || strcasecmp(line, "cancel") == 0) { + memset(&s->cc, 0, sizeof(s->cc)); + sp_buf_puts(out, sp_t("connect.cancel")); + return 1; + } + switch (s->cc.step) { + case 0: + if (!sp_provider_id_ok(line)) { + sp_buf_puts(out, sp_t("connect.name_bad")); + return 1; + } + snprintf(s->cc.id, sizeof(s->cc.id), "%s", line); + break; + case 1: + if (strcmp(line, "ollama") == 0) { + snprintf(s->cc.endpoint, sizeof(s->cc.endpoint), + "http://127.0.0.1:11434/v1/chat/completions"); + } else if (strcmp(line, "opencode") == 0) { + snprintf(s->cc.endpoint, sizeof(s->cc.endpoint), + "https://opencode.ai/zen/go/v1/chat/completions"); + snprintf(s->cc.key_env, sizeof(s->cc.key_env), + "OPENCODE_GO_API_KEY"); + } else if (!sp_provider_endpoint_ok(line)) { + sp_buf_puts(out, sp_t("connect.endpoint_bad")); + return 1; + } else { + snprintf(s->cc.endpoint, sizeof(s->cc.endpoint), "%s", + line); + } + break; + case 2: + if (!sp_provider_model_ok(line)) { + sp_buf_puts(out, sp_t("connect.model_bad")); + return 1; + } + snprintf(s->cc.model, sizeof(s->cc.model), "%s", line); + break; + default: + if (strcmp(line, "-") == 0) + s->cc.key_env[0] = '\0'; + else if (strcmp(line, "/skip") != 0) { + if (!sp_provider_key_ok(line)) { + sp_buf_puts(out, sp_t("connect.key_bad")); + return 1; + } + snprintf(s->cc.key_env, sizeof(s->cc.key_env), "%s", + line); + } + { + char dir[720]; + struct sp_buf cerr; + + sp_buf_init(&cerr); + if (s->conf == NULL || + sp_provider_dir(dir, sizeof(dir)) != 0) { + sp_buf_puts(out, sp_t("connect.nodir")); + } else if (sp_provider_add(s->conf, dir, s->cc.id, + s->cc.endpoint, s->cc.model, s->cc.key_env, + &cerr) != 0) { + sp_buf_printf(out, sp_t("connect.failed"), + cerr.p != NULL ? cerr.p : "?"); + } else { + sp_buf_printf(out, sp_t("connect.saved"), + s->cc.id, s->cc.model, s->cc.endpoint); + } + sp_buf_free(&cerr); + } + memset(&s->cc, 0, sizeof(s->cc)); + return 1; + } + s->cc.step++; + sp_buf_puts(out, "\n"); + ui_connect_ask(s, out); + return 1; +} + static int ui_slash(struct ui_state *s, struct sp_agent *ag, struct sp_host *host, char *input, size_t cap) @@ -1862,6 +1980,57 @@ ui_slash(struct ui_state *s, struct sp_agent *ag, struct sp_host *host, add_entry(s, "splinter", outbuf); return 1; } + if (strcmp(name, "new") == 0 || strcmp(name, "reset") == 0) { + static struct sp_session_info fresh; + char id[64], dir[512]; + struct sp_buf serr; + + /* 'fresh' may be the current session: read the directory first */ + snprintf(dir, sizeof(dir), "%s", + ag->sess != NULL ? ag->sess->dir : ""); + memset(&fresh, 0, sizeof(fresh)); + snprintf(id, sizeof(id), "sess-%ld-%d", (long)time(NULL), + (int)getpid()); + sp_buf_init(&serr); + if (ag->sess == NULL || + sp_session_open(&fresh, dir, id, &serr) != 0 || + sp_conv_reset(ag->conv, ag->cfg != NULL ? + ag->cfg->system_prompt : NULL) != 0) { + sp_buf_printf(&out, sp_t("session.failed"), + serr.p != NULL ? serr.p : "?"); + } else { + ag->sess = &fresh; + s->n = 0; /* the pane is the old conversation */ + s->scroll = 0; + sp_buf_printf(&out, sp_t("session.new"), fresh.id); + } + sp_buf_free(&serr); + snprintf(outbuf, sizeof(outbuf), "%s", out.p ? out.p : ""); + sp_buf_free(&out); + add_entry(s, "splinter", outbuf); + return 1; + } + if (strcmp(name, "connect") == 0) { + if (sp_config_loaded_path() == NULL) { + /* --no-config: there is no file to write the line to */ + sp_buf_puts(&out, sp_t("connect.nodir")); + snprintf(outbuf, sizeof(outbuf), "%s", + out.p != NULL ? out.p : ""); + sp_buf_free(&out); + add_entry(s, "splinter", outbuf); + return 1; + } + memset(&s->cc, 0, sizeof(s->cc)); + s->cc.active = 1; + s->cc.step = 0; + sp_buf_puts(&out, sp_t("connect.start")); + sp_buf_puts(&out, "\n"); + ui_connect_ask(s, &out); + snprintf(outbuf, sizeof(outbuf), "%s", out.p ? out.p : ""); + sp_buf_free(&out); + add_entry(s, "splinter", outbuf); + return 1; + } if (host != NULL && sp_host_command(host, name, args, &out) == 0) { snprintf(outbuf, sizeof(outbuf), "%s", out.p != NULL ? out.p : ""); sp_buf_free(&out); @@ -2458,6 +2627,16 @@ sp_ui_run(struct sp_agent *ag, const char *endpoint, const char *model, if (input[0] == '/' && input[1] != '\0' && ui_slash(&s, ag, host, input, sizeof(input))) continue; + if (s.cc.active) { + struct sp_buf o; + + if (sp_buf_init(&o) == 0) { + (void)ui_connect_answer(&s, ag, input, &o); + add_entry(&s, "splinter", o.p != NULL ? o.p : ""); + sp_buf_free(&o); + } + continue; + } hist_push(&s, SESS_DIR(ag), input); s.scroll = 0; diff --git a/src/www/index.en.html b/src/www/index.en.html index bd77709..a4b2de2 100644 --- a/src/www/index.en.html +++ b/src/www/index.en.html @@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }

splinter_

An agent harness you own: chat in the terminal, tools with authorization classes, plugins, any model that speaks OpenAI — built by us so we can change it, instead of getting used to how somebody else's client behaves.

-

28508 lines of C99/POSIX · +

28769 lines of C99/POSIX · 25 tools · 35 test programs · 16 plugins · 42 palettes · BSD-3-Clause

@@ -141,7 +141,7 @@ plugin = plugins/reminder/reminder.so

Gateway: Telegram

splinter --daemon long-polls getUpdates, one turn per message, answers with sendMessage. The token lives in ~/.splinter/telegram.token with mode 0600 and is never passed as an argument — arguments end up in ps. While a turn runs, the chat sees "typing" every four seconds.

-

The bot registers its commands: the menu shows the loaded plugins' commands and the programs in ~/.splinter/commands/; an approval arrives with Yes/No buttons. /interview asks the questions in the chat. /model offers the configured models as buttons, switches the transport and remembers the choice in splinter.conf.d/90-model.conf; /model probe asks the endpoints for /v1/models. /connect asks for name, endpoint, model and key variable, runs one test turn and writes the provider to splinter.conf.d/20-connect.conf. Answers are rendered as Telegram HTML: bold, italic, code and links as tags, tables as columns in a monospace block; a piece Telegram cannot parse goes out as text instead of being lost. Programs in commands/ answer in the chat; in the TUI their output goes to the model.

+

The bot registers its commands: the menu shows the loaded plugins' commands and the programs in ~/.splinter/commands/; an approval arrives with Yes/No buttons. /interview asks the questions in the chat. /new starts a fresh conversation; /model offers the configured models as buttons, switches the transport and remembers the choice in splinter.conf.d/90-model.conf; /model probe asks the endpoints for /v1/models. /connect asks for name, endpoint, model and key variable, runs one test turn and writes the provider to splinter.conf.d/20-connect.conf. Answers are rendered as Telegram HTML: bold, italic, code and links as tags, tables as columns in a monospace block; a piece Telegram cannot parse goes out as text instead of being lost. Programs in commands/ answer in the chat; in the TUI their output goes to the model.

Slash commands work there too. Programs in ~/.splinter/commands/ become /name: they get the rest of the line as an argument, and their output goes to the model as context — not to you as a reply. That is how the model fetches what it cannot see itself.

What gets written down

diff --git a/src/www/index.html b/src/www/index.html index 1a4d1ba..4558487 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }

splinter_

Ein Agent-Harness, das dir gehoert: Chat im Terminal, Werkzeuge mit Autorisierungsklassen, Plugins, jedes Modell das OpenAI spricht — von uns gebaut, damit wir es umbauen koennen, statt uns an das Verhalten eines fremden Clients zu gewoehnen.

-

28508 Zeilen C99/POSIX · +

28769 Zeilen C99/POSIX · 25 Werkzeuge · 35 Test-Programme · 16 Plugins · 42 Farbschemata · BSD-3-Clause

@@ -141,7 +141,7 @@ plugin = plugins/reminder/reminder.so

Gateway: Telegram

splinter --daemon pollt getUpdates, ein Turn pro Nachricht, Antwort per sendMessage. Der Token liegt in ~/.splinter/telegram.token mit Modus 0600 und wird nie als Argument uebergeben — Argumente stehen in ps. Waehrend eines Turns sieht der Chat alle vier Sekunden „typing“.

-

Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in ~/.splinter/commands/; eine Zustimmung kommt mit Ja/Nein-Knoepfen. /interview stellt die Fragen im Chat. /model bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in splinter.conf.d/90-model.conf; /model probe fragt die Endpoints nach /v1/models. /connect fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach splinter.conf.d/20-connect.conf. Antworten werden als Telegram-HTML gesetzt: fett, kursiv, Code und Links als Tags, Tabellen als Spalten im Monospace-Block; ein Stueck, das Telegram nicht parst, geht als Text raus statt verloren. Programme in commands/ antworten dort direkt im Chat; im TUI gehen sie ans Modell.

+

Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in ~/.splinter/commands/; eine Zustimmung kommt mit Ja/Nein-Knoepfen. /interview stellt die Fragen im Chat. /new faengt eine frische Konversation an; /model bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in splinter.conf.d/90-model.conf; /model probe fragt die Endpoints nach /v1/models. /connect fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach splinter.conf.d/20-connect.conf. Antworten werden als Telegram-HTML gesetzt: fett, kursiv, Code und Links als Tags, Tabellen als Spalten im Monospace-Block; ein Stueck, das Telegram nicht parst, geht als Text raus statt verloren. Programme in commands/ antworten dort direkt im Chat; im TUI gehen sie ans Modell.

Slash-Kommandos funktionieren dort genauso. Programme in ~/.splinter/commands/ werden zu /name: sie bekommen den Rest der Zeile als Argument, und ihre Ausgabe geht ans Modell als Kontext — nicht an dich als Antwort. Damit holt sich das Modell, was es selbst nicht sehen kann.

Was mitgeschrieben wird

diff --git a/src/www/index.pt.html b/src/www/index.pt.html index c0e6152..674bd34 100644 --- a/src/www/index.pt.html +++ b/src/www/index.pt.html @@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }

splinter_

Um harness de agente que e seu: chat no terminal, ferramentas com classes de autorizacao, plugins, qualquer modelo que fale OpenAI - escrito por nos para poder mudar-lo, em vez de nos acostumar com o comportamento de um cliente alheio.

-

28508 linhas C99/POSIX · +

28769 linhas C99/POSIX · 25 ferramentas · 35 programas de teste · 16 plugins · 42 paletas · BSD-3-Clause

@@ -110,7 +110,7 @@ em ordem de nome. Chave desconhecida e erro com numero de linha.

mesmos slash commands do terminal. O bot registra seus comandos: o menu mostra os comandos dos plugins carregados e os programas em ~/.splinter/commands/; uma aprovacao chega com botoes Sim/Nao; as respostas viram HTML do Telegram (negrito, codigo, links, -tabelas em bloco monoespaceado). /model lista os modelos +tabelas em bloco monoespaceado). /new comeca uma conversa nova; /model lista os modelos configurados em botoes, troca o transporte e guarda a escolha em splinter.conf.d/90-model.conf; /model probe pergunta aos endpoints por /v1/models. /connect pergunta nome, diff --git a/tests/test_gateway.sh b/tests/test_gateway.sh index cfde53e..4fdca8f 100755 --- a/tests/test_gateway.sh +++ b/tests/test_gateway.sh @@ -129,6 +129,11 @@ run_text "zeig eine tabelle" '
' 50
 check "a table is drawn in a monospace block" grep -q '
' "$D/sent.log"
 check "a table keeps its columns" grep -q '| a | b  |' "$D/sent.log"
 
+# /new starts a fresh conversation and a fresh session file
+run_text "/new" 'Neue Konversation: sess-' 45
+check "the bot says the new session" grep -q '^Neue Konversation: sess-' "$D/sent.log"
+check "a session file was opened" sh -c "ls '$D'/home/.splinter/sess-*.jsonl | tail -1 | grep -q sess-"
+
 # /model offers the configured models and switches on the button
 run_text "/model" 'Provider far' 60
 check "the model menu lists the configured providers" \
diff --git a/tests/test_ui.sh b/tests/test_ui.sh
index f510245..7b88293 100755
--- a/tests/test_ui.sh
+++ b/tests/test_ui.sh
@@ -96,6 +96,10 @@ check shows 'main  m'
 check shows 'Choose a model'
 typed '/model andere'; key Enter
 check shows 'Model: andere (provider main'
+typed '/new'; key Enter
+check shows 'New conversation: sess-'
+typed '/connect'; key Enter
+check shows 'No configuration directory to write to.'
 typed 'schreib die datei'; key Enter
 check shows 'changes files'
 key y
diff --git a/tools/gen_www.py b/tools/gen_www.py
index f9fac9c..183c4fc 100644
--- a/tools/gen_www.py
+++ b/tools/gen_www.py
@@ -305,7 +305,7 @@ SECTIONS = {
    "sendMessage. Der Token liegt in "
    "~/.splinter/telegram.token mit Modus 0600 und wird nie als Argument "
    "uebergeben — Argumente stehen in ps. Waehrend eines Turns sieht der "
-   "Chat alle vier Sekunden „typing“.

\n

Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in ~/.splinter/commands/; eine Zustimmung kommt mit Ja/Nein-Knoepfen. /interview stellt die Fragen im Chat. /model bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in splinter.conf.d/90-model.conf; /model probe fragt die Endpoints nach /v1/models. /connect fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach splinter.conf.d/20-connect.conf. Antworten werden als Telegram-HTML gesetzt: fett, kursiv, Code und Links als Tags, Tabellen als Spalten im Monospace-Block; ein Stueck, das Telegram nicht parst, geht als Text raus statt verloren. Programme in commands/ antworten dort direkt im Chat; im TUI gehen sie ans Modell.

\n

Slash-Kommandos funktionieren " + "Chat alle vier Sekunden „typing“.

\n

Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in ~/.splinter/commands/; eine Zustimmung kommt mit Ja/Nein-Knoepfen. /interview stellt die Fragen im Chat. /new faengt eine frische Konversation an; /model bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in splinter.conf.d/90-model.conf; /model probe fragt die Endpoints nach /v1/models. /connect fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach splinter.conf.d/20-connect.conf. Antworten werden als Telegram-HTML gesetzt: fett, kursiv, Code und Links als Tags, Tabellen als Spalten im Monospace-Block; ein Stueck, das Telegram nicht parst, geht als Text raus statt verloren. Programme in commands/ antworten dort direkt im Chat; im TUI gehen sie ans Modell.

\n

Slash-Kommandos funktionieren " "dort genauso. Programme in ~/.splinter/commands/ werden zu " "/name: sie bekommen den Rest der Zeile als Argument, und ihre Ausgabe " "geht ans Modell als Kontext — nicht an dich als Antwort. Damit holt sich " @@ -385,7 +385,7 @@ SECTIONS = { "sendMessage. The token lives in " "~/.splinter/telegram.token with mode 0600 and is never passed as an " "argument — arguments end up in ps. While a turn runs, the chat sees " - ""typing" every four seconds.

\n

The bot registers its commands: the menu shows the loaded plugins' commands and the programs in ~/.splinter/commands/; an approval arrives with Yes/No buttons. /interview asks the questions in the chat. /model offers the configured models as buttons, switches the transport and remembers the choice in splinter.conf.d/90-model.conf; /model probe asks the endpoints for /v1/models. /connect asks for name, endpoint, model and key variable, runs one test turn and writes the provider to splinter.conf.d/20-connect.conf. Answers are rendered as Telegram HTML: bold, italic, code and links as tags, tables as columns in a monospace block; a piece Telegram cannot parse goes out as text instead of being lost. Programs in commands/ answer in the chat; in the TUI their output goes to the model.

\n

Slash commands work there too. " + ""typing" every four seconds.

\n

The bot registers its commands: the menu shows the loaded plugins' commands and the programs in ~/.splinter/commands/; an approval arrives with Yes/No buttons. /interview asks the questions in the chat. /new starts a fresh conversation; /model offers the configured models as buttons, switches the transport and remembers the choice in splinter.conf.d/90-model.conf; /model probe asks the endpoints for /v1/models. /connect asks for name, endpoint, model and key variable, runs one test turn and writes the provider to splinter.conf.d/20-connect.conf. Answers are rendered as Telegram HTML: bold, italic, code and links as tags, tables as columns in a monospace block; a piece Telegram cannot parse goes out as text instead of being lost. Programs in commands/ answer in the chat; in the TUI their output goes to the model.

\n

Slash commands work there too. " "Programs in ~/.splinter/commands/ become /name: they get " "the rest of the line as an argument, and their output goes to the model as " "context — not to you as a reply. That is how the model fetches what it cannot see " @@ -572,7 +572,7 @@ em ordem de nome. Chave desconhecida e erro com numero de linha.

""", mesmos slash commands do terminal. O bot registra seus comandos: o menu mostra os comandos dos plugins carregados e os programas em ~/.splinter/commands/; uma aprovacao chega com botoes Sim/Nao; as respostas viram HTML do Telegram (negrito, codigo, links, -tabelas em bloco monoespaceado). /model lista os modelos +tabelas em bloco monoespaceado). /new comeca uma conversa nova; /model lista os modelos configurados em botoes, troca o transporte e guarda a escolha em splinter.conf.d/90-model.conf; /model probe pergunta aos endpoints por /v1/models. /connect pergunta nome,