70 Commits
Author SHA1 Message Date
lotherk 74df75d438 no approval gate: splinter runs what the operator's registry offers
Konrad, 24.11.: "v1 geht durch ohne irgendwas. ich will auch keine approvals
generell. ich will nur das der user mit ask nach sachen gefragt werden kann."

Removed the whole approval apparatus, not just the prompt:

- agent.c: the decision point (sp_host_gate/approve callbacks), the
  pause/resume path (has_pending, pending_from, sp_agent_resume), ack_approval,
  ask_operator and the ack stdin thread are gone. A tool runs; its exit status
  is the observation. sp_tool_policy (allow/deny per profile) stays - that is
  the operator's own configuration, not a question to the operator.
- engine.c: SP_EV_APPROVAL, sp_engine_approve, the approve_pending condition
  variable and the `approval`/`approve` protocol commands are gone.
- openai_server.c: the v1 endpoint runs gw_* tools without a gate; the
  autonomous flag is no longer part of sp_gateway_opts.
- a2aserver.c: INPUT_REQUIRED and the resume-by-taskId path are gone; CancelTask
  stays. An A2A caller has no operator sitting in front of a prompt.
- mcpserver.c: --autonomous no longer gates mutating tools; the flag and the
  config key are accepted for compatibility and documented as changing
  nothing.
- telegram.c: tg_approve and the approval callback are gone; ask is the only
  dialog, and /cancel inside it still ends the turn.
- front ends: protocol.c, curses.c, ui_local.c, ui_remote.c, client.c lose the
  approval event and the waiting flag.
- ack.c stays: it is a plugin API (plugins/kids asks its parent through it),
  not splinter's own gate. --ack is documented as such.

Tests: test_pause.c guarded the pause and now guards the opposite (a mutate and
a destructive tool run, nothing is asked). test_a2a_input.sh, test_protocol.sh,
test_ui.sh, test_agents_ui.sh, test_gateway.sh, test_gateway_openai.sh,
test_agent.c and test_mcpsession.sh were rewritten the same way;
splinter_approve must now be absent from the MCP tool list. Every rewritten
test was run red against the old behaviour where that was possible.

make check: all tests passed (428 s)
make check-asan: all 47 test binaries clean
make check-tsan: all 47 test binaries free of data races
2026-11-24 11:46:10 +00:00
lotherk 6debe213c3 ask: the wait for an answer is the operator's to set, and a late answer is refused
The 900 s wait was not the defect -- a person reads and thinks. Being hard
coded was: a run with no operator attached (an older protocol client that
does not know SP_EV_ASK, a script) lost the turn for fifteen minutes and
nobody could shorten it. Measured before the change: a client that ignores
the event saw the question and then no turn for 10 s.

sp_ask_wait_s() reads $SPLINTER_ASK_TIMEOUT, then ask_timeout from the
config, then SP_ASK_WAIT_S = 900. No upper bound: how long a turn may wait
is the operator's call. Consumers: engine_ask, tg_ask.

protocol.c also dropped sp_engine_answer's return value, so an answer that
arrived after the question was gone (wait expired, turn cancelled) looked
accepted. It now reports "no question is pending", as steer already did.

Test evidence:
- tests/test_ask_timeout.sh (new, wired into make check): with
  SPLINTER_ASK_TIMEOUT=3 the turn returns in 3 s with the "no answer"
  observation instead of parking. Proven red against the old code (env
  ignored: 5 FAILs, the client got no turn at all) and green on the fix.
- ask_timeout in the config file takes effect too: measured 3.1 s against a
  running --serve, so the docs line is not a claim.
- sp_ask_wait_s() edge cases: unset/0/-5/abc -> 900, 1 -> 1, 42 -> 42,
  999999999999 -> clamped.
- make check green (336 s), make check-asan and check-tsan clean (46
  binaries each).
2026-11-24 09:00:49 +00:00
lotherk 181b2c0638 ask: the model can put a question to the operator, in every front end
The `ask` tool asks and the answer -- or "nobody answered" -- becomes the
observation. Read class: it changes nothing on the machine, and the authority
is the operator, not a gate.

Front ends: the chat draws a dialog (options to pick, typed words still count),
the protocol carries it as an `ask` event and an `answer` command, MCP returns
it from splinter_say and resumes with splinter_answer, the Telegram gateway
sends it as a message and takes the next message from an allowed user.

What the review of the WIP found, and what this fixes:

