bin/raider

filter: Statementstmt 100% 13 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 16 / 16 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Langertha/Raider/Hall/ACP/SubStream.pm ↑ Summary blib/lib/App/Raider.pm »
1 #!/usr/bin/env perl
2 # PODNAME: raider
3 # ABSTRACT: Autonomous CLI agent with filesystem and bash access
4  
5 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 25 our $VERSION = '0.503';
9  
10 25 ▶use Langertha::Raider::CLI::Main;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 25 binmode STDOUT, ':encoding(UTF-8)';
13 25 binmode STDIN, ':encoding(UTF-8)';
14  
15 25 exit Langertha::Raider::CLI::Main->new->run(@ARGV);
16  
17 __END__
18  
19 =pod
20  
21 =encoding UTF-8
22  
23 =head1 NAME
24  
25 raider - Autonomous CLI agent with filesystem and bash access
26  
27 =head1 VERSION
28  
29 version 0.503
30  
31 =head1 SYNOPSIS
32  
33 raider "Find all TODO comments in lib/ and summarize them"
34 raider -e openai -m gpt-4o "Run the test suite and fix any trivial failures"
35 raider -i -r ~/dev/myproject
36 raider --perl --pack testing-fu "Run prove -l t and explain failures"
37 raider --json "Summarize README.md" > result.json
38 raider --stream-json "Run the tests" | jq -c 'select(.type == "tool.call")'
39 raider config explain -m gpt-4o
40 raider config migrate --dry-run
41 raider session list
42 raider --continue "Now fix the first one"
43 raider provider inspect provider.example --json
44 raider --provider provider.example -m example-model -k "$KEY" "Summarize README.md"
45 raider hall start --acp-port 38421
46 raider acp prompt 127.0.0.1:38421 --raider bjorn "Summarize status"
47  
48 =head1 DESCRIPTION
49  
50 F<raider> is the command line of L<Langertha::Raider::CLI>: it runs
51 L<Langertha::Raider::CLI::Main>, which parses the options below and builds
52 a L<Langertha::Raider::CLI> for the working directory. That wires an LLM engine
53 (via L<Langertha>) to the file tools, C<bash> (L<MCP::Run::Bash>) and the web tools,
54 then runs the L<Langertha::Raider> multi-turn agent loop on your prompt.
55 Optional profile, pack, and Perl-native tool flags let the same CLI load
56 project agent instructions, persona/power bundles, and C<perl_eval> /
57 C<perl_check> / C<perl_cpanm> tools.
58  
59 Settings of a project live in its config file: F<.raider/config.yml> in the
60 working directory, or else the legacy F<.raider.yml> there. Both take the
61 same keys; where this page names F<.raider.yml>, the file in use is meant.
62 When both exist, only F<.raider/config.yml> is read: F<raider> warns on
63 standard error that it ignores F<.raider.yml>, and C<config explain> names
64 the file in use and the ignored one. What F<raider> saves (C</model>,
65 C<--claude>, C<--openai>, C<--skills>) goes to the file in use, and to
66 F<.raider.yml> when there is none.
67  
68 Under the project file lies the home file F<~/.raider/config.yml>, with
69 the same keys: built-in defaults, then the home file, then the project
70 file, then the command line. The project replaces a home value, except
71 that C<skills> and C<no_detect> add up and C<detect:> rules are replaced
72 per pack. F<raider> never writes the home file. Run in the home directory
73 itself, F<~/.raider/config.yml> is the project file and is read once. A
74 home file that does not parse stops F<raider> like a broken project file.
75  
76 C<project_tools> in F<~/.raider/config.yml> maps a workspace selector
77 (C<*>, a path glob starting with C</> or C<~/>, or a workspace name) to
78 the home tools a project gets. Only the home file grants: in a project file
79 it is ignored, and C<config explain> says so. For now C<config explain>
80 only shows which selectors match the project and which tools they grant;
81 nothing is mounted from it yet, and workspace names never match. An
82 invalid C<project_tools> stops F<raider> with exit status 3.
83  
84 The project instructions follow the same rule: F<.raider/instructions.md>
85 in the working directory, or else the legacy F<.raider.md> there, is added
86 to the default persona. Where this page names F<.raider.md>, the file in
87 use is meant. When both exist, only F<.raider/instructions.md> is read,
88 F<raider> warns that it ignores F<.raider.md>, and C<config explain> names
89 the ignored file under C<instructions:>. The prompt-builder (C</prompt>)
90 writes the file in use, and F<.raider.md> when there is none.
91  
92 C<raider config migrate [--dry-run] [-r DIR]> moves the legacy files of a
93 project to the new layout: F<.raider.yml> to F<.raider/config.yml> and
94 F<.raider.md> to F<.raider/instructions.md>, each only when it exists. It
95 first shows what it does -- per file the new file, the backup and whether
96 the content changes -- and with C<--dry-run> stops there. Each new file is
97 written atomically with the legacy file's permissions, then the legacy
98 file is renamed to F<.raider.yml.bak> or F<.raider.md.bak>, so afterwards
99 the same settings are read from the new files; F<.raider/> is created with
100 its F<.gitignore>. A step that fails leaves its legacy file in use. An
101 C<api_key> (top level, C<default:> or an engine section) is not copied
102 into F<.raider/config.yml>, which is meant to be shared: it is reported
103 with where it was, never printed, and belongs in F<~/.raider/config.yml>
104 or the engine's C<*_API_KEY> variable; its lines are dropped (comments
105 stay), and where that would change the meaning of the file the file is
106 rewritten from its parsed content, which drops comments and says so.
107 Nothing is merged: when a new file or a backup already exists, when
108 F<.raider> is no directory, or in the home directory itself (where
109 F<.raider/config.yml> is the home file), nothing is written and the exit
110 status is 1. Only C<config migrate> in front of the options is the
111 subcommand. Its report is for humans only; there is no C<--json> form.
112  
113 Interactive mode (C<-i>) opens a REPL with conversation history retained
114 across turns. With L<Term::ReadLine::Gnu> installed, line editing and
115 persistent input history (F<~/.raider_history>) are enabled automatically —
116 including across Ctrl-C interrupts. Slash commands available in the REPL:
117 C</help>, C</clear>, C</metrics>, C</stats>, C</reload>, C</prompt>,
118 C</skill>, C</skill-claude>, C</config>, C</model>, C</packs>, C</pack>,
119 C</quit>.
120  
121 Two more line prefixes run shell commands, with C<$SHELL -c> (C</bin/sh>
122 without C<SHELL>) in the root (C<--root>); Ctrl-C while one runs ends the
123 command, not F<raider>. C<!CMD> runs C<CMD> on the terminal (C<less> and
124 C<vim> work), prints a non-zero exit status, and sends nothing to the model
125 and records nothing in the session. C<?CMD> runs C<CMD> with its output
126 shown as it comes and captured (standard input is F</dev/null>), then sends
127 the command, its exit status and its output -- standard output and
128 standard error, cut to its first and last 10000 characters when longer
129 than 20000 -- to the model as the next prompt, recorded in the session like
130 any other. A C<?CMD> ended by Ctrl-C sends nothing. A line that is only
131 C<!> or C<?> is a prompt.
132  
133 Subcommands are dispatched before normal raider startup: C<raider hall ...>
134 manages a Raider Hall daemon, and C<raider acp ...> runs the bundled ACP
135 client. C<raider config explain [options]> takes the normal options and
136 prints every effective setting with its source -- a command-line flag, a
137 layer of the config file, an environment variable or the built-in default --
138 without writing the config file or contacting a model; C</config> prints the
139 same inside the REPL. The options may also come first
140 (C<raider -e openai config explain>); there only the exact words
141 C<config explain> are the subcommand, any other prompt starting with
142 C<config> is sent as a prompt. C<raider provider inspect HOST> fetches,
143 validates and shows a provider's manifest, and C<raider --provider HOST>
144 runs on the endpoint it declares; see L</PROVIDERS>.
145  
146 With C<--json>, C<--msgpack> or C<--yaml>, F<raider> prints one document
147 describing the run instead of the human-oriented output, which is useful
148 for scripting; C<--stream-json>, C<--stream-msgpack> and C<--stream-yaml>
149 follow the run as it happens. See L</MACHINE OUTPUT>.
150  
151 When standard input is not a terminal, the REPL (C<-i>) reads its lines
152 from it and ends at its end.
153  
154 =head1 TOOLS
155  
156 The model gets one tool set per run, and the tool list in its prompt is
157 generated from exactly the tools the engine is offered:
158  
159 =over
160  
161 =item * C<list_files>, C<read_file>, C<write_file>, C<edit_file>
162 (L<Langertha::Raider::FileTools>), confined to C<-r>.
163  
164 =item * C<bash> (L<MCP::Run::Bash>), a real shell started in C<-r>,
165 120 seconds per command by default. It is not confined to C<-r>.
166  
167 =item * C<web_search>, C<web_fetch> (L<Langertha::Raider::WebTools>).
168  
169 =item * C<perl_eval>, C<perl_check>, C<perl_cpanm>
170 (L<Langertha::Raider::PerlTools>) when granted: by C<--perl>, by C<perl:>
171 in F<.raider.yml> (C<perl: false> denies them), or else when an active pack
172 requests them -- the bundled C<perl> pack, detected in a Perl workspace.
173 Switching such a pack with C</pack> or re-detecting it with C</reload>
174 mounts or unmounts them for the next raid.
175  
176 =item * C<telegram_reply>, C<hall_status>, C<hall_spawn>
177 (L<Langertha::Raider::HallTools>) only for a raider a Hall started (see
178 L</RAIDER_HALL_SOCKET>).
179  
180 =back
181  
182 C<raider config explain> shows whether the Perl tools are mounted and why;
183 C<--export-skill> writes the same tool list as a table.
184  
185 =head1 OPTIONS
186  
187 =head2 -e, --engine NAME
188  
189 The engine: C<anthropic>, C<openai>, C<deepseek>, C<groq>, C<mistral>,
190 C<gemini>, C<minimax>, C<cerebras>, C<openrouter> or C<ollama>. Without
191 it, C<-o engine=>, then C<engine:> in F<.raider.yml>, then the first API key
192 set in the environment (C<anthropic>, C<openai>, C<deepseek>, C<groq>,
193 C<mistral>, C<gemini>, in that order; see L</ENVIRONMENT>) decide, else
194 C<anthropic>.
195  
196 =head2 -m, --model NAME
197  
198 The model. Without it, C<-o model=>, then C<model:> in F<.raider.yml>, then
199 a cheap per-engine default (C<claude-haiku-4-5>, C<gpt-4o-mini>, ...), else
200 the engine's own default. C<openrouter> needs one.
201  
202 =head2 -k, --api-key KEY
203  
204 The API key, over C<api_key:> in F<.raider.yml> and the engine's
205 environment variable. With C<--provider> the only source of the key,
206 together with C<-o api_key=>.
207  
208 =head2 --provider HOST[:PORT] | https://HOST[:PORT]
209  
210 Runs on the model endpoint a provider's manifest declares, for this one
211 run; see L</Using a provider>. Not with C<-e>, C<-o engine=>, C<-o url=>
212 or C<config explain>.
213  
214 =head2 --allow-internal
215  
216 With C<--provider> (and C<provider inspect>): releases loopback, private,
217 link-local and reserved provider addresses; see L</PROVIDERS>.
218  
219 =head2 -o, --option KEY=VALUE
220  
221 An engine attribute (repeatable), e.g. C<-o temperature=0.2 -o
222 response_size=4096>, merged over F<.raider.yml>; the command line wins.
223 Integers, decimals and C<true> / C<false> become numbers. raider's own
224 F<.raider.yml> keys (C<engine>, C<perl>, C<packs=a,b>, C<skills=a,b>,
225 C<detect>, C<no_detect=a,b>, C<preferred_lib_target>) configure raider
226 instead and never reach the engine.
227  
228 =head2 -r, --root DIR
229  
230 The working directory, default the current one. The file tools are
231 confined to it, C<bash> starts in it, and F<.raider/config.yml> (or
232 F<.raider.yml>), F<.raider/instructions.md> (or F<.raider.md>) and
233 F<.raider/> are read from it.
234  
235 =head2 -M, --mission TEXT
236  
237 The instructions: replaces the default persona and F<.raider.md> for this
238 run. Skills, packs and the tool list still apply.
239  
240 =head2 --bare
241  
242 An isolated context: no F<.raider.md>, no skills, no C<packs:>, no default
243 packs, no detection. C<--pack NAME> and C</pack NAME> still work.
244  
245 =head2 -i, --interactive
246  
247 The REPL. It is the default when standard input is a terminal and no prompt
248 is given; C<-i> also forces it otherwise.
249  
250 =head2 --json[=N], --msgpack[=N], --yaml[=N]
251  
252 Print one document for the run, see L</MACHINE OUTPUT>.
253  
254 =head2 --stream-json[=N], --stream-msgpack[=N], --stream-yaml[=N]
255  
256 Print the run as events while it happens, ending with the document; see
257 L</Streams>.
258  
259 =head2 --no-session
260  
261 Record nothing; see L</SESSIONS>.
262  
263 =head2 --session ID
264  
265 Continue session C<ID>: its conversation is replayed and the run (or the
266 REPL) is recorded in it.
267  
268 =head2 --continue
269  
270 The same with the newest session of the project.
271  
272 =head2 --max-iterations N
273  
274 Hard cap on tool rounds per raid. Default 10000, effectively unlimited.
275  
276 =head2 --no-color
277  
278 No ANSI colors, as with C<ANSI_COLORS_DISABLED>.
279  
280 =head2 --trace, --no-trace
281  
282 Show or hide the live progress of tool calls. On by default when standard
283 output is a terminal; off with a machine output flag, where C<--trace>
284 sends it to standard error.
285  
286 =head2 --perl
287  
288 Mount the Perl tools (C<perl_eval>, C<perl_check>, C<perl_cpanm>), see
289 L</TOOLS>.
290  
291 =head2 --pack NAME
292  
293 Enable a pack (repeatable). Given at all, the listed packs replace
294 C<packs:> of F<.raider.yml> and the default packs; detection still adds.
295  
296 =head2 --no-pack NAME
297  
298 Switch a pack off (repeatable), also a default or detected one.
299  
300 =head2 --no-detect, --detect
301  
302 Switch pack detection off, or on over C<detect: false> in F<.raider.yml>.
303  
304 =head2 --claude
305  
306 Load F<CLAUDE.md> and F<.claude/skills/*/SKILL.md> as skills. Saved to
307 C<skills:> in F<.raider.yml> on first use.
308  
309 =head2 --openai, --codex
310  
311 Load F<AGENTS.md>. Saved like C<--claude>.
312  
313 =head2 --skills DIR
314  
315 Load the F<*.md> files in C<DIR> as skills (repeatable). Saved like
316 C<--claude>.
317  
318 =head2 --customize-prompt
319  
320 Start the REPL with the prompt-builder, which writes F<.raider.md> with
321 you (C</prompt> in the REPL).
322  
323 =head2 --export-skill [PATH]
324  
325 Write a plain-markdown "how to use raider" document for the current
326 configuration (default F<RAIDER-SKILL.md> in C<-r>) and exit.
327  
328 =head2 --export-claude-skill [PATH]
329  
330 Write the same as a Claude Code F<SKILL.md> with frontmatter (default
331 F<.claude/skills/raider/SKILL.md> in C<-r>) and exit.
332  
333 =head2 --version
334  
335 Print the version of raider (L<Langertha::Raider>) and of L<Langertha>
336 core on one line, C<raider VERSION (Langertha VERSION)>, and exit.
337  
338 =head2 -h, --help
339  
340 Print the option summary and exit.
341  
342 =head1 MACHINE OUTPUT
343  
344 C<--json>, C<--msgpack> and C<--yaml> print one document for the run, once,
345 when it has ended. C<--stream-json>, C<--stream-msgpack> and
346 C<--stream-yaml> print events while the run happens, the last of which
347 carries that same document (see L</Streams>). Nothing else goes to standard
348 output: the live trace is off unless C<--trace> asks for it, and then goes
349 to standard error like every diagnostic. The six flags exclude each other;
350 giving two is a usage error. A usage or configuration error (exit status
351 C<2> or C<3>) prints no document and no events, only its message on
352 standard error.
353  
354 The flags write the same model in three encodings:
355  
356 =over
357  
358 =item C<--json> -- a pretty-printed JSON object with sorted keys, UTF-8.
359 C<--stream-json> writes JSON Lines: one compact object per event and line.
360  
361 =item C<--msgpack> -- one MessagePack map; text is written as UTF-8 C<str>,
362 never C<bin>. Standard output is binary. C<--stream-msgpack> writes one map
363 per event, back to back (MessagePack objects delimit themselves).
364  
365 =item C<--yaml> -- one YAML document, starting with C<--->, UTF-8.
366 C<--stream-yaml> writes one YAML document per event, each starting with
367 C<--->.
368  
369 =back
370  
371 Every field and type is the same in all three encodings.
372  
373 =head2 The document
374  
375 A run that completed:
376  
377 {
378 "elapsed" : 2.731,
379 "metrics" : { "iterations" : 2, "raids" : 1, "time_ms" : 2710.4, "tool_calls" : 1 },
380 "response" : "The README describes ...",
381 "status" : "completed",
382 "version" : 1
383 }
384  
385 A run that failed:
386  
387 { "elapsed" : 0.42, "error" : "...", "status" : "failed", "version" : 1 }
388  
389 A run cancelled by C<SIGINT> (Ctrl-C; see L</EXIT STATUS>):
390  
391 { "elapsed" : 3.912, "status" : "cancelled", "version" : 1 }
392  
393 A run stopped by C<SIGTERM>, by a second C<SIGINT> while it is being
394 cancelled, or by either signal before it started:
395  
396 { "elapsed" : 5.107, "signal" : "TERM", "status" : "interrupted", "version" : 1 }
397  
398 =over
399  
400 =item C<version> -- integer, the format version (see below).
401  
402 =item C<status> -- how the run ended: C<completed>, C<failed>,
403 C<cancelled> or C<interrupted>. These are the run states of the redesign
404 (ADR 0009) that end a run and that the CLI can produce today; C<refused>
405 is reserved for when it can.
406  
407 =item C<response> -- the agent's final answer (C<completed> only).
408  
409 =item C<metrics> -- the raider's cumulative metrics: C<raids>,
410 C<iterations>, C<tool_calls>, C<time_ms> (C<completed> only).
411  
412 =item C<error> -- the error message (C<failed> only).
413  
414 =item C<signal> -- the signal that stopped the run, C<INT> or C<TERM>
415 (C<interrupted> only).
416  
417 =item C<elapsed> -- seconds the run took, to the millisecond.
418  
419 =item C<session> -- the session the run is recorded in (see
420 L</SESSIONS>): C<id> and C<path> of its journal. Missing with
421 C<--no-session> and for a signal during startup.
422  
423 =back
424  
425 =head2 Streams
426  
427 A stream is a sequence of events, each flushed as soon as it happens. Every
428 event has these fields:
429  
430 =over
431  
432 =item C<version> -- the format version, as in the document.
433  
434 =item C<type> -- what happened (below).
435  
436 =item C<seq> -- 1, 2, 3, ... within the run.
437  
438 =item C<time> -- when, in epoch seconds with fractions.
439  
440 =back
441  
442 The types of version 1, with the fields each adds:
443  
444 =over
445  
446 =item C<run.started> -- C<engine> and, when there is one, C<model>. A run
447 interrupted during startup (reading the configuration or the prompt) has
448 none: its stream is the C<interrupted> state change and C<run.finished>.
449  
450 =item C<run.state> -- C<state>: C<running> when the run starts, then the
451 C<status> it ends with (see L</The document>).
452  
453 =item C<tool.call> -- C<name> and C<arguments> of a tool call, before it
454 runs; C<call>, its id within the run (C<c1>, C<c2>, ...); C<status>,
455 C<dispatched>.
456  
457 =item C<tool.result> -- C<call> and C<name> of the call; C<status>
458 (C<succeeded>, C<failed> when the tool reported an error, or C<cancelled>
459 for a call a cancelled run cut off); C<ok> (the
460 same as a boolean); C<size>, the length of the result text in characters;
461 C<content>, its first 1000 characters; and C<truncated> (a boolean, true
462 when C<content> was cut). The cut limits how much of a tool's output
463 reaches the stream, but it is no filter: a secret in a tool's arguments or
464 output can still show up.
465  
466 =item C<message> -- a finished assistant message: C<role> (C<assistant>)
467 and C<content>. Version 1 reports the final answer of the run.
468  
469 =item C<run.finished> -- always the last event, also when the run failed.
470 Its fields are exactly the document of L</The document>; a consumer that
471 only wants the result reads the last event.
472  
473 =back
474  
475 A run that calls one tool, as C<--stream-json>:
476  
477 {"engine":"openai","model":"gpt-4o-mini","seq":1,"time":1790000000.1,"type":"run.started","version":1}
478 {"seq":2,"state":"running","time":1790000000.1,"type":"run.state","version":1}
479 {"arguments":{"command":"ls"},"name":"bash","seq":3,"time":1790000001.2,"type":"tool.call","version":1}
480 {"content":"...","name":"bash","ok":true,"seq":4,"size":42,"time":1790000001.3,"truncated":false,"type":"tool.result","version":1}
481 {"content":"There are ...","role":"assistant","seq":5,"time":1790000002.4,"type":"message","version":1}
482 {"seq":6,"state":"completed","time":1790000002.4,"type":"run.state","version":1}
483 {"elapsed":2.312,"metrics":{...},"response":"There are ...","seq":7,"status":"completed","time":1790000002.4,"type":"run.finished","version":1}
484  
485 Token deltas are not part of version 1. New event types may appear within a
486 version, so a consumer must skip types it does not know.
487  
488 =head2 Versions
489  
490 C<--json=N> (C<--msgpack=N>, C<--yaml=N>, and the C<--stream-*> flags) asks for format version C<N>; the
491 version belongs to the model, so it means the same in every encoding and
492 for documents and streams alike. The
493 only version is C<1>, which is also what the plain flags write; any other
494 C<N> is a usage error. Only the C<=N> form carries a version -- in
495 C<raider --json 2 ...> the C<2> is part of the prompt.
496  
497 Within a version, fields are only ever added, never renamed, removed or
498 changed in meaning, so a consumer must ignore fields it does not know. A
499 breaking change is a new version, chosen with C<--json=2>; the plain flag
500 stays on the old version for at least one release after the new one ships.
501  
502 =head1 SESSIONS
503  
504 Every run is recorded in a session journal (ADR 0015):
505 F<.raider/sessions/E<lt>idE<gt>.jsonl> under the working directory
506 (C<-r>), one JSON object per line. A one-shot run starts a new session and
507 names it on standard error (with a machine output flag, in the document's
508 C<session> instead); the REPL starts one with its first prompt and records
509 every prompt of it there. C<--no-session> records nothing.
510  
511 Creating F<.raider/> also writes F<.raider/.gitignore> excluding
512 C<sessions/> and C<lib/>, unless that file exists: a journal holds the
513 whole output of every tool, so it is not committed by default. API keys
514 never enter it.
515  
516 A run is recorded as C<run.started>, the input as C<message>, every
517 C<tool.call> and C<tool.result> (with the whole result text, where the
518 stream cuts it), the answer as C<message>, and C<run.finished> with how it
519 ended -- also when it failed or was interrupted. A C</clear> in the REPL
520 is recorded as C<history.cleared>. While a raider writes a
521 session it holds a lock on it; a second writer fails at once instead of
522 waiting. A journal that cannot be written in the middle of a run (a full
523 disk) is a warning on standard error; the run goes on.
524  
525 Wherever a command takes a session C<ID>, a shorter form names it too: a
526 unique start of the id (C<20260925-08>) or its four hex digits at the end
527 (C<3f2a>). A form that fits more than one session is refused with the
528 candidates listed.
529  
530 raider session list # the project's sessions, newest first
531 raider session show ID # one session, event by event
532 raider session show ID --json # the whole journal as one document
533 raider session resume ID # the REPL, continuing session ID
534 raider --session ID "and now ..." # one more run in session ID
535 raider --continue "and now ..." # the same in the newest session
536 raider -i --continue # the REPL on the newest session
537 raider session fork ID # a new session with ID's history
538 raider session rm ID # delete session ID
539  
540 C<session list> shows id, number of runs, the state of the last run and
541 the first prompt of each session; C<session show> prints every event, then
542 what the crash rules found. Both read without the lock, take C<-r> for the
543 project and a document format (C<--json>, C<--msgpack>, C<--yaml>), as do
544 C<session fork> and C<session rm>. As for
545 C<config explain>, the options may come first; there only
546 C<session list> and C<session show|resume|fork|rm> followed by a session id
547 are the subcommand, any other prompt starting with C<session> is sent as a
548 prompt.
549  
550 C<session fork ID> starts a new session in the same project whose
551 C<session.created> names the original in C<forked_from>, and copies what a
552 resume would replay as the conversation into it, as C<message> events
553 outside any run. The original is only read, not locked or changed; the
554 fork has its own journal from then on and is continued like any session
555 (C<session resume>, C<--session>). C<session rm ID> deletes the journal
556 and its lock file; it takes the lock first, so a session another raider
557 has open is refused with exit status C<4>. Raider never deletes a session
558 on its own.
559  
560 Continuing a session (C<--session ID>, C<--continue>, C<session resume>)
561 takes its lock, replays the conversation -- the input and answer of every
562 run that got an answer, and all recorded events into the full session
563 history; after a C<history.cleared> only what came later -- and records
564 the new runs in the same journal. Nothing recorded
565 is executed again. It reports what it found on standard error (in the REPL,
566 under the banner): lines that could not be read, runs that never ended
567 (they count as C<interrupted>), and tool calls without a result, whose
568 outcome is C<unknown>. The context (F<.raider.md>, packs, configuration) is
569 built fresh, not replayed. A session another raider has open ends F<raider>
570 with exit status C<4>.
571  
572 =head1 PROVIDERS
573  
574 raider provider inspect HOST[:PORT] | https://HOST[:PORT] [--json] [--allow-internal]
575  
576 fetches C<https://HOST[:PORT]/.well-known/langertha.json>, the provider
577 manifest of ADR 0007, validates it with L<Langertha::Manifest> and shows
578 what it declares: the provider id, the issuer, every endpoint (id,
579 dialect, base URL, auth reference), every auth entry (id, type) and every
580 model (id, endpoint, the capabilities it claims). Warnings follow for what
581 this raider cannot use -- an endpoint dialect it has no adapter for, an
582 auth type it cannot supply, a capability name Langertha does not know
583 (treated as absent) -- and for an issuer that is not the origin the
584 manifest came from or an endpoint on plain C<http> or an internal address.
585 C<extensions> are shown as inert: kept as published, never interpreted,
586 loaded or run. A manifest with a command-, code-, secret- or prompt-shaped
587 field (C<command>, C<exec>, C<api_key>, C<system_prompt>, ...), an unknown
588 field or another schema version is not valid.
589  
590 Inspecting stores nothing, binds no credential and trusts nothing: the
591 manifest states what the provider claims. The fetch sends no API key, no
592 C<Authorization> header and no cookie, and is bounded:
593  
594 =over
595  
596 =item * C<https> only; a target with userinfo, a query, a fragment or
597 another path than the well-known one is a usage error.
598  
599 =item * at most 1 MiB of body, 10 seconds from resolving the host to the
600 last byte, and 3 redirects, each within the origin (scheme, host and
601 port). A redirect to another origin is not followed; it is reported with
602 its target and the manifest counts as C<refused>.
603  
604 =item * the host is resolved once and every address it resolves to is
605 checked; the request goes to a checked address, never to a second lookup
606 of the name, while TLS still verifies the certificate against the name.
607 Loopback, private (RFC 1918, shared address space, IPv6 unique local),
608 link-local and reserved addresses are refused, unless C<--allow-internal>
609 releases them. Cloud metadata addresses (C<169.254.169.254>,
610 C<fd00:ec2::254>, ...), the unspecified address, multicast and
611 C<240.0.0.0/4> are refused always. A host with one refused address among
612 its addresses is refused.
613  
614 =back
615  
616 C<--allow-internal> releases loopback, private, link-local and reserved
617 target addresses for this one inspection -- for a knarr or skeid you
618 deliberately run on an internal address. Nothing remembers it.
619  
620 =head2 Using a provider
621  
622 raider --provider HOST[:PORT] | https://HOST[:PORT] [-m MODEL] [-k KEY] [--allow-internal] [options] [prompt...]
623  
624 fetches and validates the manifest as C<provider inspect> does (same
625 limits and address rules) and runs on the endpoint of one of its models:
626 one-shot, machine output and the REPL work as with C<-e>. Nothing is
627 stored and nothing is remembered: naming the host on the command line is
628 the whole release, as with C<-o url=>. C<raider provider add> with a
629 stored alias and credential is not there yet. The rules are provisional:
630  
631 =over
632  
633 =item * B<The model.> C<-m> (or C<-o model=>) must be a model id of the
634 manifest. Without it the manifest must list exactly one model id;
635 several are a usage error that lists them. C<model:> in F<.raider.yml>
636 does not apply. A model listed on several endpoints runs on the one whose
637 dialect raider has an adapter for; with more than one such endpoint raider
638 does not choose and the run is refused.
639  
640 =item * B<The engine> follows from the endpoint's dialect:
641 C<openai-chat> runs as C<openai>, C<anthropic> as C<anthropic>, C<gemini>
642 as C<gemini>, C<ollama> as C<ollama> (native API), C<responses>,
643 C<perplexity-agent>, C<anthropic-compat> and C<aki> on their own
644 Langertha engines -- C<anthropic-compat> without native structured output,
645 through a synthetic tool and a forced tool choice instead (ADR 0007). The
646 engine's C<url> is the endpoint's C<base_url>, whatever F<.raider.yml>
647 says; the other engine options of F<.raider.yml> and C<-o> apply as with
648 C<-e>. A dialect this raider has no adapter for is an error, and so is
649 C<lmstudio>: Langertha's native LM Studio engine has no tool calling.
650  
651 =item * B<The key> comes only from C<-k> or C<-o api_key=>. Neither
652 C<api_key:> in F<.raider.yml> nor any environment variable is used: a key
653 for another provider never reaches this one. An endpoint with an auth
654 reference needs a key (a usage error without one); an auth type other than
655 C<api_key> is an error. An endpoint without auth gets no key.
656  
657 =item * B<The origin.> The endpoint's C<base_url> must be C<https> and of
658 the same origin (scheme, host, port) as the manifest; anything else is
659 refused, so the key goes nowhere but the origin named on the command line.
660 The endpoint's host is resolved and checked again before the run, under
661 the rules of C<provider inspect> (C<--allow-internal> releases it the same
662 way). The engine then connects to the first of the checked addresses,
663 never to a new lookup of the name (TLS still verifies the certificate
664 against the host name), so a DNS answer that changes after the check
665 cannot send the key elsewhere. A redirect to another host is never
666 followed; the model requests are POSTs, which are not redirected at all,
667 and the engine's synchronous requests (the REPL's C</model>) follow no
668 redirect.
669  
670 =item * A model that does not declare C<tools_native> is a warning on
671 stderr, not an error: raider works through tool calls.
672  
673 =back
674  
675 Failures are reported on stderr before anything runs, without a machine
676 document: a usage error exits with C<2>, a provider that cannot be used as
677 it is (refused, not fetched, not valid, an unknown dialect or auth type)
678 with C<1>.
679  
680 =head2 The provider document
681  
682 C<--json>, C<--msgpack> and C<--yaml> write one document (no stream):
683  
684 {
685 "address" : "93.184.216.34",
686 "elapsed" : 0.214,
687 "final_url" : "https://provider.example/.well-known/langertha.json",
688 "manifest" : { "schema_version" : 1, "kind" : "langertha-provider", ... },
689 "notes" : [],
690 "redirects" : [],
691 "status" : "completed",
692 "url" : "https://provider.example/.well-known/langertha.json",
693 "version" : 1,
694 "warnings" : []
695 }
696  
697 C<status> is C<completed> for a valid manifest, C<refused> for a target
698 address or redirect the rules above do not allow, and C<failed> for
699 anything else: the network, TLS, an HTTP status, a limit, invalid JSON or
700 an invalid manifest. C<manifest> is the validated manifest as
701 L<Langertha::Manifest/to_hash> writes it; C<warnings> and C<notes> are
702 one sentence each; C<url> is the manifest URL, C<final_url> the one the
703 body came from after C<redirects>, C<address> the address connected to.
704 C<refused> and C<failed> carry C<error> instead of C<manifest>, and a
705 redirect that was not followed its target in C<location>. The version
706 and compatibility rules are those of L</Versions>.
707  
708 =head1 EXIT STATUS
709  
710 =over
711  
712 =item C<0> -- success, including C<--help>, C<--version>, the exports, C<config explain>,
713 C<config migrate> (also with nothing to migrate, and C<--dry-run>), C<session list>, C<session show>, C<session fork>, C<session rm>,
714 C<provider inspect> of a valid manifest and leaving the REPL.
715  
716 =item C<1> -- the run failed: the engine, a tool or the network raised an
717 error. With a machine output flag, the document says C<failed>. For
718 C<config migrate>: the migration was refused, also with C<--dry-run>, or
719 a step failed. For C<provider inspect>: the manifest was refused, could not be fetched or is
720 not valid (the document says C<refused> or C<failed>). For C<--provider>
721 also: its endpoint cannot be used (another origin, not C<https>, a refused
722 address, a dialect or auth type this raider has no adapter for, no
723 models, a model on several endpoints); see L</Using a provider>.
724  
725 =item C<2> -- usage error: unknown option, a C<-o> that is not
726 C<KEY=VALUE>, an unknown C<config> subcommand, no prompt, more than one
727 machine output flag, a machine output flag with C<-i>, or an unknown format
728 version; for C<config migrate> a word after it or a machine output flag;
729 for C<provider inspect> also no target or more than one, a
730 target that is no host or C<https> origin, or a C<--stream-*> flag; for
731 C<--provider> a target that is none, C<-e>, C<-o engine=>, C<-o url=> or
732 C<config explain> with it, a model the manifest does not list, no C<-m>
733 where it lists several, or no C<-k> where the endpoint needs a key; and
734 C<--allow-internal> without C<--provider>.
735  
736 =item C<3> -- configuration error: the config file (project or home; for
737 C<config migrate> the F<.raider.yml> to migrate) cannot be read, the
738 engine is unknown, or a pack detection rule is invalid.
739  
740 =item C<4> -- the session to continue (C<--session>, C<--continue>,
741 C<session resume>) or to remove (C<session rm>) is in use by another
742 raider. A usage error (C<2>) is also an unknown or ambiguous session, a
743 C<--session> that is no session id, C<--continue> without any session, or
744 more than one of C<--session>, C<--continue> and C<--no-session>.
745  
746 =item C<130>, C<143> -- a one-shot run was cancelled by C<SIGINT> or
747 interrupted by C<SIGTERM>. On C<SIGINT> (Ctrl-C) F<raider> cancels the run:
748 it ends the tool commands still running, abandons a model request in
749 flight, lets the run end at its next safe point and writes its document
750 -- C<cancelled>, or what the run reached if it ended anyway -- or its
751 events, or a note. A second C<SIGINT> while it cancels, a C<SIGTERM>, and
752 with a machine format either signal during startup end the tool commands
753 and write the C<interrupted> document at once. Either way F<raider> then
754 dies of that same signal, so a shell reports 128 plus the signal number
755 and a parent that waits for it sees a process killed by the signal. A
756 model or embedding request that blocks the process (not an asynchronous
757 one) holds a cancel up until it returns; the second C<SIGINT> does not
758 wait.
759  
760 =back
761  
762 The C<hall> and C<acp> subcommands keep their own exit statuses.
763  
764 =head1 ENVIRONMENT
765  
766 API keys come from the environment variables below only. Claude Code
767 subscription/OAuth credentials are not consumed by this CLI; Anthropic
768 usage goes through the API key path.
769  
770 =head2 ANTHROPIC_API_KEY
771  
772 The key of the C<anthropic> engine. Set, it also makes C<anthropic> the
773 engine when nothing names one; so do the next five, in this order.
774  
775 =head2 OPENAI_API_KEY
776  
777 The key of C<openai>.
778  
779 =head2 DEEPSEEK_API_KEY
780  
781 The key of C<deepseek>.
782  
783 =head2 GROQ_API_KEY
784  
785 The key of C<groq>.
786  
787 =head2 MISTRAL_API_KEY
788  
789 The key of C<mistral>.
790  
791 =head2 GEMINI_API_KEY
792  
793 The key of C<gemini>.
794  
795 =head2 MINIMAX_API_KEY
796  
797 The key of C<minimax>. This one and the next two are only read for their
798 engine; they never pick it.
799  
800 =head2 CEREBRAS_API_KEY
801  
802 The key of C<cerebras>.
803  
804 =head2 OPENROUTER_API_KEY
805  
806 The key of C<openrouter>.
807  
808 =head2 BRAVE_API_KEY
809  
810 Adds Brave to C<web_search>, next to the keyless DuckDuckGo.
811  
812 =head2 SERPER_API_KEY
813  
814 Adds Serper to C<web_search>.
815  
816 =head2 GOOGLE_API_KEY
817  
818 With L</GOOGLE_CSE_ID>, adds Google Custom Search to C<web_search>.
819  
820 =head2 GOOGLE_CSE_ID
821  
822 The Custom Search engine id for L</GOOGLE_API_KEY>.
823  
824 =head2 RAIDER_PACK_DIRS
825  
826 Colon-separated directories searched for packs after the project's
827 F<.raider/packs/>, F<~/.raider/packs/> and the bundled ones; see
828 L<Langertha::Raider::Packs/build_packs>.
829  
830 =head2 HOME
831  
832 Where F<~/.raider/packs/> and the REPL history F<~/.raider_history> are.
833  
834 =head2 ANSI_COLORS_DISABLED
835  
836 Set, the output and the trace have no colors (C<--no-color> and the
837 machine output flags set it themselves).
838  
839 =head2 RAIDER_HALL_SOCKET
840  
841 The control socket of the Hall that started this raider. When it names a
842 socket, the Hall tools C<telegram_reply>, C<hall_status> and C<hall_spawn>
843 are mounted; the Hall sets it, together with C<RAIDER_HALL_TELEGRAM_BOT>,
844 C<RAIDER_HALL_TELEGRAM_CHAT_ID> and C<RAIDER_HALL_TELEGRAM_THREAD_ID> for a
845 Telegram mission (see L<Langertha::Raider::HallTools>).
846  
847 =head1 SEE ALSO
848  
849 =over
850  
851 =item * L<Langertha::Raider::CLI>
852  
853 =item * L<Langertha::Raider>
854  
855 =item * L<raider-hall> -- the Hall daemon, also reachable as C<raider hall>
856  
857 =back
858  
859 =head1 SUPPORT
860  
861 =head2 Issues
862  
863 Please report bugs and feature requests on GitHub at
864 L<https://github.com/Getty/langertha-raider/issues>.
865  
866 =head2 IRC
867  
868 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
869  
870 =head1 CONTRIBUTING
871  
872 Contributions are welcome! Please fork the repository and submit a pull request.
873  
874 =head1 AUTHOR
875  
876 Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>
877  
878 =head1 COPYRIGHT AND LICENSE
879  
880 This software is copyright (c) 2026 by Torsten Raudssus.
881  
882 This is free software; you can redistribute it and/or modify it under
883 the same terms as the Perl 5 programming language system itself.
884  
885 =cut
« blib/lib/Langertha/Raider/Hall/ACP/SubStream.pm ↑ Summary blib/lib/App/Raider.pm »