Commit Graph
123 Commits
Author SHA1 Message Date
lotherk ddf0ec5462 tools: valid schemas; sse: surface in-stream errors
A judged request sends the whole tool list to the judge. Claude validates the
schemas and rejected the request with 400
"tools.22.function.parameters.type: Field required": delegate_due and
delegate_jobs declared "parameters": {} instead of an object schema. junction
wrapped that 400 in the stream as data: {"error":{...,"code":400}}, but the SSE
parser ignored anything that was not a choice - so the turn ended with
"stream ended with no answer" and the one line explaining it was lost. Three
sessions stopped that way at the same minute.

- delegate_due/delegate_jobs now carry {"type":"object","properties":{}}.
- test_engine walks every registered tool and fails when parameters.type is
  not "object"; this catches the next schema before a judge does.
- sp_sse_line recognises a top-level error object, reports its message and
  remembers its code; the transport puts the code in the reply status.
- a 4xx from the stream ends the turn with the real message and is not
  retried; an empty 2xx stream and a 5xx still are. 402/429/529 stay with the
  usage-limit path, which already handles them.
- test_sse feeds the junction 400 event and checks message and code.
- README and docs/PLUGINS say why a tool schema needs type:object.

make check: all tests passed.
2026-11-18 06:28:23 +00:00
lotherk 0f8c5c7e96 plugin host: status segments get their own slots; tmux title
The status table was sized by MAX_COMPACTORS (8). With the status plugin's
seven segments and lcm's new "compact" segment, junction's segment was the
ninth: sp_host_add_status failed, junction_init returned -1 and the whole
plugin was skipped. The user saw no junction widget and no junction tool.
Status segments now have MAX_STATUS (16) slots of their own, and
test_compactor registers nine extra segments so the shared cap cannot come
back.

The curses chat also asks tmux, when TMUX and TMUX_PANE are set, to name the
window and pane after the directory it was started in: "S: <dir>", with
automatic-rename off for that window. tmux is exec'd directly, never through a
shell, and nothing is written into the curses screen. test_ui checks both
names.

make check: all tests passed.
2026-11-17 23:36:59 +00:00
lotherk af2001bfee ui, model, cost and idle timeouts
- lcm: the sidebar widget and /status segment show the context, the number of
  compactions, messages and bytes of the last cut, and how many old tool
  outputs were trimmed. The counters are the compactor's own, not an estimate.
- cost: a provider-reported USD cost (usage.cost/cost_usd) is carried through
  sse/openai, the agent and the engine. /cost reports it with the cache share
  and splits judged from plain turns; the notes say that an upstream judge is
  not visible in the provider's usage. The status plugin and junction prefer
  the reported number over list-price arithmetic.
- curses: the running turn's seconds moved from the input line to the status
  bar. Notes and errors are transcript rows below the cause, never text in the
  input line or the status bar; a failed backend request is a status row and is
  retried by the agent. The steer prompt is only "steer> " and what was typed.
- model: /model probe works in the chat. The picker lists the configuration at
  once, then asks the endpoint the session is on what it serves and adds those
  models, so a router's whole menu is selectable. provider/model selectors now
  apply the right provider instead of becoming a model name. The choice is
  written to <session>.model and restored when that session is reopened; /new
  carries the current model into the new session.
- sidebar: plugin titles are bold and underlined (this curses has no italic
  attribute), with a rule between the plugin blocks.
- run/cli: a command timeout is an idle window. Every chunk on stdout or
  stderr resets it, and the process is asked with waitpid(WNOHANG) whether it
  is still there before the window is extended. A long build that keeps
  reporting progress is no longer killed for being long; a silent hang is.
- config: ';' separates settings on one line, so
  plugin lcm { keep = 6; tool_trim = 8192 } parses as two keys.
- tests: lcm widget/status counters, one-line config blocks, session model
  restore and /model probe, cli idle timeout with a talkative and a silent
  command, run output reset, and the UI status/retry rows.

