250 250 Provider registration itself performs no network request and no auth refresh.
251 251 Authenticated model discovery is lazy and bounded.
253 +###
Long-lived token minting 255 +Klaus registers exactly one slash command for minting: `/klaus-setup-token`.
256 +It registers no CLI flag, because Pi applies extension flag values only after all extensions have loaded, so a flag cannot stop the TUI from starting.
258 +The command runs the Claude Code `setup-token` OAuth flow natively inside Pi and never spawns the Claude runtime.
259 +The child runtime is an Ink application that emits nothing without a TTY and full-screen escape sequences with one, so it cannot be embedded in Pi.
261 +The flow is authorization code with PKCE (S256) against `https://claude.com/cai/oauth/authorize` with the public Claude Code client id, scope `user:inference`, the manual redirect `https://platform.claude.com/oauth/code/callback`, and a random `state`.
262 +The token exchange posts JSON to `https://platform.claude.com/v1/oauth/token` with `grant_type=authorization_code`, the code, redirect URI, client id, code verifier, state, and `expires_in` of one year in seconds.
263 +Klaus rejects pasted input whose `state` differs from the generated one before any request.
265 +In TUI mode the whole visit happens inside one focused component, the Bureau of Tokens counter, so the animation frames the flow instead of interrupting it.
266 +Klaus opens the authorization URL in the browser and the counter opens at the same moment: the block-art snail clerk and the clerical form type themselves in above a live sign-in link and code field, and a `STATUS` row reports the current phase with a spinner.
267 +The link and the code field accept input from the first frame; the intro never gates the flow.
268 +Terminals that support OSC 8 receive one short hyperlinked label rather than the raw URL, because a wrapped or truncated link text would cut the escape sequence; terminals without OSC 8 get the wrapped URL instead.
269 +Pressing `c` while the code field is empty copies the authorization URL to the clipboard and reports the result inline.
270 +Accepted code shapes are the callback page's `code#state`, a redirect URL, a query string, or a bare code.
272 +Submitting moves the same counter to the exchange phase, then stamps the outcome in place: `APPROVED` with the validity row, the quip, and the clipboard verdict, or `DENIED` with the failure reason.
273 +`r` on a denied stamp files a fresh application: new PKCE, new URL, browser reopened, same counter.
274 +The first key press skips a running stamp animation, the next one closes the counter; Escape and the interrupt key cancel at any point, and only a cancellation before minting notifies `application withdrawn`.
275 +The animation timer is cleared on close and disposal, and its cadence follows the phase: fast during the intro and the stamp, slow while the human is signing in, off once the counter is static.
277 +Colors follow Anthropic's brand ramp, from book cloth through Claude orange, kraft, and manilla to cloud, for the mascot, title sweep, and approved stamp.
278 +The ramp uses true color when the theme reports it and falls back to ordered theme colors otherwise; form, ground, and verdict rows use theme colors, so success, warning, and error stay legible.
280 +The counter is responsive in three width tiers, selected per render so terminal resizes retake effect immediately: full at 62 columns or more, compact from 42, tiny below that.
281 +Narrower tiers use a smaller mascot, fewer sparkles, a shorter title and stamp, and abbreviated form labels; rows that still do not fit wrap instead of truncating.
282 +No rendered line exceeds the supplied width at any tier.
283 +Intro timing is width independent, so hints and skipping behave the same in every terminal size.
285 +Outside the TUI there is no counter: a plain input dialog collects the code, and notifications report the outcome, carrying the token when no clipboard tool worked.
287 +On success Klaus copies the token to the system clipboard using the first working tool of: `wl-copy`, `xclip -selection clipboard`, `xsel --clipboard --input` (Linux), `pbcopy` (macOS), `clip` (Windows), `termux-clipboard-set` (Termux).
288 +When no clipboard tool works, the counter prints the token itself, matching Claude Code's own fallback behavior.
290 +Klaus never persists the minted token: no cache, settings, session, or log writes.
291 +Minting is credential creation for the user, not credential storage, and does not violate the authentication non-goals of this spec.
293 +The counter is part of the contract: a bureaucratic joke at Anthropic's expense, with a snail clerk, delivered in Claude Code's own maximalist style.
253 295 ##
Child isolation 255 297 Every Claude child uses a Klaus-owned `CLAUDE_CONFIG_DIR`.
639 681 - Pi `minimal` maps to SDK `low`.
640 682 - Directly supported levels retain their meaning.
641 683 - Unsupported levels clamp to the highest supported level not above the request.
642 -- A clamp emits one warning per Pi session and level combination.
684 +- Adaptive-thinking models always use adaptive thinking plus an effort level, matching Pi's native treatment of them.
685 +- A Pi thinking budget never pins an adaptive-thinking model into fixed-budget thinking; budgets apply only to budget-based models (Haiku).
644 687 Cold replay omits historical thinking and signatures because they are neither safely portable nor required for canonical Pi history.
645 688 A live resumed SDK lineage may preserve opaque signed thinking through its own session cache.
668 711 ###
Output limits 670 -The Agent SDK exposes no enforceable response-token limit matching Pi `maxTokens`.
671 -Klaus silently ignores `maxTokens`.
672 -It does not reject requests, warn, or inject best-effort output-length instructions.
673 -This preserves Pi compaction and extensions that set the option.
713 +The Agent SDK `query()` options expose no enforceable response-token limit matching Pi `maxTokens`.
714 +Klaus honors Pi `maxTokens` through the runtime's `CLAUDE_CODE_MAX_OUTPUT_TOKENS` child environment variable instead.
716 +The value is read once per request from the Pi `SimpleStreamOptions`, carried on the Klaus request, validated as a positive safe integer, and set only when Pi supplies it.
717 +An absent Pi `maxTokens` leaves the variable unset so the runtime default applies; the variable is never inherited from the host environment.
718 +A `maxTokens` change across a tool-boundary continuation is an incompatibility that closes the continuation and replays canonically.