- -p hung for the full 900 s ask wait: sp_engine_prompt installed engine_ask,
  but nobody polls events on the synchronous path. cfg.ask now stays NULL
  there, so the tool answers at once with "nobody can be asked here".
  Measured: 3 s instead of 900 s (was rc=124 after 20 s).
- splinter_say over MCP hung the same way, because tool_say only looked at
  st.waiting. It now looks at st.asking and returns the question; the client
  timed out at 15 s before, and the turn was lost.
- protocol.c read the question buffer uninitialized when sp_engine_ask
  returned 0.
- turn_ask answered nothing when the window could not be opened, which parked
  the turn for the full wait.
- pick_run computed the list height without the question's rows, so the
  highlighted row scrolled out of the window (reproduced: after nine Downs no
  ">" row was on the screen). pick_draw and pick_run now share pick_listtop().
- the Telegram gateway was dead for this tool: it runs its turns on a copy of
  e->base, where ask was never set, so the model was told "nobody can be
  asked" while the operator sat in the chat. New tg_ask, verified against a
  running daemon and covered in test_gateway.sh.
- tests/test_ask_ui.sh was untracked and not in make check, so it never ran.

A2A keeps no ask channel on purpose: there an approval pauses the task into
INPUT_REQUIRED, and the ask signature cannot express a pause -- saying
"nobody can be asked" is the honest answer there.

Tests: make check green (327 s), including the new test_ask_mcp.sh and
test_ask_ui.sh, both wired into make check. test_ask_mcp.sh was verified to
fail against the unfixed code (client times out, no result written).
make check-asan: 46 binaries clean. make check-tsan: 46 binaries, no races.
2026-11-24 07:57:35 +00:00
lotherk 4fc7614cc5 builtin: tools_root - the file tools stay inside one directory
The five file tools act with the rights of the process. The authorization
classes say *whether* a tool may run, never *where*: a model with mutate rights
- or a prompt-injected one - could write ~/.ssh/authorized_keys or the config
that names the plugins this harness loads.

core { tools_root = ~/src } closes that. Empty (the default) means no boundary,
so an existing setup is unchanged.

What makes it hold, rather than look like it:
- every path is resolved before it is used, and the resolved path is what the
  tool then opens (realpath for existing paths, resolve_target for one that
  does not exist yet, so a dangling symlink cannot be followed out);
- search resolves every entry it recurses into: stat() follows a directory
  symlink, so guarding only the argument left a door open (found and fixed in
  this change, the test went red without it);
- the root is resolved once at startup, and a root that does not exist is
  refused with the path in the message instead of matching nothing;
- run cannot be fenced (a shell opens any path); it starts in the root, and a
  failed chdir is written into the tool's observation, not the operator's
  terminal.

Verified: an escape by absolute path, by ../.., by a symlink inside, by a
dangling symlink, and through search's recursion are all refused in the live
engine path (scripted model, tool call in the session log); the same tree
inside the root still reads; without tools_root everything behaves as before.
Each guard was removed once to watch the test go red. tests: test_builtin,
test_config, test_secrets ok; make check: all tests passed; check_asan: all 46
binaries clean.
2026-11-23 16:55:49 +00:00
lotherk f6211362cb sessions: /sessions is a picker over sources, foreign sessions included
`/sessions` printed a list of ids; the operator then typed the id into
/open. The list was the wrong shape for a thing you pick from, and the
foreign stores (claude, hermes, opencode) were not in it at all - their
sessions were only reachable through the model's import tool.

Now it is a picker in two steps: the sources first (`splinter` and every
foreign store that has something), then the rows of the chosen one. A
foreign row's id is "claude:<id>", which sp_engine_switch() already reads
as an import - so picking it loads and continues that session, exactly
like `/open claude:<id>` typed by hand.

The picker got one shared implementation while it was open: pick_run()
with a value/label list, a configurable title and two hint lines. /model
and /sessions draw the same way now instead of two copies that could
diverge on Esc, resize and the filter. One window is held across both
steps, so a quick double Esc leaves; with a window per step the second Esc
landed in a window that was already gone and the picker stayed open.

Over the socket the same two steps exist: `{"cmd":"sources"}` and
`{"cmd":"sessions","source":"NAME"}`.

Tested: make check, all suites green (test_engine, test_protocol,
test_ui against a real tmux pane, 229 i18n keys in three catalogues).
2026-11-22 21:32:31 +00:00
lotherk d714efb16e agent: a broken tool call gets five corrected tries, then words
Konrad saw "agent: model sent malformed tool arguments" on the Telegram
daemon again and again. The retry existed, but it was useless: three
attempts in a single millisecond, each with the identical prompt, so the
model answered with the identical broken call. After the third the turn
died with an error nobody can act on, and the session lost the work.

