telegram: /interview in the chat
The same questions as splinter --interview, one message per answer; /skip skips one and /cancel stops. The answers go through the shared profile writer (sp_interview_save), so the file is the same as the terminal path. The menu registers /interview next to start and help. interview.c grows count/prompt/hint/save; the CLI uses the same API, so the questions live in one place. The README said seven questions, the array has six; fixed. test_gateway.sh answers all six questions through the fake Bot API and checks the written profile.
This commit is contained in:
1 parent
07ac1906ed
commit
04cffac3b1
15 files changed
+273
-43
No files matched your search
@@ -253,7 +253,7 @@ processes that share a working directory — not A2A, and not a network protocol
|
||||
|
||||
splinter --interview
|
||||
|
||||
Seven questions - language, who you are, stack, answering style, what never to
|
||||
Six questions - language, who you are, stack, answering style, what never to
|
||||
do, which paths are sacred - written to `~/.splinter/profile/<user>.md`. Enter
|
||||
skips a question and the skip is recorded as such: an empty line would be a lie.
|
||||
Starting the chat without a profile prints a hint, once.
|
||||
@@ -290,15 +290,17 @@ 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`, every command a loaded plugin registers (`/goal`, `/recap`,
|
||||
`/tasks`, `/quota`, `/tmux`, ...) and every program in
|
||||
`/start`, `/help`, `/interview`, 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
|
||||
text plus that live list. An approval arrives as a message with **Yes/No
|
||||
buttons**; the callback answers the button, removes the buttons and writes the
|
||||
ack file. The text form `ok <id>` / `no <id>` still works.
|
||||
|
||||
A program in `commands/` answers in the chat: its output is the reply. In the
|
||||
`/interview` asks the same six questions as `splinter --interview`, one
|
||||
message per answer; `/skip` skips one and `/cancel` stops. A program in
|
||||
`commands/` answers in the chat: its output is the reply. In the
|
||||
TUI the same program's output becomes context for the model instead. A typo
|
||||
such as `/nosuch` is answered with the command list, not sent to the model.
|
||||
|
||||
|
||||
@@ -48,9 +48,10 @@ Naechster Schritt: entscheiden, ob die npm-Reste weg duerfen. Kein Code.
|
||||
`/tmp/opencode/ack-proof.txt`. Das installierte `~/.splinter/bin/tg-ask` war
|
||||
eine alte Kopie ohne Tokenpfad und wurde durch `tools/tg-ask.sh` ersetzt.
|
||||
- **Telegram-Menue und Knoepfe**: `setMyCommands` registriert dynamisch
|
||||
`/start`, `/help`, alle Befehle der geladenen Plugins und alle Programme in
|
||||
`~/.splinter/commands/` mit gueltigem Telegram-Namen; `/start` und `/help`
|
||||
listen sie im Chat. Zustimmungen kommen mit Ja/Nein-Knoepfen; `callback_query`
|
||||
`/start`, `/help`, `/interview`, alle Befehle der geladenen Plugins und alle
|
||||
Programme in `~/.splinter/commands/` mit gueltigem Telegram-Namen; `/start`
|
||||
und `/help` listen sie im Chat. `/interview` stellt die sechs Fragen im Chat
|
||||
und schreibt das Profil; `/skip` und `/cancel` gehoeren dazu. Zustimmungen kommen mit Ja/Nein-Knoepfen; `callback_query`
|
||||
prueft denselben Allow-List-Eintrag, antwortet, entfernt die Knoepfe und legt
|
||||
die Antwortdatei ab. Der Textweg `ok <id>` bleibt. Programme in
|
||||
`commands/` antworten im Telegram-Chat direkt (im TUI gehen sie ans Modell);
|
||||
|
||||
+3
-1
@@ -223,7 +223,9 @@ Ein Timeout ist ein Nein. Stille ist keine Zustimmung.
|
||||
|
||||
Das Telegram-Gateway registriert seine Befehle beim Start: die der geladenen
|
||||
Plugins, die Programme in `~/.splinter/commands/` mit gueltigem Telegram-Namen
|
||||
und `/start`/`/help`; `/help` listet sie im Chat. Die Anfrage selbst legt es als
|
||||
und `/start`, `/help`, `/interview`; `/help` listet sie im Chat. `/interview`
|
||||
stellt dieselben sechs Fragen wie `splinter --interview` im Chat, `/skip`
|
||||
ueberspringt eine, `/cancel` bricht ab. Die Anfrage selbst legt es als
|
||||
Nachricht mit **Ja/Nein-Knoepfen** vor.
|
||||
Der Knopf ist ein `callback_query`, kein Text: das Gateway prueft denselben
|
||||
Allow-List-Eintrag, antwortet dem Knopf, entfernt die Knoepfe und legt die
|
||||
|
||||
@@ -102,3 +102,11 @@ tg.help = Ich bin splinter. Schreib eine Nachricht fuer einen Turn. /goal setzt
|
||||
ack.yes = Ja
|
||||
ack.no = Nein
|
||||
ack.how = Antwort: Knopf unten oder ok %d / no %d
|
||||
|
||||
tg.cmd.interview = Profil im Chat anlegen
|
||||
tg.interview.start = Erstes Gespraech fuer '%s'. Ich stelle %zu Fragen; /skip ueberspringt eine, /cancel bricht ab.
|
||||
tg.interview.question = Frage %zu/%zu: %s
|
||||
tg.interview.how = Antworte einfach in den Chat.
|
||||
tg.interview.saved = Profil geschrieben: %s
|
||||
tg.interview.cancel = Interview abgebrochen.
|
||||
tg.interview.busy = Das Interview laeuft; antworte, /skip oder /cancel.
|
||||
@@ -101,3 +101,11 @@ tg.help = I am splinter. Send a message for a turn. /goal sets the goal, /recap
|
||||
ack.yes = Yes
|
||||
ack.no = No
|
||||
ack.how = Answer: button below or ok %d / no %d
|
||||
|
||||
tg.cmd.interview = create the profile in the chat
|
||||
tg.interview.start = First conversation for '%s'. I ask %zu questions; /skip skips one, /cancel stops.
|
||||
tg.interview.question = Question %zu/%zu: %s
|
||||
tg.interview.how = Just answer in the chat.
|
||||
tg.interview.saved = profile written: %s
|
||||
tg.interview.cancel = interview cancelled.
|
||||
tg.interview.busy = The interview is running; answer, /skip or /cancel.
|
||||
@@ -105,3 +105,11 @@ tg.help = Eu sou o splinter. Envie uma mensagem para um turno. /goal define a me
|
||||
ack.yes = Sim
|
||||
ack.no = Nao
|
||||
ack.how = Resposta: botao abaixo ou ok %d / no %d
|
||||
|
||||
tg.cmd.interview = criar o perfil no chat
|
||||
tg.interview.start = Primeira conversa para '%s'. Sao %zu perguntas; /skip pula uma, /cancel cancela.
|
||||
tg.interview.question = Pergunta %zu/%zu: %s
|
||||
tg.interview.how = Responda no chat.
|
||||
tg.interview.saved = perfil escrito: %s
|
||||
tg.interview.cancel = entrevista cancelada.
|
||||
tg.interview.busy = A entrevista esta em andamento; responda, /skip ou /cancel.
|
||||
+79
-27
@@ -48,6 +48,72 @@ static const struct question questions[] = {
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
#define INTERVIEW_MAX 16
|
||||
|
||||
size_t
|
||||
sp_interview_count(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; questions[i].key != NULL; i++)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
const char *
|
||||
sp_interview_prompt(size_t i)
|
||||
{
|
||||
return i < sp_interview_count() ? questions[i].prompt : NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
sp_interview_hint(size_t i)
|
||||
{
|
||||
return i < sp_interview_count() ? questions[i].hint : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the profile from answers collected by a front end. A short answer list
|
||||
* (Ctrl-D, /cancel after a few questions) still writes what was answered; a
|
||||
* missing answer is recorded as "not answered", not as an empty line.
|
||||
*/
|
||||
int
|
||||
sp_interview_save(const char *session_dir, const char *const *answers, size_t n,
|
||||
struct sp_buf *err)
|
||||
{
|
||||
char dir[600], path[700];
|
||||
const char *user = sp_memory_user();
|
||||
FILE *f;
|
||||
size_t i, max = sp_interview_count();
|
||||
|
||||
if (sp_profile_path(session_dir, dir, sizeof(dir)) == NULL) {
|
||||
sp_buf_puts(err, "interview: no session directory");
|
||||
return -1;
|
||||
}
|
||||
(void)mkdir(dir, 0700);
|
||||
snprintf(path, sizeof(path), "%s/%s.md", dir, user);
|
||||
f = fopen(path, "w");
|
||||
if (f == NULL) {
|
||||
sp_buf_printf(err, "interview: cannot write %s", path);
|
||||
return -1;
|
||||
}
|
||||
fprintf(f, "# Profile: %s\n\n", user);
|
||||
fprintf(f, "_Written by `splinter --interview`. Edit it by hand whenever you "
|
||||
"like; splinter reads it at start._\n\n");
|
||||
if (n > max)
|
||||
n = max;
|
||||
for (i = 0; i < n; i++) {
|
||||
fprintf(f, "## %s\n", questions[i].key);
|
||||
if (answers == NULL || answers[i] == NULL ||
|
||||
answers[i][0] == '\0')
|
||||
fprintf(f, "(nicht beantwortet)\n\n");
|
||||
else
|
||||
fprintf(f, "%s\n\n", answers[i]);
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
sp_profile_path(const char *session_dir, char *buf, size_t len)
|
||||
{
|
||||
@@ -72,45 +138,31 @@ sp_profile_exists(const char *session_dir)
|
||||
int
|
||||
sp_interview_run(const char *session_dir, struct sp_buf *err)
|
||||
{
|
||||
char dir[600], path[700];
|
||||
const char *user = sp_memory_user();
|
||||
FILE *f;
|
||||
size_t i;
|
||||
static char answers[INTERVIEW_MAX][ANSWER_MAX];
|
||||
const char *ptrs[INTERVIEW_MAX];
|
||||
char dir[600], path[700];
|
||||
const char *user = sp_memory_user();
|
||||
size_t i, n = sp_interview_count();
|
||||
|
||||
if (sp_profile_path(session_dir, dir, sizeof(dir)) == NULL) {
|
||||
sp_buf_puts(err, "interview: no session directory");
|
||||
return -1;
|
||||
}
|
||||
(void)mkdir(dir, 0700);
|
||||
snprintf(path, sizeof(path), "%s/%s.md", dir, user);
|
||||
f = fopen(path, "w");
|
||||
if (f == NULL) {
|
||||
sp_buf_printf(err, "interview: cannot write %s", path);
|
||||
return -1;
|
||||
}
|
||||
fprintf(f, "# Profile: %s\n\n", user);
|
||||
fprintf(f, "_Written by `splinter --interview`. Edit it by hand whenever you "
|
||||
"like; splinter reads it at start._\n\n");
|
||||
|
||||
if (n > INTERVIEW_MAX)
|
||||
n = INTERVIEW_MAX;
|
||||
printf("Erstes Gespraech fuer '%s'. Enter ueberspringt eine Frage, "
|
||||
"Ctrl-D bricht ab.\n\n", user);
|
||||
for (i = 0; questions[i].key != NULL; i++) {
|
||||
char answer[ANSWER_MAX];
|
||||
size_t len;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
printf("%s\n (%s)\n> ", questions[i].prompt, questions[i].hint);
|
||||
fflush(stdout);
|
||||
if (fgets(answer, sizeof(answer), stdin) == NULL)
|
||||
if (fgets(answers[i], sizeof(answers[i]), stdin) == NULL)
|
||||
break;
|
||||
len = strcspn(answer, "\r\n");
|
||||
answer[len] = '\0';
|
||||
fprintf(f, "## %s\n", questions[i].key);
|
||||
if (len == 0)
|
||||
fprintf(f, "(nicht beantwortet)\n\n");
|
||||
else
|
||||
fprintf(f, "%s\n\n", answer);
|
||||
answers[i][strcspn(answers[i], "\r\n")] = '\0';
|
||||
ptrs[i] = answers[i];
|
||||
}
|
||||
fclose(f);
|
||||
if (sp_interview_save(session_dir, ptrs, i, err) != 0)
|
||||
return -1;
|
||||
printf("\nGeschrieben: %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
@@ -13,4 +13,11 @@ const char *sp_profile_path(const char *session_dir, char *buf, size_t len);
|
||||
int sp_profile_exists(const char *session_dir);
|
||||
int sp_interview_run(const char *session_dir, struct sp_buf *err);
|
||||
|
||||
/* The same questions for a front end that is not a terminal (Telegram). */
|
||||
size_t sp_interview_count(void);
|
||||
const char *sp_interview_prompt(size_t i);
|
||||
const char *sp_interview_hint(size_t i);
|
||||
int sp_interview_save(const char *session_dir,
|
||||
const char *const *answers, size_t n, struct sp_buf *err);
|
||||
|
||||
#endif /* SPLINTER_INTERVIEW_H */
|
||||
+132
-1
@@ -38,6 +38,7 @@
|
||||
#include "mcp.h"
|
||||
#include "log.h"
|
||||
#include "cmdscript.h"
|
||||
#include "interview.h"
|
||||
#include "splinter_plugin.h"
|
||||
|
||||
/*
|
||||
@@ -382,6 +383,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"));
|
||||
if (sp_buf_init(&list) != 0)
|
||||
return;
|
||||
if (host != NULL) {
|
||||
@@ -444,7 +446,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 ");
|
||||
sp_buf_puts(out, "\n\n/start /help /interview ");
|
||||
if (host != NULL)
|
||||
(void)sp_host_command_help(host, out);
|
||||
if (sp_cmdscript_dir(sess_dir, dir, sizeof(dir)) == 0 &&
|
||||
@@ -505,6 +507,123 @@ static struct {
|
||||
const char *allow;
|
||||
} tg_cur;
|
||||
|
||||
/*
|
||||
* /interview in the chat: the same questions as `splinter --interview`, one
|
||||
* message per answer. The state is per gateway process; a restart abandons a
|
||||
* half-finished interview, as a closed terminal does.
|
||||
*/
|
||||
struct tg_interview {
|
||||
int active;
|
||||
long chat_id;
|
||||
size_t step;
|
||||
char answers[16][4096];
|
||||
};
|
||||
|
||||
static struct tg_interview tg_iv;
|
||||
|
||||
static int
|
||||
tg_interview_ask(const char *token, long chat_id, struct sp_buf *err)
|
||||
{
|
||||
const char *q = sp_interview_prompt(tg_iv.step);
|
||||
const char *h = sp_interview_hint(tg_iv.step);
|
||||
struct sp_buf msg;
|
||||
|
||||
if (q == NULL)
|
||||
return -1;
|
||||
if (sp_buf_init(&msg) != 0)
|
||||
return -1;
|
||||
sp_buf_printf(&msg, sp_t("tg.interview.question"), tg_iv.step + 1,
|
||||
sp_interview_count(), q);
|
||||
if (h != NULL && *h != '\0')
|
||||
sp_buf_printf(&msg, "\n (%s)", h);
|
||||
sp_buf_puts(&msg, "\n");
|
||||
sp_buf_puts(&msg, sp_t("tg.interview.how"));
|
||||
(void)send_message(token, chat_id, msg.p, err);
|
||||
sp_buf_free(&msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
tg_interview_begin(const char *token, long chat_id, struct sp_buf *err)
|
||||
{
|
||||
struct sp_buf msg;
|
||||
|
||||
memset(&tg_iv, 0, sizeof(tg_iv));
|
||||
tg_iv.active = 1;
|
||||
tg_iv.chat_id = chat_id;
|
||||
tg_iv.step = 0;
|
||||
if (sp_buf_init(&msg) != 0)
|
||||
return;
|
||||
sp_buf_printf(&msg, sp_t("tg.interview.start"), sp_memory_user(),
|
||||
sp_interview_count());
|
||||
(void)send_message(token, chat_id, msg.p, err);
|
||||
sp_buf_free(&msg);
|
||||
(void)tg_interview_ask(token, chat_id, err);
|
||||
}
|
||||
|
||||
static void
|
||||
tg_interview_end(const char *token, long chat_id, const char *session_dir,
|
||||
struct sp_buf *err)
|
||||
{
|
||||
const char *ptrs[16];
|
||||
char dir[600], path[700];
|
||||
struct sp_buf msg;
|
||||
size_t i, n = tg_iv.step;
|
||||
|
||||
if (n > 16)
|
||||
n = 16;
|
||||
for (i = 0; i < n; i++)
|
||||
ptrs[i] = tg_iv.answers[i];
|
||||
if (sp_interview_save(session_dir, ptrs, n, err) == 0) {
|
||||
path[0] = '\0';
|
||||
if (sp_profile_path(session_dir, dir, sizeof(dir)) != NULL)
|
||||
snprintf(path, sizeof(path), "%s/%s.md", dir,
|
||||
sp_memory_user());
|
||||
if (sp_buf_init(&msg) == 0) {
|
||||
sp_buf_printf(&msg, sp_t("tg.interview.saved"), path);
|
||||
(void)send_message(token, chat_id, msg.p, err);
|
||||
sp_buf_free(&msg);
|
||||
}
|
||||
} else {
|
||||
(void)send_message(token, chat_id,
|
||||
err->p != NULL ? err->p : sp_t("err.turn_failed"), err);
|
||||
}
|
||||
memset(&tg_iv, 0, sizeof(tg_iv));
|
||||
}
|
||||
|
||||
static void
|
||||
tg_interview_answer(const char *token, long chat_id, const char *text,
|
||||
const char *session_dir, struct sp_buf *err)
|
||||
{
|
||||
struct sp_buf msg;
|
||||
|
||||
if (strcmp(text, "/cancel") == 0) {
|
||||
memset(&tg_iv, 0, sizeof(tg_iv));
|
||||
if (sp_buf_init(&msg) == 0) {
|
||||
sp_buf_puts(&msg, sp_t("tg.interview.cancel"));
|
||||
(void)send_message(token, chat_id, msg.p, err);
|
||||
sp_buf_free(&msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (text[0] == '/' && strcmp(text, "/skip") != 0) {
|
||||
if (sp_buf_init(&msg) == 0) {
|
||||
sp_buf_puts(&msg, sp_t("tg.interview.busy"));
|
||||
(void)send_message(token, chat_id, msg.p, err);
|
||||
sp_buf_free(&msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (tg_iv.step < 16)
|
||||
snprintf(tg_iv.answers[tg_iv.step], sizeof(tg_iv.answers[0]),
|
||||
"%s", strcmp(text, "/skip") == 0 ? "" : text);
|
||||
tg_iv.step++;
|
||||
if (tg_iv.step < sp_interview_count())
|
||||
(void)tg_interview_ask(token, chat_id, err);
|
||||
else
|
||||
tg_interview_end(token, chat_id, session_dir, err);
|
||||
}
|
||||
|
||||
/*
|
||||
* An inline keyboard answer: ack:<id>:yes|no. The button travels as a
|
||||
* callback_query, not a message; the same allow list applies. The buttons are
|
||||
@@ -810,8 +929,20 @@ sp_telegram_run(struct sp_agent *ag, struct sp_host *host, const char *token,
|
||||
* reader of this chat, so it resolves here instead of letting a
|
||||
* second poller fight it for updates.
|
||||
*/
|
||||
if (tg_iv.active && tg_iv.chat_id == chat_id) {
|
||||
tg_interview_answer(token, chat_id, text,
|
||||
ag->sess != NULL ? ag->sess->dir : NULL,
|
||||
err);
|
||||
sp_buf_clear(err);
|
||||
continue;
|
||||
}
|
||||
if (tg_ack_reply(token, chat_id, text))
|
||||
continue;
|
||||
if (strcmp(text, "/interview") == 0) {
|
||||
tg_interview_begin(token, chat_id, err);
|
||||
sp_buf_clear(err);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(text, "/start") == 0 ||
|
||||
strcmp(text, "/help") == 0) {
|
||||
struct sp_buf help;
|
||||
|
||||
@@ -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>24238</b> lines of C99/POSIX ·
|
||||
<p class="meta"><b>24428</b> lines of C99/POSIX ·
|
||||
<b>23</b> tools · <b>31</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. 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. 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>24238</b> Zeilen C99/POSIX ·
|
||||
<p class="meta"><b>24428</b> Zeilen C99/POSIX ·
|
||||
<b>23</b> Werkzeuge · <b>31</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. 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. 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>24238</b> linhas C99/POSIX ·
|
||||
<p class="meta"><b>24428</b> linhas C99/POSIX ·
|
||||
<b>23</b> ferramentas · <b>31</b> programas de teste ·
|
||||
<b>16</b> plugins · <b>42</b> paletas · BSD-3-Clause</p>
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ class H(http.server.BaseHTTPRequestHandler):
|
||||
if markup is not None:
|
||||
f.write("markup: " + json.dumps(
|
||||
markup, separators=(",", ":")) + "\n")
|
||||
m = re.match(r"Frage (\d+)/", text)
|
||||
if m:
|
||||
add_update("antwort-%s" % m.group(1))
|
||||
m = re.match(r"Zustimmung (\d+):", text)
|
||||
if m:
|
||||
add_update("was machst du?") # must be told to wait
|
||||
|
||||
@@ -102,6 +102,14 @@ check "an unknown command is an error" \
|
||||
grep -q '^unbekanntes Kommando: /nosuch' "$D/sent.log"
|
||||
check "an unknown command does not start a model turn" test ! -e "$D/out.txt"
|
||||
|
||||
# /interview asks the seven questions and writes the profile
|
||||
run_text "/interview" '^Profil geschrieben' 30
|
||||
prof=$(ls "$D/home/.splinter/profile/"*.md 2>/dev/null | head -1)
|
||||
check "the interview wrote a profile" test -n "$prof"
|
||||
check "the first answer is in the profile" grep -q 'antwort-1' "$prof"
|
||||
check "the last answer is in the profile" grep -q 'antwort-6' "$prof"
|
||||
check "the profile has the language section" grep -q '## language' "$prof"
|
||||
|
||||
if [ "$fails" -eq 0 ]; then echo "test_gateway: ok"; exit 0; fi
|
||||
cat "$D/gw.out"
|
||||
exit 1
|
||||
+2
-2
@@ -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. 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. 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. 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. 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 "
|
||||
|
||||
Reference in new issue
Block a user