Commit Graph
136 Commits
Author SHA1 Message Date
lotherk 5143fcd054 gateway, sessions, reconnect: splinter serves other harnesses and keeps tabs
- --openai-listen: an OpenAI-compatible /v1/chat/completions and /v1/models.
  The model gets splinter's local tools as gw_* (executed here) and the
  caller's tools under their own names (returned as tool_calls to run there).
  Local calls loop inside one request; a mixed reply runs the local calls and
  asks again. --autonomous gates mutation; beyond loopback a bearer token is
  required; stream:true answers with SSE.
- --serve keeps several sessions: sessions/open over the protocol and
  /sessions, /open in the attach screen. The server owns the engines, closes
  the old one before opening the next (plugins keep globals) and sends
  state/history after every switch. Session ids are unique per process, so two
  engines in the same second no longer share a file.
- --attach reconnects: when the server goes away the screen keeps running,
  retries every second, asks for its session by id and restores the
  transcript; a missing session falls back to the server's current one.
- transports own their context now: provider switches and close dispose it
  (a switch used to leak one per change). The idle screen repaints entries it
  drains, so a reconnect note is not invisible.
- docs/GATEWAY.md; PROTOCOL, FRONTENDS, README and the manual page describe
  the three; tests cover the gateway tools, sessions/open and a server
  restart under --attach.
2026-11-16 09:33:37 +00:00
lotherk a9f175c25b backend/frontend: an engine every front end can talk to
The harness was two halves that could not see each other: main.c built the
agent, ui.c ran it -- with the curses thread model, the approval condition
variable, the slash commands and the provider switching inside the drawing
code. A second front end had to copy all of it.

Now:

  src/backend/   engine.c owns the session, the turn thread, the event queue
                 and every command; agent, transports, tools, session, config,
                 providers, plugins and the protocol servers move here.
  src/frontend/  curses.c draws and reads keys through ui_backend.h;
                 ui_local.c is the engine in this process, ui_remote.c is a
                 served engine behind a socket. protocol.c serves the engine
                 as JSON lines (protocol 2: history, approvals, steering);
                 client.c is splinterctl, the reference client.

splinter --serve / --attach: the same screen runs as a client of a served
engine, so the socket carries everything the front end needs. docs/PROTOCOL.md
and docs/FRONTENDS.md describe the contract; docs/proto-example.py is a
60-line client. tests/test_engine, test_protocol and test_attach cover the
event order, the socket and the attach mode.

Review fixes in the same tree: dynamic line buffers (9 KB prompts and 8 KB
events were truncated), a turn event no longer ends the busy window (steer
leftovers), the screen finalises every turn, /new keeps the profile, reopens
the log and gets unique ids, the profile is remembered in <session>.agent so
--resume comes back in it, agent statistics are a locked snapshot (no data
race), !shell keeps 64 KiB with a marker, the socket probes for a live server,
compares its inode and sets CLOEXEC/SNDTIMEO, exit 2 means configuration,
BSD peer checks use getpeereid, and the i18n checker scans the new
subdirectories again.

Includes the parallel session's SSE fix: the parser reports what a line
produced, so a tool name no longer lands in the answer ("readread").
2026-11-16 09:06:51 +00:00
lotherk c9f21be89b ui: a call names itself once - no JSON, one row, quiet calls inline
Three places named the tool call and none of them said what it was.

The prompt line while a turn ran read "12s run {"command": "sleep 4; echo x"}":
the model's own encoding, cut at forty bytes in the middle of an escape, pushed
into the steer prompt. It is now "12s Run  sleep 4; echo x", and the call gives
way when the row is narrow - never the steer prompt, which is the one hint the
row exists for.

The approval question read "run run (destructive) {"command": ...}? y/N" - the
verb twice (the catalogue's "run" and the tool's name) and the raw arguments in
it. It is now "Run  touch /tmp/x (destructive)?  y/N", the same words as the
transcript row, then how far the call reaches.

In the transcript every row was dim and said "Run" again, so a run of shell
calls was a grey column of the same word. The call row is now painted in the
accent colour, its output stays dim, and the row shows the verb and the one
argument that matters - command, path, pattern, query, url - read out of the
argument object with mcp_parse instead of off the front of the pretty text: the
model orders its arguments as it likes, and a write carries the whole file
content next to the path. A call that answered with nothing but
"[exit status 0]" keeps that on its own row instead of a second block.