make check: all tests passed.
2026-11-17 23:21:56 +00:00
lotherk dc9a1c62ec lcm: never drop the newest user message
A long tool loop pushed the question out of the six-message tail; the model then
wrote 'The compaction dropped the user's actual question' and recovered it with
recall (session 1794952419). The newest user message is now pinned and put back
right after the summary, so the task survives any compaction. test_compactor
covers it.
2026-11-17 22:23:05 +00:00
lotherk 82bda09ed1 lcm: cut old tool outputs before dropping messages
Tool observations are the bulk of a long conversation. Before lcm drops any
message it now cuts every old tool output to a head and a tail with a marker
quoting its first line; the middle stays in the session log, where the recall
tool finds it. Only when that is still over budget are messages dropped, so a
conversation often keeps all its turns and only loses the middle of old
outputs.

- plugin lcm { keep = 6; tool_trim = 8192 } sets the verbatim tail and the cap
  per old observation (0 turns the trim off).
- the compacted summary says when tool output was cut too.
- test_compactor: a 20 KB old observation is trimmed, nothing is dropped, and
  the marker points at recall.
- docs/CONFIG and docs/PLUGINS updated; the user config uses 6/8192.

make check: all tests passed.
2026-11-17 21:44:45 +00:00
lotherk 63b6742447 retry reasoning-only streams, /compact, token threshold and target
- a stream that carried only reasoning and then ended without an answer used to
  abort with no retry: guarded_stream counted every chunk as "already
  produced". Only answer text and tool calls block a retry now; the thinking
  may repeat, a lost turn may not. test_agent has a stream that thinks, fails
  once and answers on the second attempt.
- /compact [tokens]: runs the compactors now (default: compact_target, else
  8000 tokens) and reports messages and bytes before/after.
- compact_threshold / compact_target in core (tokens): once the last request
  was larger than the threshold, the next request is compacted to the target
  before it is sent. 0 disables either.
- lcm gains a read tool `recall`: case-blind search in the session log for
  what compaction dropped from the prompt.
- user config: compact_threshold = 32000, compact_target = 12000.
- README/CONFIG document the command, the two keys and the cache trade-off.

make check: all tests passed.
2026-11-17 21:34:57 +00:00
lotherk 8aee12e9d4 drop tmux/planner/sysinfo, tasks becomes processes, no capitalised calls
- plugins/tmux, plugins/planner and plugins/sysinfo are gone (plugin list,
  Makefile rules, tests, docs). The config no longer loads them; the stale
  .so files were removed from the install tree.
- plugins/tasks is plugins/processes: plugin name "processes", widget
  "processes", tools process_start/process_list/process_result/process_kill.
  The sidebar now lists only running work: a finished task keeps its output
  in process_result but stops taking a row forever.
- the dead planner link in the delegate (link_plan_quota -> command "tasks")
  is removed with the planner.
- tool call rows are no longer capitalised: "run  ls -l", "read  src/x.c" as
  the model sent them, not "Run "/"Read ".
- tests updated (delegate panel expects no finished row, engine/UI expect the
  lowercase call row, secrets/delegate use the processes plugin and tools).
- the user's config gets a Delegate/Scheduler section: the three providers
  carry review/plan/docs tags and keep max_parallel=2; plugin scheduler stays
  loaded so waiting jobs are retried.

make check: all tests passed.
2026-11-17 21:06:55 +00:00
lotherk 1e15c91e4e interview: the model talks to the user, USER.txt rides in the prompt
The six-question form is gone. `splinter --interview` now opens the chat with an
interview system prompt: get to know the person, one question at a time, then
write a compact summary and end with INTERVIEW_COMPLETE.

- the marker is captured in the engine's turn thread and in the synchronous -p
  path: the summary before it is written to ~/.splinter/USER.txt (0600), the
  marker is stripped from the answer and the conversation, and a "interview
  saved to USER.txt" note goes into the transcript. An installation from before
  USER.txt keeps working: profile/<user>.md is the fallback until the first new
  interview.
- the USER.txt text is appended to the system prompt of every later session
  (plain "What you know about the user" block), including after /new and an
  agent switch (it rides in base_prompt).
- --interview is a chat mode with the interview prompt and no agent profiles;
  it needs a provider like any chat.
- Telegram: /interview swaps the system prompt, starts the conversation and
  restores the normal prompt once the summary is captured. The initial turn and
  every later reply are checked, so a model that summarizes immediately also
  works.
- test_interview.sh now proves capture, marker-free USER.txt and the summary in
  the next request; test_gateway drives /interview and the fake model answers
  with the marker when the interview prompt is in the request.
- docs (README, PLUGINS) describe the new flow.

