| 1 |
% clnkrd(1) User Commands |
| 2 |
|
| 3 |
# NAME |
| 4 |
|
| 5 |
clnkrd - stdio JSONL adapter for clnkr |
| 6 |
|
| 7 |
# SYNOPSIS |
| 8 |
|
| 9 |
**clnkrd** [**--model** *name*] [**--base-url** *url*] [**--provider** *mode*] [**--provider-api** *surface*] [**--act-protocol** *protocol*] [**--effort** *level*] [**--thinking-budget-tokens** *n*] [**--max-output-tokens** *n*] [**--max-steps** *n*] [**--continue**] [**--load-messages** *file*] [**--event-log** *file*] [**--no-system-prompt**] [**--system-prompt-append** *text*] [**--dump-system-prompt**] [**--version**] |
| 10 |
|
| 11 |
# DESCRIPTION |
| 12 |
|
| 13 |
**clnkrd** runs clnkr behind a newline-delimited JSON protocol on standard |
| 14 |
input and standard output. A frontend writes one JSON command per line to |
| 15 |
stdin. clnkrd writes one JSON event per line to stdout. |
| 16 |
|
| 17 |
Normal diagnostics, flag errors, configuration errors, JSONL decode errors, |
| 18 |
and run errors are written to stderr. In JSONL mode, stdout is reserved for |
| 19 |
protocol events. |
| 20 |
|
| 21 |
clnkrd is a stdio adapter. It does not open sockets, authenticate clients, |
| 22 |
serve HTTP, host plugins, or manage a background service lifecycle. |
| 23 |
|
| 24 |
Tools, editors, wrappers, eval harnesses, and automation can launch clnkrd |
| 25 |
when they need to embed clnkr behavior behind a stdio JSONL protocol. In that |
| 26 |
use, stdout, stderr, and **--event-log** are the process artifact surfaces. |
| 27 |
|
| 28 |
# JSONL COMMANDS |
| 29 |
|
| 30 |
Every stdin line is one JSON object with a **type** field. |
| 31 |
Each command line may be up to 16 MiB. Longer lines are rejected as bad JSONL |
| 32 |
input, with diagnostics on stderr and exit status **1**. |
| 33 |
|
| 34 |
**prompt** |
| 35 |
: Start a run. |
| 36 |
Requires **text** and **mode**. **mode** is **approval** or **full_send**. |
| 37 |
Only one prompt can run at a time. |
| 38 |
|
| 39 |
``` |
| 40 |
{"type":"prompt","text":"inspect this repo","mode":"approval"} |
| 41 |
``` |
| 42 |
|
| 43 |
**reply** |
| 44 |
: Answer a pending **approval_request** or **clarify** event. |
| 45 |
For approval, **text** equal to **y** approves the command batch. Any other |
| 46 |
non-empty text rejects the batch and is sent back to the model as guidance. |
| 47 |
|
| 48 |
``` |
| 49 |
{"type":"reply","text":"y"} |
| 50 |
``` |
| 51 |
|
| 52 |
**compact** |
| 53 |
: Compact older transcript history. |
| 54 |
|
| 55 |
``` |
| 56 |
{"type":"compact"} |
| 57 |
``` |
| 58 |
|
| 59 |
**shutdown** |
| 60 |
: Cancel an active run, drain pending events, and exit successfully. |
| 61 |
|
| 62 |
``` |
| 63 |
{"type":"shutdown"} |
| 64 |
``` |
| 65 |
|
| 66 |
# JSONL EVENTS |
| 67 |
|
| 68 |
Every event written to stdout is a JSON object with **ts**, **type**, and **payload** fields. |
| 69 |
**ts** is a UTC RFC3339Nano timestamp recorded when clnkrd writes the event. |
| 70 |
Older event streams may contain only **type** and **payload**. |
| 71 |
|
| 72 |
**debug** |
| 73 |
: Diagnostic metadata and internal progress. Payload: **message**. |
| 74 |
|
| 75 |
**response** |
| 76 |
: Accepted model turn. Payload: **turn**, **usage**, and optional **raw**. |
| 77 |
**usage** contains **input_tokens** and **output_tokens**. |
| 78 |
|
| 79 |
**protocol_failure** |
| 80 |
: Rejected model response. Payload: **reason** and **raw**. |
| 81 |
|
| 82 |
**approval_request** |
| 83 |
: Command batch waiting for a **reply**. Payload: **prompt** and **commands**. |
| 84 |
Each command has **command** and optional **workdir**. |
| 85 |
|
| 86 |
**clarify** |
| 87 |
: User question waiting for a **reply**. Payload: **question**. |
| 88 |
|
| 89 |
**command_start** |
| 90 |
: Command execution started. Payload: **command** and **dir**. |
| 91 |
|
| 92 |
**command_done** |
| 93 |
: Command execution finished. Payload: **command**, **stdout**, **stderr**, |
| 94 |
**exit_code**, **feedback**, and optional **err**. |
| 95 |
|
| 96 |
**compacted** |
| 97 |
: Transcript compaction completed. Payload: **compacted_messages** and |
| 98 |
**kept_messages**. |
| 99 |
|
| 100 |
**done** |
| 101 |
: Prompt run completed. Payload: **summary**. |
| 102 |
|
| 103 |
**error** |
| 104 |
: Driver-visible run error. Payload: **message**. |
| 105 |
|
| 106 |
When the context length backstop runs, **clnkrd** emits debug events for |
| 107 |
compaction and retry progress, emits the normal **compacted** event with |
| 108 |
compacted and kept message counts, then continues with the normal **response**, |
| 109 |
**done**, or **error** event. No separate JSONL command is required. |
| 110 |
|
| 111 |
# OPTIONS |
| 112 |
|
| 113 |
clnkrd accepts the same provider, prompt, session, and run-control options as |
| 114 |
the clnkr CLI where they apply to non-interactive operation: |
| 115 |
**--model**, **--base-url**, **--provider**, **--provider-api**, |
| 116 |
**--act-protocol**, **--effort**, **--thinking-budget-tokens**, |
| 117 |
**--max-output-tokens**, **--max-steps**, **--continue**, |
| 118 |
**--load-messages**, **--event-log**, **--no-system-prompt**, |
| 119 |
**--system-prompt-append**, **--dump-system-prompt**, and **--version**. |
| 120 |
|
| 121 |
**--event-log** writes the same JSONL event stream to a file while also writing |
| 122 |
events to stdout. |
| 123 |
|
| 124 |
# STDIO JSONL EXAMPLES |
| 125 |
|
| 126 |
Run one adapter process and inspect its JSONL events: |
| 127 |
|
| 128 |
```bash |
| 129 |
workdir=$(mktemp -d /tmp/clnkr-processes.$$.XXXXXX) |
| 130 |
mkdir -p "$workdir/readme" |
| 131 |
printf '%s\n' '{"type":"prompt","text":"Inspect README.md. Do not edit files. Return evidence and uncertainty.","mode":"full_send"}' | |
| 132 |
clnkrd --event-log "$workdir/readme/events.jsonl" \ |
| 133 |
> "$workdir/readme/out.jsonl" \ |
| 134 |
2> "$workdir/readme/err" |
| 135 |
sed -n '1,200p' "$workdir/readme/out.jsonl" |
| 136 |
``` |
| 137 |
|
| 138 |
Run two independent adapter processes in parallel, then synthesize their |
| 139 |
output: |
| 140 |
|
| 141 |
```bash |
| 142 |
workdir=$(mktemp -d /tmp/clnkr-processes.$$.XXXXXX) |
| 143 |
mkdir -p "$workdir/code" "$workdir/docs" |
| 144 |
printf '%s\n' '{"type":"prompt","text":"Review prompt.go for clnkrd machine-facing JSONL adapter risks. Do not edit.","mode":"full_send"}' | |
| 145 |
clnkrd --event-log "$workdir/code/events.jsonl" \ |
| 146 |
> "$workdir/code/out.jsonl" 2> "$workdir/code/err" & pid1=$! |
| 147 |
printf '%s\n' '{"type":"prompt","text":"Review doc/*.1.md for clnkrd machine-facing JSONL adapter docs. Do not edit.","mode":"full_send"}' | |
| 148 |
clnkrd --event-log "$workdir/docs/events.jsonl" \ |
| 149 |
> "$workdir/docs/out.jsonl" 2> "$workdir/docs/err" & pid2=$! |
| 150 |
wait "$pid1" "$pid2" |
| 151 |
sed -n '1,200p' "$workdir/code/out.jsonl" |
| 152 |
sed -n '1,200p' "$workdir/docs/out.jsonl" |
| 153 |
``` |
| 154 |
|
| 155 |
# EXIT STATUS |
| 156 |
|
| 157 |
**0** |
| 158 |
: Clean EOF on stdin, **shutdown**, **--help**, **--version**, or |
| 159 |
**--dump-system-prompt**. |
| 160 |
|
| 161 |
**1** |
| 162 |
: Invalid flags, missing provider configuration, bad JSONL input, invalid |
| 163 |
command sequencing, session load failure, provider error, command/run error, |
| 164 |
or event write failure. |
| 165 |
|
| 166 |
**130** |
| 167 |
: Interrupted by SIGINT. |
| 168 |
|
| 169 |
# ENVIRONMENT |
| 170 |
|
| 171 |
**CLNKR_API_KEY** |
| 172 |
: API key for the LLM provider. |
| 173 |
|
| 174 |
**CLNKR_PROVIDER** |
| 175 |
: Provider adapter semantics. |
| 176 |
|
| 177 |
**CLNKR_PROVIDER_API** |
| 178 |
: OpenAI-only API surface override. |
| 179 |
|
| 180 |
**CLNKR_MODEL** |
| 181 |
: Default model identifier when **--model** is not provided. |
| 182 |
|
| 183 |
**CLNKR_BASE_URL** |
| 184 |
: Default LLM endpoint when **--base-url** is not provided. |
| 185 |
|
| 186 |
# SEE ALSO |
| 187 |
|
| 188 |
**clnkr**(1), **clnkr**(3), **clnkr**(7) |