Now:

- Five tries, five seconds apart (SPLINTER_RETRY_WAIT_MS still shortens
  it for the tests). The wait goes through retry_sleep(), so Ctrl-C does
  not have to sit it out.
- Every retry carries a correction as a user message: what was wrong,
  and what to send instead. A tool result without a call before it is
  refused by the endpoint, so it has to be a user turn.
- A call cut off by the token limit is a different fault from a call the
  model could not write. sp_reply grew a `finish` field ("length",
  "max_tokens"), filled by both the SSE parser and the non-streaming
  reply; the correction then asks for a *smaller* call instead of the
  same one the limit already truncated.
- After the fifth failed try the turn does not die: the model is asked
  for plain words ("say what you wanted to do, step by step"), and
  whatever it sends ends the turn as an answer. A call that arrives
  anyway does not run and is logged whole.
- The log line keeps the whole argument string, not 240 bytes of it -
  "mal gucken" means the operator can read what the model tried.

The tests were only rebuilt when their .c changed, so a new field in
struct sp_reply left them reading a different layout; that failure looks
like a broken test, not a stale object. $(TESTS) now depend on $(HDRS).

Evidence: make check exit 0 (45 binaries + 20 shell tests,
SPLINTER_RETRY_WAIT_MS=0). Counter-checks: with the old single-prompt
retry test_agent fails on bad_args_calls == 6 and on the correction
text; without the finish field cut_off_second carries "not valid JSON"
instead of "cut off by the".
2026-11-22 14:46:08 +00:00
lotherk f19fbf6ac1 cli: splinter -c --claude continues the newest claude session of this folder
The operator's claude ran into its limit mid-work; the session was too full to
continue there. The foreign plugin could already read and import it, but only
through a tool call inside a turn - there was no way in from the command line.

--claude, --opencode, --hermes and --from=NAME make the newest session that
tool ran in this directory the session of the run: it is imported before the
history is loaded, so the first turn already carries it. -c no longer fails in
a folder that has no splinter session yet; it falls back to "no session" and
lets the import decide. An empty placeholder session is removed again, whether
the import worked or not.

Repeating the call continues the same session instead of importing a second
time: sp_session_foreign() reads the foreign= marker back, so the work done in
splinter is kept. A second foreign_import into the same session replaces the
history rather than appending it twice (path_join built "id/.jsonl", so the
replace branch never fired).

Test: tests/test_foreignopen.c builds a claude fixture under its own HOME and
covers import, idempotency, replace-not-append, the empty placeholder and a
folder with no foreign session. make check exit 0, check_asan.sh clean.
2026-11-22 13:20:45 +00:00
lotherk f7120882fa sessions: a resumed session is the whole transcript, not a chat log
A session file was written as if it were a chat: role and text, nothing
else. Reading it back kept "user" and "assistant" and dropped everything
else - and nearly every line of an agent transcript is an observation.
Measured on three real sessions: 21 of 1507 messages came back, 8 of 1356,
3 of 317. --resume then sent 1% of the conversation and the model had no
idea what it was continuing.

Three writers had to change with the loader:

  - A turn that asked for tools wrote no line at all (agent.c only wrote
    when ncalls == 0). It now goes out with its tool_calls, and each result
    with the name of its tool and its call id; a provider rejects a tool
    message without them.
  - {"role":"user","text":""} came from the steer path and showed the model
    a blank human turn it answered. sp_session_append_rec writes nothing
    when text and calls are both empty.
  - A record from the old format has no name and no call id. It is paired
    with the next unanswered call of its pending assistant turn, or given a
    synthetic one (recovered-N). Dropping it is what emptied every resume;
    keeping it unpaired is what a provider answers with 400.

The same pass gives the core its own compactor (compact.c): a thread digest
- one line per dropped message, OPERATOR: 800 chars, assistant: 300, tool
result 160 - so the model keeps the story, not a count. lcm stays a plugin
that runs after it; sp_core_compactor() is the fallback only when no plugin
registered one, because running both eats the conversation before lcm sees
work to do.

