gateway, ui: /new starts a fresh conversation; /connect in the TUI
/new (and /reset) opens a new session file in the same directory, drops the conversation back to the system prompt and, in the gateway, resets the interview/connect state so a half-finished flow does not survive the reset. The old session file stays: it is the record of what was said. In the TUI the history pane is cleared, because it shows the old conversation. The directory is read before the static session struct is cleared, or the second /new would start from an empty path. /connect exists in the TUI now: the same four questions, one answer per line, the same validation and presets, and connect.nodir when the run has no config file to write to (--no-config). conv.c grows sp_conv_reset(), which frees every message and puts the system prompt back. test_gateway checks /new (message and a new session file); test_ui checks /new in the pane and the /connect guard with --no-config.
This commit is contained in:
1 parent
900b8e1efa
commit
5de70f5dbb
16 files changed
+311
-21
No files matched your search
@@ -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 `<config>.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 <id|name>`), 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 `<config>.d/20-connect.conf`, so the next start
|
||||
has the provider too, runs one tiny turn against it to prove endpoint, model
|
||||
|
||||
+2
-1
@@ -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
|
||||
`<config>.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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
+28
-7
@@ -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)
|
||||
{
|
||||
|
||||
+56
-1
@@ -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:<id>:yes|no for an approval, model:<id> 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;
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include "splinter_plugin.h"
|
||||
#include "config.h"
|
||||
#include "providers.h"
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#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;
|
||||
|
||||
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
|
||||
<h1>splinter<span>_</span></h1>
|
||||
<p class="lead">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.</p>
|
||||
|
||||
<p class="meta"><b>28508</b> lines of C99/POSIX ·
|
||||
<p class="meta"><b>28769</b> lines of C99/POSIX ·
|
||||
<b>25</b> tools · <b>35</b> test programs ·
|
||||
<b>16</b> plugins · <b>42</b> palettes · BSD-3-Clause</p>
|
||||
|
||||
@@ -141,7 +141,7 @@ plugin = plugins/reminder/reminder.so</pre>
|
||||
|
||||
<h2>Gateway: Telegram</h2>
|
||||
<p><code>splinter --daemon</code> long-polls <code>getUpdates</code>, one turn per message, answers with <code>sendMessage</code>. The token lives in <code>~/.splinter/telegram.token</code> with mode 0600 and is never passed as an argument — arguments end up in <code>ps</code>. While a turn runs, the chat sees "typing" every four seconds.</p>
|
||||
<p>The bot registers its commands: the menu shows the loaded plugins' commands and the programs in <code>~/.splinter/commands/</code>; an approval arrives with Yes/No buttons. <code>/interview</code> asks the questions in the chat. <code>/model</code> offers the configured models as buttons, switches the transport and remembers the choice in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> asks the endpoints for <code>/v1/models</code>. <code>/connect</code> asks for name, endpoint, model and key variable, runs one test turn and writes the provider to <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> answer in the chat; in the TUI their output goes to the model.</p>
|
||||
<p>The bot registers its commands: the menu shows the loaded plugins' commands and the programs in <code>~/.splinter/commands/</code>; an approval arrives with Yes/No buttons. <code>/interview</code> asks the questions in the chat. <code>/new</code> starts a fresh conversation; <code>/model</code> offers the configured models as buttons, switches the transport and remembers the choice in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> asks the endpoints for <code>/v1/models</code>. <code>/connect</code> asks for name, endpoint, model and key variable, runs one test turn and writes the provider to <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> answer in the chat; in the TUI their output goes to the model.</p>
|
||||
<p>Slash commands work there too. Programs in <code>~/.splinter/commands/</code> become <code>/name</code>: they get the rest of the line as an argument, and their output goes <em>to the model</em> as context — not to you as a reply. That is how the model fetches what it cannot see itself.</p>
|
||||
|
||||
<h2>What gets written down</h2>
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
|
||||
<h1>splinter<span>_</span></h1>
|
||||
<p class="lead">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.</p>
|
||||
|
||||
<p class="meta"><b>28508</b> Zeilen C99/POSIX ·
|
||||
<p class="meta"><b>28769</b> Zeilen C99/POSIX ·
|
||||
<b>25</b> Werkzeuge · <b>35</b> Test-Programme ·
|
||||
<b>16</b> Plugins · <b>42</b> Farbschemata · BSD-3-Clause</p>
|
||||
|
||||
@@ -141,7 +141,7 @@ plugin = plugins/reminder/reminder.so</pre>
|
||||
|
||||
<h2>Gateway: Telegram</h2>
|
||||
<p><code>splinter --daemon</code> pollt <code>getUpdates</code>, ein Turn pro Nachricht, Antwort per <code>sendMessage</code>. Der Token liegt in <code>~/.splinter/telegram.token</code> mit Modus 0600 und wird nie als Argument uebergeben — Argumente stehen in <code>ps</code>. Waehrend eines Turns sieht der Chat alle vier Sekunden „typing“.</p>
|
||||
<p>Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in <code>~/.splinter/commands/</code>; eine Zustimmung kommt mit Ja/Nein-Knoepfen. <code>/interview</code> stellt die Fragen im Chat. <code>/model</code> bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> fragt die Endpoints nach <code>/v1/models</code>. <code>/connect</code> fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> antworten dort direkt im Chat; im TUI gehen sie ans Modell.</p>
|
||||
<p>Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in <code>~/.splinter/commands/</code>; eine Zustimmung kommt mit Ja/Nein-Knoepfen. <code>/interview</code> stellt die Fragen im Chat. <code>/new</code> faengt eine frische Konversation an; <code>/model</code> bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> fragt die Endpoints nach <code>/v1/models</code>. <code>/connect</code> fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> antworten dort direkt im Chat; im TUI gehen sie ans Modell.</p>
|
||||
<p>Slash-Kommandos funktionieren dort genauso. Programme in <code>~/.splinter/commands/</code> werden zu <code>/name</code>: sie bekommen den Rest der Zeile als Argument, und ihre Ausgabe geht <em>ans Modell</em> als Kontext — nicht an dich als Antwort. Damit holt sich das Modell, was es selbst nicht sehen kann.</p>
|
||||
|
||||
<h2>Was mitgeschrieben wird</h2>
|
||||
|
||||
@@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
|
||||
<h1>splinter<span>_</span></h1>
|
||||
<p class="lead">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.</p>
|
||||
|
||||
<p class="meta"><b>28508</b> linhas C99/POSIX ·
|
||||
<p class="meta"><b>28769</b> linhas C99/POSIX ·
|
||||
<b>25</b> ferramentas · <b>35</b> programas de teste ·
|
||||
<b>16</b> plugins · <b>42</b> paletas · BSD-3-Clause</p>
|
||||
|
||||
@@ -110,7 +110,7 @@ em ordem de nome. Chave desconhecida e erro com numero de linha.</p>
|
||||
mesmos slash commands do terminal. O bot registra seus comandos: o menu mostra os comandos dos plugins carregados
|
||||
e os programas em <code>~/.splinter/commands/</code>; uma aprovacao chega com
|
||||
botoes Sim/Nao; as respostas viram HTML do Telegram (negrito, codigo, links,
|
||||
tabelas em bloco monoespaceado). <code>/model</code> lista os modelos
|
||||
tabelas em bloco monoespaceado). <code>/new</code> comeca uma conversa nova; <code>/model</code> lista os modelos
|
||||
configurados em botoes, troca o transporte e guarda a escolha em
|
||||
<code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> pergunta
|
||||
aos endpoints por <code>/v1/models</code>. <code>/connect</code> pergunta nome,
|
||||
|
||||
@@ -129,6 +129,11 @@ run_text "zeig eine tabelle" '<pre>' 50
|
||||
check "a table is drawn in a monospace block" grep -q '<pre>' "$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" \
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -305,7 +305,7 @@ SECTIONS = {
|
||||
"<code>sendMessage</code>. Der Token liegt in "
|
||||
"<code>~/.splinter/telegram.token</code> mit Modus 0600 und wird nie als Argument "
|
||||
"uebergeben — Argumente stehen in <code>ps</code>. Waehrend eines Turns sieht der "
|
||||
"Chat alle vier Sekunden „typing“.</p>\n<p>Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in <code>~/.splinter/commands/</code>; eine Zustimmung kommt mit Ja/Nein-Knoepfen. <code>/interview</code> stellt die Fragen im Chat. <code>/model</code> bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> fragt die Endpoints nach <code>/v1/models</code>. <code>/connect</code> fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> antworten dort direkt im Chat; im TUI gehen sie ans Modell.</p>\n<p>Slash-Kommandos funktionieren "
|
||||
"Chat alle vier Sekunden „typing“.</p>\n<p>Der Bot registriert seine Befehle: das Menue zeigt die geladenen Plugin-Befehle und die Programme in <code>~/.splinter/commands/</code>; eine Zustimmung kommt mit Ja/Nein-Knoepfen. <code>/interview</code> stellt die Fragen im Chat. <code>/new</code> faengt eine frische Konversation an; <code>/model</code> bietet die konfigurierten Modelle als Knoepfe, schaltet den Transport um und merkt die Wahl in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> fragt die Endpoints nach <code>/v1/models</code>. <code>/connect</code> fragt Name, Endpoint, Modell und Key-Variable ab, macht einen Test-Turn und schreibt den Provider nach <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> antworten dort direkt im Chat; im TUI gehen sie ans Modell.</p>\n<p>Slash-Kommandos funktionieren "
|
||||
"dort genauso. Programme in <code>~/.splinter/commands/</code> werden zu "
|
||||
"<code>/name</code>: sie bekommen den Rest der Zeile als Argument, und ihre Ausgabe "
|
||||
"geht <em>ans Modell</em> als Kontext — nicht an dich als Antwort. Damit holt sich "
|
||||
@@ -385,7 +385,7 @@ SECTIONS = {
|
||||
"<code>sendMessage</code>. The token lives in "
|
||||
"<code>~/.splinter/telegram.token</code> with mode 0600 and is never passed as an "
|
||||
"argument — arguments end up in <code>ps</code>. While a turn runs, the chat sees "
|
||||
""typing" every four seconds.</p>\n<p>The bot registers its commands: the menu shows the loaded plugins' commands and the programs in <code>~/.splinter/commands/</code>; an approval arrives with Yes/No buttons. <code>/interview</code> asks the questions in the chat. <code>/model</code> offers the configured models as buttons, switches the transport and remembers the choice in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> asks the endpoints for <code>/v1/models</code>. <code>/connect</code> asks for name, endpoint, model and key variable, runs one test turn and writes the provider to <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> answer in the chat; in the TUI their output goes to the model.</p>\n<p>Slash commands work there too. "
|
||||
""typing" every four seconds.</p>\n<p>The bot registers its commands: the menu shows the loaded plugins' commands and the programs in <code>~/.splinter/commands/</code>; an approval arrives with Yes/No buttons. <code>/interview</code> asks the questions in the chat. <code>/new</code> starts a fresh conversation; <code>/model</code> offers the configured models as buttons, switches the transport and remembers the choice in <code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> asks the endpoints for <code>/v1/models</code>. <code>/connect</code> asks for name, endpoint, model and key variable, runs one test turn and writes the provider to <code>splinter.conf.d/20-connect.conf</code>. 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 <code>commands/</code> answer in the chat; in the TUI their output goes to the model.</p>\n<p>Slash commands work there too. "
|
||||
"Programs in <code>~/.splinter/commands/</code> become <code>/name</code>: they get "
|
||||
"the rest of the line as an argument, and their output goes <em>to the model</em> 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.</p>""",
|
||||
mesmos slash commands do terminal. O bot registra seus comandos: o menu mostra os comandos dos plugins carregados
|
||||
e os programas em <code>~/.splinter/commands/</code>; uma aprovacao chega com
|
||||
botoes Sim/Nao; as respostas viram HTML do Telegram (negrito, codigo, links,
|
||||
tabelas em bloco monoespaceado). <code>/model</code> lista os modelos
|
||||
tabelas em bloco monoespaceado). <code>/new</code> comeca uma conversa nova; <code>/model</code> lista os modelos
|
||||
configurados em botoes, troca o transporte e guarda a escolha em
|
||||
<code>splinter.conf.d/90-model.conf</code>; <code>/model probe</code> pergunta
|
||||
aos endpoints por <code>/v1/models</code>. <code>/connect</code> pergunta nome,
|
||||
|
||||
Reference in new issue
Block a user