An observation keeps sixteen rows and 4 KiB, whichever comes first, with the
number of lines left out: a row limit alone let one enormous line through, a
byte limit alone let fifty short lines cover the screen. The log keeps all of
it. In the sidebar the last-turn line clipped to "3 " in a narrow column; it
gets two rows now.

tests/test_ui.sh holds the question to it: shows "Write  ", not_shows
'{"path"', and after the run ">> Write  ".
2026-11-15 21:04:20 +00:00
lotherkandClaude Opus 5.5 b05bb34cc7 ui: a tool call reads like a call; a joined swarm session stays usable
The transcript said

  [23:12:05] <werkzeug> run  command: touch /tmp/.../made

which is the harness talking about itself. Hermes prints one row per call -
emoji, a capitalized verb, a one-line preview of the primary argument
(agent/display.py builds it per tool, 80 chars) and a duration; its long
outputs end in "... (N more lines)". opencode's TUI does the same shape: a
header line for the call, the output indented underneath.

So the row is ">> Run  touch /tmp/.../made" (verb capitalized, no
"command:" and no JSON for a shell call), and the observation hangs under it
as "| output", cut at 4 KiB with "... N lines". The log keeps the rest.

Also: the swarm master never sent "unlock", so a second splinter in the same
directory sat on "[swarm locked]" and swallowed every key - one of the
intermittent failures in the suite. Joining unlocks; the master locks a slave
only while it routes work to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:42:10 +00:00
lotherkandClaude Opus 5.5 41f42cbf95 ui: show what the tools returned; the log keeps the order they happened
Three things were missing or doubled.

The reasoning is no longer cut to ten lines: it is shown as it comes.

A tool's observation was only ever shown when it carried a diff, and then as a
separate "diff" entry - so the output of a `run` was invisible in the chat
while the session log had it. Now every observation is an entry of its own
(role "observation"), capped at 4 KiB with the number of lines left out: a
300 KB JSON dump must not bury the conversation, and the log keeps all of it.
The separate diff queue is gone, which is also what printed a diff twice.

The session log had holes: the user's words were not logged at all, and the
reasoning only for the last step of a turn. Both are written now, and a step
that only called tools no longer leaves an empty "reply" record. The chat and
session.log carry the same records; the log has the full observation where
the screen keeps its head.

The call line keeps one readable line of arguments (200 chars, "..." after
that); the log has the whole argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:18:41 +00:00
lotherkandClaude Opus 5.5 cb73c4a0bb ui: a transcript that is laid out once, and tool calls that are entries
draw_history rebuilt every entry from scratch on every keystroke and every
100 ms tick: table formatting, markdown stripping, two mallocs and the wrap,
for up to 512 entries. Each entry now keeps its wrapped lines and its width,
and only the entry whose text changed is laid out again. A frame costs the
visible lines, not the log.

Tool calls are queued as events on the turn thread (reasoning, text of the
step, the call, notes) and drained in order into real entries with the role
"tool". Before, they were pasted into the reasoning text as "> name args",
which made them uncountable and kept two copies of the same text; the answer
text of all steps of a turn also ran together in one buffer, so the text
before and after a call was one line. The transcript is now

  ~ denkt: ...      reasoning
  <m> teil eins     text before the call
  <werkzeug> run    the call
  <m> nach dem ...  text after it

Also: the "N more lines" marker goes through the catalogues, the dead
reserve parameter is gone, and the day-change marker lives in the UI state
instead of a static inside add_entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:20:30 +00:00
lotherkandClaude Opus 5.5 32a214aee3 ui: the sidebar is back, and it says where splinter runs
Removing it went too far: the conversation area should be plain appended
text, but the sidebar carries what no line of the transcript should repeat -
agent, provider and model, what is left of the allowance, the plugin widget
lines, the session and now the directory the tools act in ("~" for $HOME,
wrapped at the slashes). A narrow terminal drops it and gives the width to
the conversation.

No status bar: the running time and the tool lead the prompt, and /usage,
/status and /widgets print the same numbers on demand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:00:49 +00:00
lotherkandClaude Opus 5.5 5054393e17 gateway: one instance per session dir; drop the keys the sidebar left behind
Two daemons poll getUpdates and race: one reads the update, the other never
sees it, so a message is answered by nobody or twice. The gateway now holds
flock on <session_dir>/gateway.pid and a second start says who has it.