Two bugs fell out of the same area:

  - The plugin host was only built when a plugin was configured, so a
    plugin-less run had no compactor at all: over max_bytes the turn was
    refused instead of compacted (90 KB session, budget 8000, "nothing
    sent").
  - lcm walked *forward* past tool results at the tail boundary, which
    silently shrank the tail: a turn with two results kept four messages
    where keep_tail says six. Walking back to the assistant that carries
    the call keeps six and no orphan.

And the .meta sidecar is shared now: the core rewrote it with only the keys
it knew, so anything a plugin put there was gone on the next open. It
carries unknown lines through (extra[8][160]), which is what lets a plugin
mark a session in the core's own file.

Tests: tests/test_corecompact.c (10 checks, no plugin), the resume cases in
tests/test_session.c, and the tail-size check in tests/test_compactor.c.
Each was seen red on the old code before it was green on the new.
2026-11-21 21:25:51 +00:00
Konrad Lother 6b51f48335 telegram: own session tree and a status channel
The daemon writes its sessions under <state>/telegram, so a CLI -c in
the same directory never picks a gateway conversation and /new in the
chat never creates a file a CLI would resume.  Command scripts and
USER.txt stay in the base state dir; only the session files move.

Add --notify TEXT ("-" reads stdin) and telegram { status_chat = ID }
to send status and cron messages to the status chat.  The daemon
announces its start there, and the cron bridge can use the same path.
2026-11-20 09:59:40 +00:00
lotherk eba6f71a2d prompt: name the working directory's task scope; /effort sets the review depth
A session in ~/src/mikronix asked for "open tasks", called task_list without a
scope, got the makronix list and answered with it. The system prompt now names
the working directory as the default task scope (sp_task_scope_note), so the
model says "mikronix" instead of following the busiest scope. tasksd's
task_scopes/task_list descriptions now tell it to pass that scope (separate
repo, commit 4781f60).

/effort (off/low/medium/high/max or 0..12) sets X-Junction-Review-Rounds for
this process; unset keeps the router rule. The transport sends the header on
every request while set, so one session can run 0, 7 or 12 rounds without a
junction config change. /effort alone prints the current value.

test_engine: the prompt carries the scope paragraph; /effort maps to 12/2/0 and
rejects junk. make check: all tests passed. make check-asan: 41/41 clean.
2026-11-19 11:37:32 +00:00
lotherk 47d45bfd15 session: search only sessions that ran in this working directory
"What did we do last?" in a folder searched every session ever and wandered
off in another direction: the plugin walked the whole session directory while
only the prompt note was folder-scoped. Both tools now read the cwd from the
session's meta sidecar (sp_session_cwd, the same record the folder note uses)
and skip sessions from other folders -- and sessions that have no cwd record.

test_sessiontools creates a session in a second folder with the same needle:
with the filter disabled it shows up (red), with it the search and the list
stay in the folder, and even session=<id from elsewhere> answers "no message".

make check: all tests passed. make check-asan: all 41 test binaries clean.
2026-11-19 07:57:03 +00:00
lotherk 11d119be04 session: a plugin that reads earlier sessions, and a prompt that points at them
session_search walks the logs of earlier sessions in this folder newest first
(query, limit, days, session) and answers with date, session id, title and a
snippet around the match; session_list shows the sessions themselves. The
running session is left out -- that is context, and lcm's recall covers what
compaction dropped -- unless a call names it with session=.

The system prompt now carries two things. When the working directory has
earlier sessions, a paragraph says how many, the newest, and that
session_search/session_list read them, so the model looks before asking the
user something that was already answered. And the default prompt tells it to
use the mcp_* tools for tasks, memory, skills and knowledge bases actively, not
only when asked.

test_sessiontools drives both tools (hit, no hit, limit, days, explicit id,
list with the current session marked); test_engine checks the prompt paragraph
and the default text. make check: all tests passed.
make check-asan: all 41 test binaries clean.

The user's ~/.splinter/splinter.conf gained "plugin session { }" (backup:
splinter.conf.bak-session).
2026-11-19 07:40:49 +00:00
lotherk c11a6c7989 mcp: join the server threads and give the tools an owner
The MCP plugin's reconnect thread was detached: shutdown killed the child and
returned, so the thread could still be reading into its line buffer (up to
16 MiB) and could call sp_host_add_tool() into a host that was being freed -- a
use-after-free waiting to happen, and the reason three leaks were suppressed in
tests/asan.supp (read_line, register_tools, connect_server).

Each server now keeps its pthread_t, init creates it joinable, and shutdown
waits (bounded, 5 s) for every thread to return before joining it and freeing
its state. teardown() frees the line buffer for the HTTP transport too (it was
freed only for stdio) and closes the stdio pipes even when the child was
already reaped.

