diff --git a/include/splinter_plugin.h b/include/splinter_plugin.h index fc99fe3..5519093 100644 --- a/include/splinter_plugin.h +++ b/include/splinter_plugin.h @@ -77,6 +77,12 @@ struct sp_gate { int (*check)(struct sp_host *, const char *tool, int auth, const char *args, char *reason, size_t reason_len); + /* + * Optional: refuse the whole turn before the model is called. Used by kid + * mode when the day's minutes are gone - a message the child reads, not a + * hang, and not a model that has to be trusted to obey. + */ + int (*block_turn)(struct sp_host *, char *msg, size_t len); }; struct sp_plugin { @@ -105,6 +111,7 @@ int sp_host_add_gate(struct sp_host *, const struct sp_gate *); /* Ask every gate. Returns 1 allowed, 0 denied (reason filled), -1 no opinion. */ int sp_host_gate(struct sp_host *, const char *tool, int auth, const char *args, char *reason, size_t reason_len); +int sp_host_turn_blocked(struct sp_host *, char *msg, size_t len); int sp_host_add_command(struct sp_host *, const char *name, sp_cmd_fn, void *ctx); int sp_host_command(struct sp_host *, const char *name, const char *args, diff --git a/plugins/kids/kids.c b/plugins/kids/kids.c index b0d83f2..0ad5504 100644 --- a/plugins/kids/kids.c +++ b/plugins/kids/kids.c @@ -248,7 +248,23 @@ kids_gate(struct sp_host *h, const char *tool, int auth, const char *args, return ask_parent(tool, args, reason, reason_len) ? 1 : 0; } -static const struct sp_gate gate = { "kids", kids_gate }; +/* + * The day ends here. Not "the model is asked to stop" - the model is not called + * at all, so a chatty model cannot talk past the budget. + */ +static int +kids_block_turn(struct sp_host *h, char *msg, size_t len) +{ + (void)h; + if (quota_left() != 0) + return 0; + snprintf(msg, len, "Fuer heute ist Schluss: %ld von %u Minuten sind " + "verbraucht. Morgen geht es weiter.", used_seconds / 60, + daily_minutes); + return 1; +} + +static const struct sp_gate gate = { "kids", kids_gate, kids_block_turn }; /* * Kid-safe conversation: a system message in front of every request, because a diff --git a/src/agent.c b/src/agent.c index 3c68a2a..4915b6b 100644 --- a/src/agent.c +++ b/src/agent.c @@ -118,7 +118,21 @@ sp_agent_run(struct sp_agent *a, const char *user_text, struct sp_buf *answer, sp_buf_clear(answer); /* the turn counter is what a plugin like 'focus' schedules against */ if (a->host != NULL) - sp_host_turn(a->host); + /* + * A turn gate runs before the model does. Kid mode ends the day here: the + * child gets a sentence, the model gets nothing to answer. + */ + if (a->host != NULL) { + char msg[256]; + + msg[0] = '\0'; + if (sp_host_turn_blocked(a->host, msg, sizeof(msg))) { + sp_buf_puts(answer, msg[0] != '\0' ? msg : + "today is over"); + return 0; + } + } + sp_host_turn(a->host); if (sp_buf_init(&obs) != 0) { sp_buf_puts(err, "agent: out of memory"); if (conv == &local) diff --git a/src/main.c b/src/main.c index 1a70f28..84ddf2b 100644 --- a/src/main.c +++ b/src/main.c @@ -112,12 +112,16 @@ load_script(struct sp_mock *m, const char *path, struct sp_buf *err) } /* one-shot mode: print the answer as it arrives, no buffering */ +/* bytes the transport streamed: if none, the answer still has to be printed */ +static size_t streamed_bytes; + static void stdout_stream(void *ctx, int kind, const char *text) { (void)ctx; if (kind != SP_STREAM_TEXT || text == NULL) return; + streamed_bytes += strlen(text); fputs(text, stdout); fflush(stdout); } @@ -797,7 +801,7 @@ main(int argc, char **argv) cfg.stream_ctx = NULL; rc = sp_agent_run(&ag, prompt, &answer, &err); if (rc == 0) { - if (cfg.stream == NULL) + if (cfg.stream == NULL || streamed_bytes == 0) printf("%s\n", answer.p != NULL ? answer.p : ""); else printf("\n"); /* the stream already printed it */ diff --git a/src/plugin.c b/src/plugin.c index 5fbfb92..4a63a72 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -189,6 +189,20 @@ sp_host_add_gate(struct sp_host *h, const struct sp_gate *g) * The first gate with an opinion wins. A denial carries its reason; allowing * skips the operator prompt, which is what a whitelist is for. */ +int +sp_host_turn_blocked(struct sp_host *h, char *msg, size_t len) +{ + size_t i; + + if (h == NULL) + return 0; + for (i = 0; i < h->ngate; i++) + if (h->gate[i]->block_turn != NULL && + h->gate[i]->block_turn(h, msg, len)) + return 1; + return 0; +} + int sp_host_gate(struct sp_host *h, const char *tool, int auth, const char *args, char *reason, size_t reason_len) diff --git a/src/www/index.html b/src/www/index.html index cc1c53a..6881746 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -48,7 +48,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }
Deutsch · English
+Deutsch · English · Portugues (BR)
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.
diff --git a/src/www/index.pt.html b/src/www/index.pt.html new file mode 100644 index 0000000..753e8c7 --- /dev/null +++ b/src/www/index.pt.html @@ -0,0 +1,156 @@ + + + + +Deutsch · English · Portugues (BR)
+ +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.
+ + + +splinter e um harness de agente em C99/POSIX: um programa que segura a +conversa, decide quais ferramentas existem, quem pode usa-las e o que ficou +registrado. O modelo e um detalhe trocavel; o harness e a parte que sabe o que +acontece.
+ +voce: por que o build falha? +pensando: preciso ler o erro antes de opinar. +ferramenta: search {"pattern":"error","path":"build/logs"} +ferramenta: read {"path":"build/logs/last.log"} +alteracao: -CFLAGS = -O2 + +CFLAGS = -O2 -Wall -Werror +modelo: faltava -Werror; o erro era um aviso promovido.+
Pensamento, ferramenta com argumentos, alteracao e resposta entram no +transcript na ordem em que acontecem.
+ +Orcamento, registro e classe de autorizacao. A ferramenta declara a classe +(read, mutate, destructive) - nunca o modelo, nunca o prompt. Um plugin pode +entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.
+ +14 ferramentas: read, write, edit,
+search, list, run,
+folder_history, delegate,
+delegate_parallel e as de leitura do sistema.
Transporte e um vtable: openai (HTTP/SSE), cli (claude, opencode), mock para
+teste. Plugins sao .so carregados com dlopen: lcm, focus, reminder,
+ring, mcp, cli, clock, cps e agora kids.
[parallel: 2 task(s), 12018 ms wall] + +## task 1 | model slow | score 5 | 12018 ms | exit 0 | 75 B | requested tag 'slow'+
Modelo, duracao e status por tarefa - um delegado lento aparece no cabecalho +antes de alguem ler o texto.
+ +endpoint = http://kontron.local:8080/v1/chat/completions +model = ... +autonomous = 1+
~/.splinter/splinter.conf mais splinter.conf.d/*.conf
+em ordem de nome. Chave desconhecida e erro com numero de linha.
splinter --daemon fala Telegram com indicador de digitacao e os
+mesmos slash commands do terminal.
Cada sessao escreve session.log (eventos legiveis) e
+wire.jsonl (o que foi de fato enviado ao modelo).
make
+make check # 21 binarios de teste, i18n, site
+Sem dependencias alem de libc e pthread; ncurses vem do vendor.
+ +delegate = olivia | em olivia | tags=remote | host=172.25.206.16 | + endpoint=http://172.25.206.2:18082/v1/chat/completions | model=...+
O delegate nomeia um host e a chamada inteira vai por ssh; a maquina remota +poe suas proprias chaves.
+ +$ splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
+splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)
+Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
+--autonomous.
$ cat /etc/passwd | splinter "explique o arquivo" +$ cd ~/src/splinter && splinter -c +$ splinter --interview+
stdin vira contexto; -c pega a ultima sessao daquele diretorio;
+--interview escreve o perfil em
+~/.splinter/profile/<usuario>.md.
Com o plugin kids, toda acao que muda algo precisa da aprovacao de
+um adulto (Telegram), uma lista branca libera o inofensivo, o modelo e lembrado a
+cada pedido de manter a conversa adequada a idade, e um limite diario de minutos
+fecha o dia quando acaba.
splinter - C99/POSIX, BSD-3-Clause. Manual: man ./docs/splinter.1 · ABI de plugins: docs/PLUGINS.md
man ./docs/splinter.1"
+ " · ABI de plugins: docs/PLUGINS.md",
+}
+
SECTIONS = {
"de": [
("Dasselbe, was Claude Code oder opencode fuer dich sind: ein "
@@ -440,6 +455,86 @@ of letting it guess; the profile from the interview lives in
~/.splinter/profile/<user>.md.
splinter e um harness de agente em C99/POSIX: um programa que segura a +conversa, decide quais ferramentas existem, quem pode usa-las e o que ficou +registrado. O modelo e um detalhe trocavel; o harness e a parte que sabe o que +acontece.
""", +"""voce: por que o build falha? +pensando: preciso ler o erro antes de opinar. +ferramenta: search {"pattern":"error","path":"build/logs"} +ferramenta: read {"path":"build/logs/last.log"} +alteracao: -CFLAGS = -O2 + +CFLAGS = -O2 -Wall -Werror +modelo: faltava -Werror; o erro era um aviso promovido.+
Pensamento, ferramenta com argumentos, alteracao e resposta entram no +transcript na ordem em que acontecem.
""", +"""Orcamento, registro e classe de autorizacao. A ferramenta declara a classe +(read, mutate, destructive) - nunca o modelo, nunca o prompt. Um plugin pode +entrar na frente com um gate: permitir, negar com motivo, ou nao opinar.
""", +"""14 ferramentas: read, write, edit,
+search, list, run,
+folder_history, delegate,
+delegate_parallel e as de leitura do sistema.
Transporte e um vtable: openai (HTTP/SSE), cli (claude, opencode), mock para
+teste. Plugins sao .so carregados com dlopen: lcm, focus, reminder,
+ring, mcp, cli, clock, cps e agora kids.
[parallel: 2 task(s), 12018 ms wall] + +## task 1 | model slow | score 5 | 12018 ms | exit 0 | 75 B | requested tag 'slow'+
Modelo, duracao e status por tarefa - um delegado lento aparece no cabecalho +antes de alguem ler o texto.
""", +"""endpoint = http://kontron.local:8080/v1/chat/completions +model = ... +autonomous = 1+
~/.splinter/splinter.conf mais splinter.conf.d/*.conf
+em ordem de nome. Chave desconhecida e erro com numero de linha.
splinter --daemon fala Telegram com indicador de digitacao e os
+mesmos slash commands do terminal.
Cada sessao escreve session.log (eventos legiveis) e
+wire.jsonl (o que foi de fato enviado ao modelo).
make
+make check # 21 binarios de teste, i18n, site
+Sem dependencias alem de libc e pthread; ncurses vem do vendor.
""", +"""delegate = olivia | em olivia | tags=remote | host=172.25.206.16 | + endpoint=http://172.25.206.2:18082/v1/chat/completions | model=...+
O delegate nomeia um host e a chamada inteira vai por ssh; a maquina remota +poe suas proprias chaves.
""", +"""$ splinter --mcp-server-listen 0.0.0.0 --mcp-listen-port 8098
+splinter: MCP server on 0.0.0.0:8098 (14 tools, read only)
+Como cliente busca ferramentas; como servidor oferece as suas. Mutar so com
+--autonomous.
$ cat /etc/passwd | splinter "explique o arquivo" +$ cd ~/src/splinter && splinter -c +$ splinter --interview+
stdin vira contexto; -c pega a ultima sessao daquele diretorio;
+--interview escreve o perfil em
+~/.splinter/profile/<usuario>.md.
Com o plugin kids, toda acao que muda algo precisa da aprovacao de
+um adulto (Telegram), uma lista branca libera o inofensivo, o modelo e lembrado a
+cada pedido de manter a conversa adequada a idade, e um limite diario de minutos
+fecha o dia quando acaba.