Removing the sidebar left 12 catalogue keys nobody reads (sidebar.*,
widget.*, status.title, ui.running); they are gone from all three
catalogues and test_i18n checks keys that still exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:52:16 +00:00
lotherkandClaude Opus 5.5 be2ab165f7 make install: rename, never copy over a mapped file
cp truncates the inode a running splinter has mapped, so the pages under a
live gateway change and it jumps into garbage. That is what killed the daemon
while make install ran (SIGSEGV at 0xb176). Link to a temp name and rename;
the old inode stays mapped for whatever is already running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:46:37 +00:00
lotherkandClaude Opus 5.5 fdf8b2888d ui: drop the sidebar and the status bar for good
They were already invisible (the windows were NULL and every draw returned
early); keeping the code around meant two layouts in one file and four
windows worth of thinking for a screen that has one text field. draw_sidebar,
draw_status, their helpers and usage_line go, together with the ui_side and
ui_status windows; the fleet is polled where the status bar used to poll it.

The file header now shows the layout it has, not the one it used to have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:40:31 +00:00
lotherkandClaude Opus 5.5 c215fd8101 docs: the plugin docs say where a widget line shows now
No sidebar to draw into: /widgets prints the published text, and draw() is
not called at all any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:31:04 +00:00
lotherkandClaude Opus 5.5 a32c591572 tests: drive a tmux server of their own, never the user's
test_agents_ui.sh ran on whatever server $TMUX pointed at, so a run inside
somebody's tmux created and typed into sessions there -- keys went into the
session the person was working in. It now drops $TMUX, points TMUX_TMPDIR at
its temp dir and refuses to signal a server it did not start, the way
test_ui.sh already did. test_a2a_ui.sh gets the same guard for its
kill-server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:21:55 +00:00
lotherkandClaude Opus 5.5 74e20547ed test_agents_ui: a fresh tmux name for the German session; starter says Xresources
Reusing the session name right after kill-session raced: the typed line went
to the dying pane and the test reported a missing answer. One run in four.
The starter config names the default theme, so --init-config does not send
people a palette they did not ask for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:16:15 +00:00
lotherk 23bc0d13d4 merge: plugins get their own config block 2026-11-13 20:59:51 +00:00
lotherkandClaude Opus 5.5 a77641b699 ui: one text field that only grows; themes are Xresources or a CDE palette
The chat is now the whole screen and the input line the row below it: no
sidebar, no status bar. Entries are append only -- a growing answer stays in
its entry while it is the last one and continues in a new entry once a tool
line follows, so nothing that was on screen ever moves. The prompt carries
the agent name ("build> "), /widgets shows what plugins published, and
/status still prints the status segments.

The default theme is Xresources: *foreground, *background and *color0..15
from xrdb -query (or ~/.Xresources), falling back to the terminal's own
colour indices. Every CDE palette is a theme by its own name, painted the
way the desktop paints it (set 5 windows, set 4 text areas, set 6 dialogs,
set 1 active frame, set 2 inactive frame) with CDE's black-or-white rule.
"Default" is therefore the CDE Default palette again, which is what the
config asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:59:13 +00:00
lotherkandClaude Opus 5 f3b832ae64 plugins come from their own config block, with their own settings
plugin NAME { path = ...  enabled = false  key = value } loads the plugin
(shipped one for NAME unless path says otherwise) and hands everything else
to that plugin as its configuration, read with sp_host_plugin_config() or
walked with sp_host_plugin_config_at(). Nested blocks give dotted keys,
lists arrive comma-separated.

The mcp plugin's servers are now server ID { url | cmd | header } blocks
inside plugin mcp { }; the old top-level mcp NAME { } and the flat
plugin = path / plugins = [ ... ] forms keep loading.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-13 20:52:46 +00:00
lotherkandClaude Opus 5.5 bddba6423b anthropic 400 on repeated user turns, exit in under a second, /quit
- anthropic: two messages of the same role in a row (a failed turn asked
  again) put the second one's blocks after the closed message object; the
  API answered 400 "messages.1.role: Field required". The message now stays
  open until the role changes.