The registered tools leaked for a second reason: sp_registry_add copies the
struct, not the strings, and sp_registry_free freed only the arrays -- the
prefixed name, the description, the printed schema and the toolref of every MCP
tool were lost with the registry. struct sp_tool gets a dispose hook; the
registry calls it for each tool, and the MCP plugin frees what it allocated (the
default schema is strdup'd now, so ownership is uniform). Builtins and the
gateway's tools leave it NULL; every positional initializer got the new field.

tests/asan.supp is empty. make check-asan: all 39 test binaries clean.
make check: all tests passed.
2026-11-19 00:05:05 +00:00
lotherk 4cbd57d829 tree: lcm keeps the task, and the in-flight work it sits in
Everything that was uncommitted in the shared tree, in one commit because the
changes are interleaved across the same files (lcm, engine, frontend, locales).

lcm: a continuation prompt is not the task. After /resume the newest user
message is "Continue with the task ...", and pinning it kept the keystroke
while the question it continues was cut away -- measured: a resumed session
woke up with the prompt, one tool call and its error, and no task at all. The
pin now skips the harness's own continuation prompts, so the real question is
pinned again. test_compactor drives it: with the skip disabled the task is
lost (red), with it the task comes back after the summary (green).

engine: /self-check and the exact tool-argument parse are in a1794fb; this
commit carries the tests for them (a failed tool observation must appear in
the self-check prompt; mcp_parse_exact rejects two objects in one string) and
the i18n keys the new code uses: cmd.script.*, main.no_profile, tg.busy,
tg.interview.running, ui.agent_busy in all three catalogues.

The rest is the in-flight work from the shared session: engine/frontend,
plugins, telegram/a2a, and their tests.

make check: all tests passed; check_i18n ok, 204 keys in 3 catalogues.
2026-11-18 23:03:09 +00:00
lotherk 7f8493c949 ui: multiline prompt, shift+enter, mouse; cache plugin; judge headers
Prompt box
- The input wraps at the window width and grows from one to five rows;
  beyond five it keeps the line with the cursor visible and scrolls inside.
  The conversation and sidebar shrink instead of the prompt being cut.
- Shift+Enter inserts a newline. It accepts the CSI-u and xterm modifyOtherKeys
  sequences and Alt+Enter; modifyOtherKeys is enabled at start and disabled on
  exit/signal. Enter still sends.
- History entries are folded to one line so the line-based history file stays
  readable.
- Mouse wheel scrolls the transcript (3 rows) in the prompt and during a turn.

Cache plugin
- New plugins/cache/cache.so: sidebar block and /cache command with the
  provider prompt-cache hit rate (last and session), cumulative cached tokens,
  and the junction cache from X-Junction-Cache plus its /status cache object
  (entries, hits, misses, bytes, ttl, joined).
- sp_meter/agent/engine now carry cached_total; the UI fills it.
- plugin cache { } added to the user config.

Junction judge schedule
- The transport parses X-Junction-Judge-Next/-In/-Next-Step/Every/Target/
  Model/Cache from every chat response and publishes the last one on the host.
- The junction widget and /junction show "judge next in N ... via ... cache
  ..." when the provider sends it; no stale schedule after a plain model.
- X-Junction-Cache is parsed even when no judge headers are present.

Self plugin
- Human labels and units: memory, threads, open files, children, bytes read/
  written; "children" instead of "kids".

Errors
- An in-stream error event now reads "provider error: ..." instead of "sse:",
  because it is the provider/router talking, not the stream parser.

make check: all tests passed.
2026-11-18 14:17:36 +00:00
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 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 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 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 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 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 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 573ef61afc version: print the build time and revision, not just 0.1.0
The release number does not move, so two builds - the tree and the
installed binary - looked identical in --version.

make now generates src/backend/buildinfo.c from the objects it stamps and
links it into libsplinter. The stamp is only rewritten when one of those
objects is newer, so a no-op make keeps the old time instead of pretending
the binary was rebuilt. The git revision is included, with -dirty when the
working tree differs from HEAD.

    splinter 0.1.0 (built 2026-11-16 15:39:00 WET, 42c11f9)

buildinfo.c is a build artefact: gitignored and removed by make clean.
make check: all tests passed.
2026-11-16 15:39:10 +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
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 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
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 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
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 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 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
lotherkandClaude Opus 5.5 808039cd58 cli: the main transport falls back at the limit, too
cli_fallback = claude1, claude0 names cli delegates whose cmd and env=
take over when cli_cmd answers with its limit. The main command is
benched as "cli", a fallback under its own id, on the same bench the
delegation uses (sp_limit_parse, sp_cooldown_until, sp_cooldown_set are
now exported from libsplinter). The session key stays, so claude
resumes the same conversation under the next account. With everyone
benched the turn fails with the first reset, as WAIT_QUOTA ready_at=.

A fallback's env= goes through a 0600 file the shell sources, not a
command line. A delegate's child is benched under the delegate's id
(SPLINTER_CLI_ID), never as "cli".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 20:51:23 +00:00
lotherkandClaude Opus 5.5 75d8beeaa4 delegates and cli_env: hardcoded environment per cli program; swarm, provider, planner, scheduler, tmux
env=NAME=VALUE on a delegate line (repeatable) is set in the child right
before exec and beats what the parent exported, so two delegates can run
the same cli with two accounts. Remotely it goes in front as
`env 'NAME=VALUE'`, quoted like the rest. cli_env = NAME=VALUE does the
same for the main cli transport. A bad name is an error with the line.

Also in this commit, the work in progress from the tree: swarm and
provider state, the provider/scheduler/planner/tmux plugins, the ui test,
whose tmux session name is now per run so parallel runs do not collide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 19:15:48 +00:00
lotherkandClaude Opus 5.5 25a616a87f review fixes, third round: the gateway asks in its chat, approvals say what
Telegram gateway
- A tool call of the gateway's own turn that needed consent was either denied
  (a daemon has no approval stream) or, with ack channels set, waited for an
  "ok <id>" that only the blocked gateway could have read. It now asks in the
  chat the turn came from, keeps reading while it waits, resolves answers
  (also other processes' and 'splinter --ack'), ignores strangers and tells
  everything else to wait. The update offset is shared, so nothing is handled
  twice. New cfg flag approve_is_channel: such an approve is asked directly.
- send_message wrote its error through err, and half the callers pass NULL: the
  first refused message (too long, bad UTF-8) crashed the gateway. It also
  missed '"ok": true' by substring; the reply is parsed now.
- tests/test_gateway.sh drives the real daemon against a fake Bot API and a
  fake model (tests/fake_telegram.py), with "ok" and with "no". In make check;
  .gitignore no longer hides tests/test_*.sh.

Approvals
- A channel was told "Zustimmung <id>" and nothing else: a phone said yes to a
  number. The message now names the tool and its arguments (cut at 300 bytes)
  and how to answer, and goes to the channel as "$1", never parsed by sh.

Smaller
- ring: an exit that already streamed text is not retried on the next one
  (the operator saw a second answer after half of the first); the header now
  says what moves the ring - limits and providers that are down.
- cli: the program's stderr went over the curses screen and the error quoted
  stdout. stderr goes to a file and into the error; temp paths are quoted;
  the BODY_CAP no-op is gone. (That is the "kaputt" make check used to print.)
- memory: memory_key_env became an env var curl never reads, so no request had
  a key. It is "Authorization: Token <key>" now, on curl's stdin. Tested.
- docs/CONFIG.md: the real default path, and the seven keys it did not know
  (telegram_allow, memory_url, memory_key_env, skills_dir, env_delegates,
  exit, delegate) with the line formats, checked against the parser.
- The no-token message named a config key that does not exist.

Left as it is, on purpose: 'read' stays unrestricted (decision); the fsync per
session line stays (durability over latency).

make check: 26 test binaries and the gateway script, green, also under
ASan/UBSan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 06:13:09 +00:00
lotherkandClaude Opus 5.5 489c5da26a fixes from the review, second round: mcp client, kids rules, plugin life, ui
Each change has a test that fails against the code before it.

Also note: 8900d7f ("telegram: refuse to start without a token") swept in
work of this round that its message does not describe - an OLLAMA_KEY no longer
overwrites the key of the operator's last exit (config.c), parallel delegates
are killed and reaped after a timeout (delegate.c), lcm/cps never leave a tool
result without its call, cps keeps working past 256 messages, Telegram ids are
parsed as 64 bit, and 'run' also hides SPLINTER_OLLAMA_KEY_* and
SPLINTER_MCP_TOKEN.

MCP client (plugins/mcp)
- fgets into char[16384] split every longer reply into unparseable pieces; a
  big tools/list or file read never arrived. A reply sharing one write with a
  notification sat in stdio's buffer, invisible to poll(). Lines are now
  buffered on the fd (up to 16 MiB). An error is the top-level "error" member,
  not the text "error" anywhere in the line. test_mcpclient.

kids
- Rules were matched against the raw JSON, so "run ls*" never matched. They
  now see the command, path or url. A 'run' command that can chain, substitute
  or redirect is never whitelisted. The glob is linear instead of exponential.
  test_kids, which also covers the approval-command quoting and the domain
  checks from the first round.

Plugin life (src/plugin.c, ABI 2)
- An init() that failed kept what it had registered (tools, gate, widget
  threads); it is now rolled back. shutdown() was never called; the host calls
  it, newest plugin first, after the widget threads have stopped.
- A widget slot is filled before it is counted, and the count is read under the
  lock, so tick threads never see a half-made slot.
- SP_PLUGIN_ABI is 2: struct sp_gate grew block_turn while the ABI stayed 1.
  test_lifecycle, with tests/plugin_lifecycle.so.

UI
- Ctrl-C and Ctrl-D cancel under the lock and wake a turn waiting for approval
  (it waited forever); Ctrl-D cancelled nothing before the join.
- A steer the turn already took is not sent again as the next message.
- KEY_RESIZE re-cuts the windows; Ctrl-L repaints instead of sending the
  half-typed line; key codes above 255 are not typed into the input.
- Markdown attributes went to stdscr while the text went to ui_hist: bold and
  code never showed. They now build on the line's role colour.
  Checked in tmux: UTF-8 input, resize to 70x20, Ctrl-L, Ctrl-D, bold.

Telegram
- Replies are split on UTF-8 boundaries; a cut umlaut made Telegram refuse the
  chunk and the rest of the answer was lost.

Build
- Seven plugins linked with an undefined $(PLUGIN_LDFLAGS): no rpath, no LIBS.
  All eleven now carry $ORIGIN/../..; objects depend on the interface headers.

Seen, not changed: sp_session_append fsyncs every line; under disk load an
answer appears up to 15 s late. Not a deadlock, and the same before this round.

make check: 26 test binaries, green, also under ASan/UBSan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:50:33 +00:00
lotherkandClaude Opus 5.5 6fe30f4787 security: the authorization model holds where the model writes the input
A review found the tool classes - the core of the harness - bypassable in
several places where model output was pasted into a shell or trusted as an id.
Each fix below has a test that reproduces the original failure.

No shell for model data
- webfetch put the URL between '...' and ran it through popen: a quote in the
  URL ran any command, from a tool that needed no consent. curl is now exec'd
  with an argv, http(s) only, HTML stripped in C, stderr off the curses screen.
- webfetch is mutate: with read free, "read a key, fetch evil/?k=..." left the
  machine without anybody being asked. websearch stays read (fixed host).
- kids: the parent-approval command got the model's arguments inside '...'
  via system(); they are now "$1". The domain check reads the URL with the
  same parser as the tool (duplicate keys) and refuses user@host URLs.
- delegate: the two copies of the child argv are one (exec_delegate). The ssh
  path exec'd splinter with "ssh" as argv[0]; it now runs ssh and quotes every
  word for the remote shell. A single delegate to a host now really runs there.

Approvals (ack)
- The id was the pid: a late yes stayed on disk and approved the next request
  unseen. Ids are random, requests 0600 with O_EXCL, deleted when answered or
  expired; an answer is refused after expiry; the first answer wins (link(2)).
- An ack dir owned by someone else or writable by others is refused.
- --ack accepted every word but "no" as yes ("nein" approved). Now strict.
- The terminal thread blocked in fgets after a phone answer; it is stoppable.

Secrets
- API key and Telegram token were in curl's argv, readable via ps. src/curl.c
  passes URL and auth headers as a -K config on stdin (transport, telegram,
  tg-ask.sh; its dead eval fallback is gone).
- 'run' and task_start no longer inherit splinter's keys ("run env"). 'run' got
  its own process group, stdin /dev/null and SPLINTER_RUN_TIMEOUT (300 s).

MCP server
- Beyond 127.x it refuses to start without SPLINTER_MCP_TOKEN; connections
  must begin with "AUTH <token>". SIGPIPE ignored, idle connections closed.

Crashes
- task_kill sent kill(-0) - SIGTERM to splinter's own process group - because
  popen gave no pid. Tasks now have a pid and a process group; integer ids work.
- ui: a 3- or 4-byte UTF-8 character overflowed char[2] on every redraw
  (now sp_ui_ascii_char, tested); the scroll offset was taken from one buffer
  and applied to another, reading past its end.

Repo
- The test binaries are no longer tracked (.gitignore already said so).

make check: 23 test binaries, green, also under ASan/UBSan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:19:01 +00:00
Konrad 3c5cdaf53a splinter: delegations are tasks too, and the status line is alive
A delegate is work someone else does while we wait, so it belongs in the task
panel with its own clock. The tasks plugin now publishes sp_task_ops through the
host, and delegate.c opens an entry before the call and closes it with status and
rough token count after - 'who is still running' becomes a fact on screen instead
of a guess.

Measured status line, live during a turn:

  splinter 0.1.0  clock: 19:12:56  |  ctx 4.0k  |  12 tok/s  |
  4.0k in / 238 out  |  tasks 0/4          Delphinium 19178ms

Not yet observed: a delegate entry in the panel. Both test configs had no
reachable delegate (one endpoint dead, one with no defers at all), so the cycle
open -> close never ran against a real call. The wiring compiles and the task API
is exercised by task_start/task_list; the delegate half needs one live delegate to
prove.
2026-11-08 19:13:44 +00:00
Konrad 3f65dfdc4c splinter: a status line that plugins can write
New host API for it: sp_host_add_status() takes a named renderer, and
sp_host_status_text() joins the segments with '  |  '. The numbers a plugin shows
come from the harness through struct sp_meter - context used and window, session
tokens, cache hits, tokens per second, running tasks. A plugin that counted for
itself would drift from the harness within one turn.

plugins/status renders clock, ctx with a 24 column bar, cache, tok/s, tokens in and
out, cost and task count. Prices are configuration, not knowledge:

  SPLINTER_CTX_MAX=32768 SPLINTER_PRICE_IN=0.3 SPLINTER_PRICE_OUT=1.2

Without prices the cost segment says nothing instead of inventing a number.

Also fixed: the status.so recipe compiled kids.c, so the plugin that loaded was
the kid mode with a different name - the reason seven status registrations
produced an empty line.

Known open: the segments compose (probe: 'clock: 17:28:14  |  ctx 0/32.8k
[........................] 0%  |  0 in / 0 out  |  $0.0000') but the bar still
draws only the title - not yet isolated.
2026-11-08 17:29:01 +00:00
Konrad c0ec7bacd4 splinter: kid mode enforces the day, and the site speaks Portuguese
The daily budget was advisory: the gate refused tools and a system message asked
the model to close the day, but a chatty model answered anyway. So the core grew a
turn gate - a plugin can now refuse the whole turn before the model is called:

  Fuer heute ist Schluss: 60 von 30 Minuten sind verbraucht. Morgen geht es weiter.

That sentence comes from the plugin, not from a model that was asked to obey. No
model call, no tokens, no way around it by talking.

Also fixed: one-shot mode printed only a newline when the transport streamed
nothing (a turn blocked before the stream), so the answer vanished. It is printed
when no bytes were streamed.

Website: third language, index.pt.html, generated from the same source; the
language bar on all three pages links all three. check_i18n now sees 51 keys in
three catalogues.
2026-11-08 16:02:21 +00:00
Konrad f3174c0296 splinter: kid mode, and Portuguese (Brazil)
Kid mode plugin: a parent approves every action that changes something, a
whitelist lets the harmless ones through, and the model is told to stay
age-appropriate on every request (not once at the start, where it gets buried).

The core grew one hook for it: a gate. A plugin's gate sees tool, class and
arguments before the operator prompt and before the authorization class, and
answers allow, deny with a reason, or no opinion.

  allowed  -> the call runs, the operator is not asked
  denied   -> the model gets 'denied: <reason>' and cannot retry around it
  silence  -> the normal rules apply

	A whitelist entry is '<tool> <glob>' in ~/.splinter/kids/allow:
	run ls*
	read *

	Parents are reached through SPLINTER_KIDS_APPROVE_CMD, which gets the request
	as its argument and answers with its exit status. No channel means no
	mutating work at all - it fails closed, like the operator prompt it replaces.
	A timeout is a no.

	Measured: 'run' was denied with 'ein Erwachsener hat nicht zugestimmt
	(abgelehnt)', the parent channel recorded the request, whitelisted 'ls'
	went through.

	Daily budget: SPLINTER_KIDS_DAILY_MINUTES, counted per step, stored per day in
	~/.splinter/kids/usage, reset at midnight. When it is gone the gate refuses
	every tool including reads.

	pt_BR: a full catalogue (51 keys, 3 languages). Language detection now keeps
	the region - pt_BR and pt are different catalogues and a Brazilian child
	should not be handed European Portuguese - and falls back to the bare
	language before English.
2026-11-08 15:56:20 +00:00