make check: all tests passed.
2026-11-17 20:50:03 +00:00
lotherk 8aad48b928 remove the mem0 memory system
The memory tools talked to a mem0 server (memory_url/memory_key_env), one
bucket per unix user. It is gone: no memory_add, no memory_search, no mem0
client, no config keys, no test_memory.

- delete src/backend/memory.c and memory.h; the engine no longer registers the
  tools; config loses memory_url/memory_key_env; SPLINTER_MEM_KEY leaves the
  secret list; docs/CONFIG, ROADMAP and GATEWAY stop mentioning it.
- the unix identity helper stays, under its real name: sp_user_name() in
  src/backend/user.c (profiles, interview and the Telegram gateway used it).
- tool list is now read/search/list/write/edit/run/skill_*/... plus the MCP
  session tools; nothing about memory remains.
- test_mcpsession.sh: the client socket gets a 120 s read timeout, not the
  5 s connect timeout (a turn under load answered too late and looked hung).

make check: all tests passed.
2026-11-17 20:00:38 +00:00
lotherk 36a66ab4f0 self monitor, MCP session tools, junction serving endpoint
- plugins/self: what the session costs the machine - RSS, CPU, threads, fds
  and io of the process itself from /proc/self/*, and the same (count, RSS,
  CPU) for every process whose parent chain reaches it: run calls, MCP
  children, delegates. Widget, /self and the session_usage tool; interval in
  the plugin block (default 2 s).
- MCP server: the session tools. splinter_sessions, splinter_state,
  splinter_models, splinter_agents, splinter_history, splinter_say,
  splinter_open, splinter_model, splinter_agent, splinter_steer,
  splinter_cancel, splinter_approve. Say starts a real turn and returns the
  answer; a turn parked on an approval returns the question instead of
  failing. Mutating tools obey --autonomous. `--daemon --mcp-server-listen`
  runs the MCP server on a thread beside the Telegram daemon.
- the MCP server asks the engine for its registry on every call (a session
  switch replaces it) and copies the tool name out of the parsed JSON before
  freeing it (the first version compared a dangling pointer and answered
  every session call with empty text).
- junction: "serving <endpoint>" - streaming answers carry no
  X-Junction-Endpoint, so the plugin compares the route targets' ok counters
  from /status between samples and names the one that grew, with its
  last_ms. The header is still used when present (non-streaming). The
  X-Junction-Endpoint of the plugin's own /v1/models probe remains a probe
  fact in /junction only.
- transport: X-Junction-Endpoint is parsed from the response headers in both
  the streaming and the non-streaming path and published through
  sp_host_served_by(); sp_reply carries served_by.
- the curl rate guard (--speed-limit/--speed-time) is gone: it cut slow
  router streams with "Less than 1 bytes/sec" even while keepalives arrived.
  The overall -m timeout stays.
- focus: the sidebar shows "recap N, every M turns", and an applied recap
  writes "recap applied (turn N, every M turns)" into the transcript (host
  status messages are now drained during a turn; protocol clients get them
  as entry events too). The initial goal announcement says so as well.
- tests: test_self, test_mcpsession.sh (real socket), test_focus status
  messages, test_junction serving placeholder.

make check: all tests passed.
2026-11-17 19:13:59 +00:00
lotherk 55ca5c71f8 junction widget: the model's route, nothing else
Two reasons the sidebar was useless: it named the route of the *configured*
provider model, not of the model the run was switched to (/model
deepseek-v4.1-flash kept showing qwen3.6-35b's kontron/kompute route), and it
repeated server counters (MCP servers, queue, requests, probe headers) that
have nothing to do with the conversation.

- sp_host_model()/sp_host_set_model(): the engine publishes the model it is
  actually on; the engine sets it at plugin load, after /model and on every
  state read. The junction plugin prefers it over the config.
- the widget is now only the model, the route from the matching rule (one
  target per row, "!" when that target's probe fails) and "N/M up":
  deepseek-v4.1-flash / route opencode-go0 / opencode-go1 / ... / 4/4 up.
  Uptime, MCP servers, queue, requests, endpoint p95 and every response
  header stay in /junction.
- widget text may use up to 8 rows (a four-target route plus model and
  health is seven).
- test_junction: the widget must be exactly "m\nroute a\nb!\n1/2 up" and
  must not repeat mcp/models/probe stats.

make check: all tests passed.
2026-11-17 18:28:00 +00:00
lotherk 7e8fe5b825 retries are visible in the prompt line
The session showed the last error as "retry 1/3 in 5000ms: openai: stream
ended with no answer" with nothing on screen: the turn looked hung for the
five seconds, then either answered or failed. The retry itself was fine; the
operator could not see it.

- sp_agent_config gains note()/note_ctx: a status line for the operator, ""
  clears it. The engine turns it into SP_EV_NOTE, so curses shows it in the
  steer line and protocol clients get the note event.
- agent_request() emits "retrying in N s: <reason>" before sleeping and clears
  it when the attempt answers or the retries are exhausted.
- i18n ui.retry_note in en/de/pt_BR; README says the wait is visible.
- test_agent: the note callback must have seen "retrying in" on the recovery
  case.

make check: all tests passed.
2026-11-17 18:14:31 +00:00
lotherk b0c1da65a2 junction: the session's route, not the probe's endpoint
The widget printed "endpoint=opencode-go" because that is the
X-Junction-Endpoint header of the plugin's own /v1/models probe, which
junction routes there by a path rule. It says nothing about where the
conversation goes, and the operator's qwen3.6-35b is routed to kontron and
kompute0..2 - so the line was wrong, not just imprecise.

- read the active model from the config (sp_usage_active -> provider model)
  and match /status' rules against it: exact model > glob > catch-all, rules
  with a path are another route. The result is the route line:
  "route kontron! kompute0 kompute1 kompute2" ("!" = that target's own health
  probe is not ok).
- /junction shows model, route and "route health: N/M up, down: ..."; the
  /v1/models header block is marked as the probe's route, not the session's.
- the header stats label the probe values (probe-ms=, probe-cache=) and no
  longer print the endpoint header as if it were the route.
- side_text(): wrap one line at a time and let a continuation use up to three
  rows; passing a multi-line string to one mvwaddnstr() double-counted rows
  and cut "route ... kompute1 kompute2" in half.
- test_junction: fake /status gains rules and per-endpoint probe_ok; the test
  sets the run's model ("m") and expects "route a b!", "probe-ms=12",
  "route health: 1/2 up, down: b" and no "endpoint=" in the stats.

make check: all tests passed.
2026-11-17 12:31:58 +00:00
lotherk 0f46c22a58 model picker, steer feedback, tolerant SSE with retries, junction headers
- /model in the curses chat opens a picker: Up/Down, typing filters by
  provider/model, Enter takes the selector, Esc cancels. The list comes from
  the backend (sp_engine_models -> sp_provider_choices), not from a text
  scrape; the socket has a `models` command, so --attach gets the same picker,
  and the switch is still the ordinary "/model <selector>" input.
- steering: Enter during a turn now says so twice - a "steering queued: ..."
  row in the transcript and "Ns steering queued (n) steer>" in the input line
  until the step boundary picks it up; a rejected steer is an error entry.
- input lag: typing during a turn is echoed immediately (the input line is
  redrawn per key, not at the next 100 ms frame), and the history is only
  repainted when its generation changed, so a streaming turn no longer
  repaints the whole transcript on every clock tick.
- sidebar: the first line of every widget is bold, like its heading, so a
  plugin block has a title instead of a wall of small print.
- junction plugin: keeps every response header from /mcp, the status route and
  /v1/models; the widget shows the X-Junction-* routing stats, /junction lists
  all headers per source. It reads the status aliases (/status, /v1/status,
  /queue, /v1/queue) and remembers the one that answered, parses queue,
  endpoint p95/exhausted counts, and counts the models (/v1/models, probed on
  its own slower interval because it goes upstream).
- SSE: blank lines no longer abort a pretty-printed object, a truncated tail
  is dropped instead of failing the turn ("incomplete data line" is gone), and
  a [DONE] with a fragment clears it.
- retries: a request that fails before anything streamed (connection, missing
  status, 5xx) is tried three more times, 5 s apart; 4xx is not retried, and
  after the first chunk the error is reported instead of printing the answer
  twice. Ctrl-C ends a wait at once; SPLINTER_RETRY_WAIT_MS overrides the wait.
- tests: test_sse (split object across events, truncated tail), test_agent
  (four 500s = four requests; two 500s then an answer), test_engine and
  test_protocol (models list), test_junction (headers, aliases, models),
  test_ui (/model picker), test_focus (status keys).

make check: all tests passed.
2026-11-17 11:46:11 +00:00
lotherk 614988aa68 junction plugin, light/dark themes, goal completion
- plugins/junction: evaluates the X-Junction-Mcp header and /status; the
  sidebar widget, the "junction" status segment, junction_status and
  /junction show uptime, MCP-server health, queue and request counts.
  The url/header come from the plugin block, the mcp junction server or
  SPLINTER_JUNCTION_URL/TOKEN; the key is never printed.
- theme: two flat themes. light is a white page with black text, dark the
  same inverted; chat, sidebar and input share the page, the status line is
  the one separate surface. Each CDE palette keeps its own rules.
- curses: the sidebar uses the theme's own text on its own background
  (white/black) instead of white on a darkened surface; the one column
  between chat and sidebar is painted, so a white theme has no black seam.
- focus: the goal goes into the first prompt (config, resume, planner), and
  every goal-carrying text asks the model to end with GOAL_COMPLETE. The
  marker is read from the conversation and the session log and recorded as
  goal_state=succeeded in the session meta; /goal and the sidebar say
  [done], reminders stop, a new goal opens a new one.
- tests: test_junction (fake server, header identity, no colon in widget
  continuation lines, no key in the output), test_focus (announcement,
  completion in the compactor and from the tick, persisted state),
  test_theme (flat themes, list order).

make check: all tests passed.
2026-11-17 10:10:47 +00:00
lotherk be3d0ee415 ui: slash commands run off the screen thread, sysinfo one row per metric
A command that talks to the network (/connect, /model probe, a plugin
command, a commands/ program) ran on the UI thread: the prompt froze until
it returned. ui_command_run() now runs be->input on its own thread while
the screen keeps reading keys. One next line can be queued and is processed
when the command ends; Ctrl-C clears the edit, Ctrl-D quits. The worker
never touches curses, and the backend is not polled while it runs.

Widget text may now have continuation lines without "name:": they are
rendered under the widget above. sysinfo uses that for one metric per row
instead of wrapping "RAM ... CPU ..." into the same paragraph. A blank row
stays between widgets, not between their rows.

The Ctrl-C UI test looks for the active steer prompt; "working" is replaced
by it on the first 100 ms tick.

make check: all tests passed.
2026-11-16 18:42:27 +00:00
lotherk 67b4d5d070 goal in the session, /continue, a white sidebar, sysinfo
The goal lived only in the focus plugin's memory: a resume lost it and
there was no way to start the next turn from it. It is now stored in the
session's .meta (one line, 1000 bytes) and read back when the plugin sees a
new session id, so /open and a resumed process find their own goal again.
/continue reads the same sidecar and starts a turn with "Continue working
toward this goal: ...". /goal still sets it and starts the recap turn.

The sidebar was a patchwork of pairs and widgets could inherit the wrong
background. It now uses one PAIR_SIDE (white on a darkened theme
background) for every heading, label, usage row and widget; the window
gets that pair as its background, so no line paints its own surface.

New plugins/sysinfo: a widget thread samples /proc/meminfo, /proc/stat and
statvfs("/"), and publishes RAM, CPU, swap and disk with five-cell
[|||| ] gauges every two seconds. It is added to the shipped plugin list
and to the user's config.

agent.c keeps the last prompt/cache counters when a tool-call step reports
no usage. A zero there used to reset the ctx gauge in the status bar after
every tool call.

Tests: session goal survives reopen, /continue returns the prompt,
make check: all tests passed.
2026-11-16 18:30:42 +00:00
lotherk 006198425c sse: keepalives are not errors, pretty-printed data is assembled
An OpenAI-compatible proxy may put non-JSON text behind the data: prefix
(`data: ping`, `data: [PING]`) or pretty-print one JSON event over several
data: lines. The parser called both "unparseable data line" and failed the
turn.

- Empty payloads, `ping`-style text and non-[DONE] brackets are ignored as
  keepalives. Only a line that claims to be a JSON object is still an error.
- A data payload starting with '{' that does not parse yet is kept and the
  next data: line is appended; the event is parsed when it completes. A
  blank line (event end) with an unfinished object is still the error, and
  sp_sse_finish() refuses an unfinished tail.
- The Anthropic parser gets the same keepalive tolerance.

test_sse: keepalive lines, multi-line JSON and a broken event.
make check: all tests passed.
2026-11-16 18:01:06 +00:00
lotherk bff47eede8 ui: palette roles, a working unlimited usage count, /goal as the recap
Three things the screen and the goal were getting wrong.

Colours. The theme had one accent for the user and grey for everything
else. theme.h now carries agent, think, tool and notice colours. A CDE
palette maps them to sets 7 (answer), 3 (reasoning), 6 (tool) and 8
(status); Xresources uses colour10/11/14/13 on dark and 2/3/6/5 on
light. Role colours keep their hue and are pushed from the surface only
when they would disappear; each role has a slightly different minimum,
so even a monochrome palette yields distinguishable steps. The 256-colour
mapping now takes the nearest cube/ramp entry instead of rounding each
channel down, which turned a dark orange into grey 240.

Usage. sp_usage_get() only counted requests inside a declared window. A
provider without limit= therefore always read "0 calls" in the sidebar,
although every call was in its log. Calls are now counted when no window
is declared; test_usage covers it.

Goal. /goal <text> set a variable and answered "goal set" without starting
a turn. The engine now starts the recap prompt: the model writes a short
recap, the focus plugin remembers that answer and injects it every seventh
turn (SPLINTER_FOCUS_EVERY still overrides). /recap is gone as a command;
its old behaviour is what /goal does now. A palette and a wiki page are
not enough to make that visible: the prompt, the confirmation entry and
the sidebar goal all show up in the chat.

Tests: palette role separation and indexed roles in test_theme, four
unlimited calls in test_usage, recap capture/injection and the missing
/recap in test_focus, and a settle delay so the UI tests type after
ui_read_line() owns the keyboard. make check: all tests passed.
2026-11-16 17:48:22 +00:00
lotherk 1726bc1967 ui: a status bar above the prompt, a scroll fix, a steer space
The screen had no room for the numbers that say how a turn is doing, and
two older behaviours still hurt: scrolling to the top made PgDn jump back
to the top, and a catalogue's steer mark without its trailing space glued
the typed text to ">".

- draw_statusbar() in curses.c: one row above the prompt with
  ctx used/max + [||||    ] gauge, cache share and tok/s. The history and
  sidebar lose one row; the prompt stays the bottom row. The bar is drawn
  on every idle tick, during a turn and in --attach.
- ctx: optional field on a provider (and in core) in tokens; the engine
  reports it in struct sp_engine_state. SPLINTER_CTX_MAX still overrides it.
- cache: sp_reply gained tokens_cached. OpenAI reads
  prompt_tokens_details.cached_tokens / prompt_cache_hit_tokens, Anthropic
  reads cache_read_input_tokens and counts cache reads+writes in the prompt
  total. sp_agent_stats keeps the last request's prompt and cache share;
  the engine keeps the turn's output tokens for a real tok/s.
- scroll: grow scroll by the growth of maxscroll, not by the distance from
  the first visible line. At the top that distance was 0, so every frame
  re-added the whole scrollback and PgDn could not leave the top.
- steer mark: append the missing space if a catalogue omits it.
- protocol state carries ctx_used/ctx_max/cached/turn_tokens_out, so the
  attached UI shows the same bar.
- tests: cache parsing in test_sse/test_openai/test_anthropic, ctx parsing
  in test_confblock, and test_ui checks the bar, the cache share and the
  PgUp-to-top/PgDn-down path.

make check: all tests passed.
2026-11-16 16:59:49 +00:00
lotherk 76c9007c02 config: a core default is a choice, not something a main endpoint overrides
load_config() copied the config's main endpoint into the command-line
options, so apply_selection() saw o->endpoint != NULL and skipped
core { default = ... }. Every config with a main endpoint (and every
/model drop-in, which wrote exactly that) silently ran the main endpoint
instead of the default; a drop-in with model = provider/model even put a
slash-name into the model field.

- The main endpoint is applied only when no -m and no default exist.
  -m and a command-line --endpoint still win.
- /model saves a delegate choice as "default = ID[/MODEL]" instead of a
  second main endpoint; the provider block supplies kind, endpoint and
  key. A model of the main endpoint has no provider block, so that one
  keeps the full endpoint/model/api_key_env form.
- docs/CONFIG.md, README and test_providers describe the order and the
  new drop-in line.

Verified with a fake endpoint: core default -> mb, -m a -> ma, main-only
config -> mmain, a stale endpoint/model drop-in no longer shadows the
default, a "default = a" drop-in does.
make check: all tests passed.
2026-11-16 16:27:03 +00:00
lotherk 42c11f95c7 providers: a 3s connect timeout, one model-list path, a tmux test of its own
The model-list probe hung on a host that accepted no connection and the
delegate list had a second, worse way to ask: popen(curl) without the key and
a line-by-line "id" scan that saw only the first model in one-line JSON.

- http_get(): --connect-timeout 3, -m 8 for the answer. Every provider
  probe (/v1/models, usage/balance) uses it.
- delegate_list probe=1 builds an sp_provider and calls sp_provider_served(),
  so it sends the key, reads the JSON and lists every model.
- The route stays <endpoint>/models: /v1/models for opencode, ollama.com,
  api.anthropic.com and the junction gateway (verified against all four).
- test_tmux unsets TMUX/TMUX_PANE and points TMUX_TMPDIR at its own temp
  dir: no session, window or keystroke on the user's server. The literal "x"
  probe text is gone.

make check: all tests passed.
2026-11-16 15:28:38 +00:00
lotherk 9af7695064 gateway streams: the answer grows while the provider talks
- stream:true uses the provider's send_stream and writes each text delta as a
  chat.completion.chunk as it arrives, instead of one chunk at the end. The
  SSE headers and the role chunk go out before the upstream call, so a slow
  provider still gives the caller a live connection.
- caller tool calls are sent as one tool_calls delta at the end of the step,
  when their names and arguments are complete; filtered gw_ calls are
  renumbered 0,1,... so strict accumulators see no gap. Local gw_ calls stay
  invisible.
- stream_options.include_usage asks the provider for usage and adds the summed
  token counts in a final chunk before [DONE]. Usage is now summed over every
  upstream round, for the non-stream reply too.
- an error after the first byte becomes an SSE error object plus [DONE]; a
  bad request is still an ordinary HTTP 400. SIGPIPE is ignored and
  TCP_NODELAY set, so a caller that closes early cannot kill the gateway.
- tests: fake_gateway.py has a slow stream, tests/stream_probe.py measures
  that chunks arrive while the upstream streams, usage is checked, and the
  mixed reply keeps index 0 after filtering. make check green.
2026-11-16 14:06:54 +00:00
lotherk dd135f3b33 sessions get titles, /rename and /rm
- .meta carries a title: the first user line is stored once, /rename
  [ID] TITLE replaces it. Reopening preserves the title and the original
  creation time.
- /sessions shows the title, locally and over the link; the protocol's
  sessions event carries it. Old sessions without a stored title fall back
  to their first user line when listed.
- /rm ID removes a session that is not open: JSONL, meta, saved agent
  profile and logs/<id>; the open session is refused, /rm last resolves
  the newest.
- tests: test_session (auto title, explicit title survives reopen, old-log
  fallback, recursive removal), test_protocol (title, rename, rm, errors),
  test_ui (title, rename, rm). make check green.
2026-11-16 12:10:06 +00:00
lotherk a01bfe9df1 sessions switch locally, gateway keeps caller settings and mixed calls
- sp_engine_switch(): close the old engine and open the chosen session from
  the same options; if the new one fails, reopen the session the engine was
  on. The protocol's open and the in-process /open both use it. The curses
  screen clears the pane and replays the new history, so /open no longer says
  it needs --attach.
- gateway: temperature, top_p and max_tokens (max_completion_tokens) are
  forwarded to the provider instead of dropped; request bodies may be
  Transfer-Encoding: chunked; a mixed reply runs the gw_ calls, returns the
  caller's calls in tool_calls and puts the local observations in content
  (also in the SSE delta), so the caller can echo them back.
- reconnect: when the remembered session is gone, the screen says which one
  and stays on the session the server has instead of silently swapping the
  transcript.
- ring: the exits' transports are disposed on plugin shutdown.
- /status goes through the catalogues like the rest of the UI (the English
  labels and their alignment are unchanged, so existing parsers still work).
- the man page passes mandoc -Tlint and covers the gateway and /open.

Tests: test_ui.sh covers local /sessions and /open (new, back, history),
test_protocol.sh the shared switch, test_reconnect.sh a vanished session,
test_gateway_openai.sh forwarded parameters, a chunked body and the mixed
reply in JSON and SSE. make check green.
2026-11-16 10:18:41 +00:00
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 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 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
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 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