- exit took 20+ s: the mcp plugin's HTTP round trip to a server that is down
  had curl -m 60 and nothing killed it; shutdown now kills the curl in
  flight, and connects time out after 5 s. Widget threads slept a whole
  interval before seeing the stop flag; they sleep in 100 ms steps.
- /quit (/exit, /q) leaves the chat.
- the prompt mark has its space again: the catalogue trims trailing blanks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:31:51 +00:00
lotherkandClaude Opus 5.5 2c58dcfd2a cli providers take a model: provider prefix, {model}, -m occli/MODEL
A kind = cli provider now has a default model and a prefix
(provider = opencode), so -m occli/deepseek-v4.1-flash-free runs
"opencode run --model opencode/deepseek-v4.1-flash-free". {model} in cmd
marks where the model goes, otherwise --model is appended; a model that
already has a '/' is used as it is. sp_cli_command() builds the command for
-m, delegates and the cli plugin's pool fallback. Model names are limited to
letters, digits and ._:/@+- since the command goes through /bin/sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:08:16 +00:00
lotherkandClaude Opus 5.5 05c8d936e7 anthropic transport, provider usage APIs, endpoints as /v1 base
- kind = anthropic: the Messages API over curl, OAuth tokens (sk-ant-oat)
  as Bearer with the oauth beta, tool_use/tool_result blocks.
- --doctor spends no tokens: it asks /models and the provider's own usage
  route (ollama /api/balance, opencode go /v1/usage) instead of a tiny turn;
  cli providers are only checked for the program. /usage shows the same
  provider figures, cached for a minute.
- endpoint names the API base (https://host/v1); sp_endpoint_url() builds
  chat/completions (default), messages, models and usage from it. A full
  route is still accepted and cut back to the base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:35:41 +00:00
lotherk 62a041a61b mcp: servers from the config, HTTP transport
The MCP client could only start one program and talk to it on a pipe; a server
behind an endpoint (junction at http://host:8090/mcp) had no way in. Now the
config names the servers and the plugin speaks whichever transport each one
offers:

- new `mcp NAME { url | cmd | header | enabled }` block (and the flat
  `mcp = NAME | url=...` form), parsed into struct sp_mcpserver; an entry
  without a url and without a cmd is refused with its line number
- streamable HTTP in plugins/mcp/mcp.c: one POST per JSON-RPC message, answered
  with one JSON object or an SSE stream of `data:` lines - both are read,
  Mcp-Session-Id is kept and echoed back, and the Authorization header travels
  through curl's stdin config so the token never appears in ps
- several servers register side by side; tools are mcp_<tool> for one server
  and mcp_<server>_<tool> for more, so two servers that both offer `search` do
  not overwrite each other. A server that fails its handshake is reported and
  skipped, the rest still load. SPLINTER_MCP_CMD stays as the one stdio server
- tests: the config and block parsers, and a socket server in test_mcpclient
  that refuses the tool list without the configured header and answers the call
  as an event stream
- README and docs/CONFIG.md describe both transports and where the token lives
2026-11-12 12:05:35 +00:00
lotherk bad1e4511f README: current quick start, block config, delegation 2026-11-12 03:31:03 +00:00
lotherkandClaude Sonnet 5.5 c0a295dfa7 ui: emphasis follows CommonMark flanking rules (pointers in code keep their asterisks)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 03:30:32 +00:00
lotherkandClaude Sonnet 5.5 2e7a88c462 usable: opencode-go session header, embedded catalogs, locale fixes, calmer UI, --doctor
- openai transport sends x-opencode-session (opencode-go refused every request
  without it) and a splinter user agent
- the message catalogues are compiled in: an installed binary no longer shows
  raw keys (ui.ready ...); LANG=de_DE now selects German (lang was emptied by an
  overlapping snprintf), pt_BR is matched
- sidebar rewritten (agent, provider/model, usage, goal/plan, last turn);
  idle widgets say nothing; status line shows only what matters
- tool calls shown readable instead of JSON with \u escapes
- providers without their key variable are skipped by pools and refused by -m
  with a clear message; --doctor checks every provider

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 03:22:49 +00:00
lotherkandClaude Sonnet 5.5 b8db78816a agent profiles: Tab switches build/plan/yours; files in ~/.splinter/agents, .agents/
build (all tools) and plan (read-only plus delegate/plan_task) are built in; a
markdown file with opencode-style front matter (description, model, tools,
allow, deny, autonomous) adds or replaces one. Tool policy is enforced in the
agent loop, the prompt is added to the system message, /agent and --agent.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 23:05:12 +00:00
lotherkandClaude Sonnet 5.5 b22ef6526f roles: analyze/decide words, balance without limits by recent load, WORKFLOW.md
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 22:55:53 +00:00
lotherkandClaude Sonnet 5.5 1f79ae29dc delegate: tag weighting by word, synonyms, private as a rule, default as fallback
Substring matching made 'cli' match 'client' and never matched 'gross' to 'big'.
Words now, with German/English synonyms; a private task only goes to a private
delegate; when no tag fits the config's default takes the task.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 22:34:42 +00:00
lotherkandClaude Sonnet 5.5 0b7a91e3b7 config blocks, pools, -m/--model-list, waiting out usage limits
Config: { } blocks (core, telegram, provider, pool, exit) translated to the flat
reader with source line numbers; flat form still loads; delegate/plugin limits
raised. Pools: failover/balance, used by delegation (tag-safe), by -m and for
the conversation when its provider hits a limit. -m SEL picks a pool, provider,
provider/model or model name; --model-list lists them with served models.
Usage limits: the agent finds the reset and waits (UI: Ctrl-C stops, /resume
goes on; on_limit=fail turns it off).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 22:12:26 +00:00
lotherkandClaude Sonnet 5.5 fac5cffc6f ui: keep the text the model streams before a tool call; test: gateway turn waits for the model switch
The final answer replaced the whole streamed entry, so 'I will read the file'
vanished. The fake Telegram sent the follow-up turn together with the model
button, so the turn could be read first (flaky test).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 19:04:23 +00:00
lotherkandClaude Sonnet 5.5 ba5b76f945 usage: per-provider allowance accounting, status line, headroom-aware delegation
limit=N/window and tokens=N/window on delegates and the main provider; calls are
counted in ~/.splinter/usage/<id>.log; /usage and the status line show how full
each allowance is; choose() skips used-up providers and prefers the one with the
most left among equal matches; refused calls bench the active provider.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 18:03:58 +00:00
lotherkandClaude Sonnet 5.5 cdb33cbda2 ui: input scrolls instead of crashing; history laid out once, word wrapped
The prompt wrote into the bottom-right cell of a non-scrolling window (segfault).
It now draws the tail of the line. The history pane computed height and drawing
separately; it now builds visual lines once (word wrap, hanging indent, scroll
in lines, reasoning clipped to its last lines).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 18:03:58 +00:00
lotherkandClaude Sonnet 5.5 cc2fcb5d34 www: hand-written site, drop the generator, no private values in docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 17:13:20 +00:00
lotherkandClaude Sonnet 5.5 478e2ec663 planner, tmux: rewrite with real JSON, validation and tests
planner: v0.2, state in plan_task_*.json via libmcp, atomic replace, refused states.
tmux: v0.3, in-process capture-pane diff, no watcher helper, tmux_ask/read/capture.
tests: test_tmux added, test_delegate_cli no longer hangs without a tty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 17:13:20 +00:00
lotherk 9c205dcd21 a2a: the client can send a file, and already saves what it receives
a2a_send posts SendMessage with a text part and, when a path is given, a file
part: base64 bytes, a name (the path's last component) and a media type
guessed from the name, at most 8 MiB -- the same cap the server enforces on
the way in. The answer is text; a file the other side sends back is saved by
collect_parts and named by path, which the tool returns.

sp_b64_encode is the missing direction of the base64 helper, with vectors of
its own in test_b64: empty input, one and two trailing bytes, a NUL.

test_a2a: a real PNG is attached, the request carries name, mimeType and the
base64 bytes, and the other side names it in the answer; a missing path is an
error, not a silent empty message.
2026-11-11 10:25:49 +00:00
lotherk a6d54d120b a2a: a2a_subscribe reads a remote task's events
The client half had GetTask and CancelTask; a subscription is the one that
shows what a task is doing. The tool posts SubscribeToTask and reads the SSE
stream into one observation: each statusUpdate's state and message, each
artifactUpdate's text, and a whole task if the server sends it that way, in
the order the events arrived. A plain JSON-RPC answer -- usually the
TaskNotFound error -- is read too, so a refused subscription says -32001
instead of 'no events'.

The fake agent answers SubscribeToTask with a status update plus an artifact;
test_a2a drives the tool through the script transport and checks the happy
path and the unknown id.
2026-11-11 09:18:26 +00:00
lotherk a72df5bb7f gateway: a local file that is not an image goes as a document
sendPhoto and sendDocument are one upload path now: send_upload() takes the
method and the form field, so ![alt](/path/report.md) leaves the chat as a
document with the alt text as caption, in the order of the answer. The photo
branch still checks the bytes (PNG/JPEG/GIF/WebP, 10 MiB), so a text file
cannot ride in as a photo; documents are capped at 50 MiB and have to be a
readable regular file. A missing or unreadable path stays a reference in the
chat.

test_gateway: a local PNG is a photo, a text file is a document, and neither
leaves the markdown in the chat.
2026-11-11 07:17:28 +00:00
lotherk 07e8b62be9 gateway: local images are uploaded, not just linked
![alt](/path/to.png) and ![alt](file:///...) are sent with sendPhoto as a
multipart upload (-F photo=@path), in the order of the answer, the alt text as
caption -- the same path a URL takes, except that the bytes come from this
machine.

Only a regular file that really is a PNG, JPEG, GIF or WebP up to 10 MiB is
uploaded, so the chat cannot be turned into a way to post arbitrary files.
Anything else (missing, unreadable, not an image, too big) falls back to
sending the reference as text.

tg_curl is split into tg_run(args) + tg_curl(json), so the upload passes -F
without duplicating the pipe, timeout and waitpid handling.

test_gateway: a local PNG goes out as a photo with its caption; a text file
named in the alt text is not uploaded and stays a reference.
2026-11-11 07:07:27 +00:00
lotherk 6074e7da1e gateway: markdown images go out as photos
![alt](https://...) is sent with sendPhoto (Telegram fetches the URL), the
alt text as caption, in the order the answer was written: text, photo, text.
An image inside a fenced block, an inline code span or a table row is left
alone -- lifting it out of a table would break the table.

When Telegram refuses the photo (unreachable URL, wrong type), the link goes
out as text instead: a broken image must not swallow the answer.

test_gateway: the photo call with its caption, the text before and after it,
no markdown image in the chat, and an image inside code staying text.
2026-11-10 20:47:39 +00:00
lotherk 5de70f5dbb 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.
2026-11-10 20:36:08 +00:00
lotherk 900b8e1efa a2a: SubscribeToTask replays the stored state
The last refused method. This server answers one request at a time, so while
a subscription is open the task cannot make progress: a live feed would be a
promise it could not keep. It sends one statusUpdate with the state and its
message (the answer, or the INPUT_REQUIRED question) and ends the stream; an
unknown id is TaskNotFound. The header no longer claims streaming is not
served, either.

test_a2a_server checks the replay for a stored task and the -32001 for an
unknown id.
2026-11-10 20:02:58 +00:00
lotherk cc9747b1a7 model choice sticks, endpoints are probed, connect is tested, A2A takes files
/model writes its choice to <config>.d/90-model.conf, so the next start uses
it; picking main deletes the file and the configuration speaks again. With a
plugin transport nothing is written, because that program picks the model.
/model probe asks every endpoint /v1/models and offers what it really serves
as buttons; the callback carries an index, because a GGUF path does not fit
in Telegram's 64 bytes. The TUI gets the same command: the list, or
/model <id|name>, with the same persistence.

/connect runs one tiny turn against the provider it just saved (30 s) and
says whether endpoint, model and key answer. The message with the buttons
goes out before the wait starts, so the save is visible immediately.

A2A no longer refuses binary parts: file{bytes} and raw with a non-text media
type are written to the session's inbox (0600, 8 MiB cap) and the prompt says
[file <name> at <path> (mime, n bytes)], so a text model can hand the file to
a tool. The client saves what a remote agent sends the same way
(SPLINTER_A2A_INBOX). SubscribeToTask stays refused: the task store has no
live events, and a one-shot replay would pretend to be a subscription.

Markdown gains <https://...> autolinks and images (as links, since Telegram
has no inline image without sendPhoto).
2026-11-10 19:33:38 +00:00
lotherk 7ce8e6b96c gateway: /model switches models, /connect adds a provider
/model offers the models the configuration names -- the main endpoint,
every delegate with a model, every exit -- as inline buttons and points the
agent's transport at the one that is pressed. /model <name> keeps the
endpoint and takes another model from it. A provider whose key variable is
not exported is marked in the menu. The choice is not written: it lasts for
the session, a restart goes back to the config.

/connect asks for name, endpoint, model and key variable, validates each
answer, and writes the delegate line to <config>.d/20-connect.conf before
anything is used, so the same run has the provider and the next start loads
it.  and [?2031h]10;?]11;?[>0q[?25lP+q4d73\[?1016$p[?2027$p[?2031$p[?1004$p[?2004$p[?2026$p[?u]99;i=opentui-notifications:p=?;\]1337;Capabilities\]7501;?\]66;w=1; \]66;s=2; \[?1049h[?25l[>4;1m[?2004h[?1000h[?1002h[?1003h[?1006h]7501;state=idle:app=opencode\[?2026h[?25l                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ]22;default\[?2026l]0;OpenCode[?2026h[?25l                                ▄     █▀▀█ █▀▀█ █▀▀█ █▀▀▄█▀▀▀ █▀▀█ █▀▀█ █▀▀██  █ █  █ █▀▀▀ █  ██    █  █ █  █ █▀▀▀▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀┃                                                                          ┃  Ask anything… "What is the tech stack of this project?"                 ┃                                                                          ┃                                                                          ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀~/src/splinter:mainshift+tab agentsctrl+p commands2.2.6]12;#c1c497[1 q[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃Build·DeepSeek V4.1 Flash 1017Ollama Cloud╹[?25h[?2026l[?2026h[?25l┃┃┃┃BuildDeepSeek V4.1 Flash 1017╹[?25h[?2026l]7501;state=clear\[?25h]22;\[>4;0m[?1003l[?1002l[?1000l[?1006l[?2004l[?1049l[?2031l]0;]12;default]112[0 q[?25h[?25h stand for their usual endpoints. The drop-in
goes next to the file that was actually read (sp_config_loaded_path), not
next to a path guessed from the environment, so --config works.

providers.c holds the list, the validation, the transport switch and the
provider identity main.c used to compute inline. test_providers covers the
list, the refusals, replacement of a line and a reload of what was written;
test_gateway presses the model button, proves the next turn goes to the new
endpoint (the test one is dead) and runs /connect to the written file.
2026-11-10 10:25:20 +00:00
lotherk e7a5afed3c gateway: render the model's markdown as Telegram HTML
A chat that shows **fett**, |---| and <b> lost the answer's shape. tgmd.c
turns bold, italic, strike, inline code, fenced blocks, links, headings,
bullets and quotes into the tags parse_mode=HTML accepts and escapes
everything else, so a '<' stays text and snake_case_name stays a name.
Tables keep the shape the terminal chat gives them: aligned columns in
<pre>.

Telegram's 4096 cap is met by splitting the rendered HTML at tag and
entity boundaries, closing open tags at the end of a piece and reopening
them at the start of the next. A piece the API refuses to parse is resent
stripped, because losing the shape is better than losing the answer.
SPLINTER_TG_MARKDOWN=0 keeps the old plain-text path.

test_tgmd pins the renderer and the chunker; test_gateway asserts the bot
sends parse_mode=HTML with <b>/<code> and a table in <pre>.
2026-11-10 09:37:27 +00:00
lotherk a00ffef699 a2a: INPUT_REQUIRED -- a turn that pauses and resumes
sp_agent_run can stop before a mutating tool when an approval callback
returns 2; the assistant call is in the conversation, no observation is.
sp_agent_resume(decision) runs the pending calls, adds the observations
and continues the model loop. Normal callers are unchanged: the ack, UI
and gateway paths still return 0/1.

The A2A server pauses as TASK_STATE_INPUT_REQUIRED, keeps the task and
its context, and resumes on SendMessage with the same taskId and
yes/no. CancelTask cancels a paused task. SendStreamingMessage has no
resume point and denies mutating tools instead.

test_pause covers allow/deny in the agent; test_a2a_input covers the
whole HTTP flow (yes, no, cancel). Full make check green (33 C tests).
2026-11-10 08:56:23 +00:00
lotherk 624fcf3d48 a2a: URL text parts and push-config CRUD; .local/lib untangled
A text/plain url part is fetched from loopback or a host in
SPLINTER_A2A_URL_ALLOW (1 MiB, no redirects); binary and other media
types stay refused. The four push-config methods create/get/list/delete
in-memory configs per task.

~/.local/lib is a real directory now: libsplinter.so plus a node_modules
symlink to ../npm/node_modules. The npm tree is not leftover -- it is
the mcp-local-memory MCP server and the Python user dirs -- so npm
root -g, the module and the installed splinter are verified working;
nothing was deleted.

Full make check green.
2026-11-10 08:49:27 +00:00
lotherk 544399a3bf a2a: GetTask/CancelTask as client tools, and a spec-shaped GetTask
The plugin registers a2a_get_task (read) and a2a_cancel_task
(destructive) for a local model that uses A2A as a tool source; both
share the endpoint or card and return the raw task/error JSON.

The server's GetTask result was wrapped as {"task": ...}; the spec's
result is the Task itself. Fixed, and the test checks the shape.

The website's tool-count regex missed digits, so a2a_get_task and
a2a_cancel_task were not counted; [a-z0-9_]+ now reports 25.

test_a2a drives both tools through the mock transport and checks the
session observations. Full make check green.
2026-11-10 08:28:12 +00:00
lotherk f4077687fa a2a: push the completed task to a webhook
A taskPushNotificationConfig in SendMessage/SendStreamingMessage posts
the completed Task (one StreamResponse) to its URL after the response.
Loopback is allowed; other hosts need SPLINTER_A2A_PUSH_ALLOW (comma
separated, '*' for all), so a client cannot turn the server into an SSRF
probe. The config token goes as X-A2A-Notification-Token, the
authentication as Authorization. The card says pushNotifications:true;
the standalone CRUD methods answer UnsupportedOperation (-32004).

test_a2a_server starts a fake webhook on loopback and checks the task,
the bearer credential and the token; a non-allowlisted host is refused
with -32003 before the turn. Full make check green.
2026-11-10 08:21:23 +00:00
lotherk a85b1c4615 a2a: text/plain raw and string data parts
The server accepts text, a string in data, and a text/plain raw part
(base64) via the new sp_b64_decode; a url part (not fetched) or a binary
part is refused with ContentTypeNotSupported (-32005). The client reads
text, string data and text/plain raw, ignoring parts it cannot render.
The agent card now says streaming:true and pushNotifications:false.

test_b64 covers the decoder; test_a2a reads raw/data from the fake
agent; test_a2a_server accepts a raw part and refuses a url. test_ui
waits for the turn label to disappear after Ctrl-C before typing again.

Full make check green.
2026-11-10 08:16:50 +00:00
lotherk 49d18361e2 tests: isolate the ack directory, fail loudly on a dead fake
test_ack used one fixed /var/tmp path; a leftover or a second run could
delete a request under another. It now mkdtemps a private directory (and
one for the world-writable case) and waits 10 s instead of 5.

test_gateway and test_ui check that the fake Bot API really started
(readiness plus kill -0) and print its log instead of racing a dead
server; the gateway waits 60 s for a turn under load. test_ui lets the
input process the typed keys before Ctrl-L instead of assuming one
delivery order.

Full make check green.
2026-11-10 08:07:24 +00:00
lotherk 6d9c74e3b1 cli: --interview needs no transport, and a test
check_usage demanded a transport before the ack/interview paths ran, so
'--no-config --interview' failed with 'no transport' even though neither
path runs a model. Exempt the ack and interview modes.

tests/test_interview.sh pipes six answers through the real binary,
checks the English catalogue prompts, the skipped marker and the written
profile. README notes that the questions follow the locale.
2026-11-10 07:46:28 +00:00
lotherk 68b2888334 i18n: the interview questions come from the catalogue
No German question texts in interview.c: the question table holds
catalogue keys, the prompt/hint/save API uses sp_t, and the intro,
profile header, skipped marker, written line and errors are translated
too. The profile section keys stay stable English schema names. The
CLI and the Telegram /interview read the same entries, so the default
English process asks English questions.

reply.empty replaces the hardcoded '(leer)' in the gateway. de/en/pt
entries added; check_i18n passes with 97 keys.
2026-11-10 07:34:44 +00:00