CLI Flags, Exec & Bridge Contracts & Env Vars
CONTENTS
- CLI Entrypoints
- Complete CLI Flags (mizar and mizar exec)
- mizar exec Automation Contract
- NDJSON Stream Schema (--json / --output-format ndjson / --output-format json)
- Exit Codes
- mizar bridge Long-Lived Protocol (v1.0)
- mizar bridge Flags
- Protocol Contract & Lifecycle
- Official TypeScript SDK (@mizar/sdk)
- Environment Variables Reference
- 1. LLM Routing & Credentials
- 2. Paths & Runtime Diagnostics
- 3. Corporate Proxies & Custom TLS CA Roots
- 4. Self-Update, Offline & Tool Installer Controls
- 5. Terminal, TUI Emphasis & Editor Integration
The mizar binary exposes five entrypoints sharing the same config resolution, routing logic, and Cordis plugin spine.
CLI Entrypoints
| Command Form | Purpose | Prompt Input / Args |
|---|---|---|
mizar [OPTIONS] | Launch interactive TUI workbench; passing -p / --prompt / --prompt-file enters headless exec | Interactive input or -p / --prompt-file |
mizar exec [OPTIONS] [<prompt>] | Headless single-turn execution for CI, benchmarks, and shell scripts | Positional <prompt>, -p, --prompt-file, or piped stdin |
mizar bridge [OPTIONS] | Long-lived stdio NDJSON JSON-RPC 2.0 bridge (protocol v1.0) for external host runtimes | stdin/stdout NDJSON frames (internal logs routed to stderr) |
mizar update [FLAGS] | Verify SHA-256 and update binary from GitHub Releases | -v/--version <ver>, -f/--force, --check, -h/--help |
mizar install-tools [--force] [rg|fd ...] | Install or locate managed rg & fd binaries in $MIZAR_HOME/bin | Installs both by default; --force reinstalls, with ghfast.top mirror fallback |
Complete CLI Flags (mizar and mizar exec)
| Flag | Value / Default | Scope | Description |
|---|---|---|---|
-C, --workspace <dir> | Path (default .) | Global | Override workspace root directory (fallback: WORKSPACE env var) |
-p, --prompt <text> | String | Global / exec | Provide a single prompt and run headlessly |
--prompt-file <path> | File path | Global / exec | Read prompt from file and run headlessly (conflicts with --prompt/<prompt>) |
--provider <name> | Provider ID | Global | Override provider (openai, openai-responses, anthropic, deepseek, mock, or models.json key) |
--model <id> | Model ID | Global | Override active model ID |
--protocol, --api-format <kind> | completions | responses | messages | Global | Select protocol adapter (accepts openai-completions, openai-responses, anthropic-messages) |
--base-url <url> | URL string | Global | Override API endpoint URL |
--reasoning-effort <level> | off | minimal | low | medium | high | xhigh | max | Global | Override reasoning effort |
--max-steps <n> | Positive integer (unlimited) | Global | Maximum tool steps allowed per turn; triggers code=max_steps on overflow |
--max-tokens <n> | Positive integer | Global | Override max output tokens per LLM response |
--context-window <tokens> | Positive integer (>= 1) | Global (TUI / exec) | Override model context window (takes precedence over MIZAR_CONTEXT_WINDOW and catalog) |
--timeout <secs> | Seconds | exec | Whole-turn execution timeout; exits with code 124 on expiry |
--output-format <fmt> | text (default) | json | ndjson | exec | Output format; json & ndjson emit line-flushed NDJSON events ending with result |
--json | Boolean flag | exec | Shorthand alias for --output-format ndjson |
--trace-out <path> | File path | exec | Atomically write structured TrajectoryExport JSON on exit (overrides MIZAR_TRACE_OUT) |
--isolated | Boolean flag | Global | Skip loading global and workspace disk configs; run cleanly in memory |
--minimal | Boolean flag | Global | Select default MinimalCoding preset (read, bash, edit, write only) |
--read-only | Boolean flag | Global | Select ReadOnly preset (read, grep, find only) |
-t, --tools <csv> | Comma-separated names | Global | Explicitly enable/constrain active tools |
-xt, --exclude-tools <csv> | Comma-separated globs | Global | Add tool exclusions (Hidden in both schemas and codemode) |
--inline | Boolean flag | TUI | Start directly in Inline scrollback viewport |
--approve | Boolean flag | TUI | Require interactive approval for non-read-only tools (ui.approvalMode: "ask") |
-c, --continue | Boolean flag | TUI / exec | Resume the most recent session for the current workspace |
-r, --resume [id] | Optional session ID | TUI / exec | Open session picker in TUI when id is omitted, or resume matching ID |
--no-persist | Boolean flag | Global | Disable JSONL session persistence (in-memory session only) |
--no-instructions | Boolean flag | Global | Skip startup AGENTS.md / CLAUDE.md discovery and injection |
--theme <name> | Theme name (auto) | TUI | Initial theme: auto | mist-dark | mist-light | sakura-dark | system | ansi16 |
-h, --help | — | Global | Print CLI help text |
-V, --version | — | Global | Print binary version and exit |
mizar exec Automation Contract
NDJSON Stream Schema (--json / --output-format ndjson / --output-format json)
Each line is a flushed JSON object carrying type and ts_ms: session, step_start, tool_call (redacted arguments_preview of at most 512 chars), tool_result (individual duration_ms and images), retry (plus [W retry] on stderr), compaction, step_end (6-field usage), ending with a single result after the persistence barrier (or a single invalid_request line on input/validation errors):
{
"type": "result",
"ts_ms": 1764250000000,
"session_id": "019...",
"resumed": false,
"reason": "completed",
"exit_code": 0,
"steps": 4,
"duration_ms": 3820,
"llm_ms": 2910,
"ttft_ms": 340,
"tool_ms": 880,
"tool_calls": 6,
"tool_errors": 0,
"retries": 0,
"compactions": 0,
"session_turns": 1,
"session_steps": 4,
"usage": { "input_tokens": 1200, "output_tokens": 350, "total_tokens": 1550, "cache_read_tokens": 0, "cache_write_tokens": 0, "reasoning_tokens": 0 },
"session_usage": { "input_tokens": 1200, "output_tokens": 350, "total_tokens": 1550, "cache_read_tokens": 0, "cache_write_tokens": 0, "reasoning_tokens": 0 },
"text": "Finished analyzing Cargo.toml..."
} Exit Codes
| Exit Code | Meaning | stderr Diagnostic Pattern |
|---|---|---|
0 | Completed turn cleanly | — |
1 | Generic error, storage failure, max steps, truncation, or cancellation | Contains code=storage, code=max_steps, code=max_tokens, code=cancelled, invalid_request, or secret-redacted error text |
124 | --timeout deadline exceeded | execution timed out after <secs>s (code=timeout) |
130 / 143 | Interrupted by signal (SIGINT / SIGTERM) | execution interrupted by signal (code=cancelled) |
Diagnostics printed to stderr or triggered by —trace-out write errors are automatically scrubbed against loaded API keys. When both —trace-out and MIZAR_TRACE_OUT are set, the CLI flag wins.
mizar bridge Long-Lived Protocol (v1.0)
mizar bridge (backed by mizar-bridge) allows external TypeScript or polyglot hosts to drive Mizar over strictly \n-delimited NDJSON JSON-RPC 2.0 on stdin/stdout (all internal logs go to stderr).
mizar bridge Flags
| Flag | Value / Default | Description |
|---|---|---|
-C, --workspace <dir> | Path (default .) | Workspace root directory |
--sessions-dir <dir|none> | MIZAR_SESSIONS_DIR / ~/.mizar/sessions | JSONL sessions directory, or none / off / memory to disable (disabled by default when --isolated) |
--isolated | Boolean flag | Skip user ~/.mizar global config, MCP, skills, and sessions |
--mock | Boolean flag | Force offline mock LLM route |
--identity <text> | String | Override system identity prompt (defaults to DEFAULT_IDENTITY) |
--identity-file <path> | File path | Read system identity prompt from file |
--personality <text> | String | Optional system personality prompt section |
--protocol-version | — | Print supported bridge protocol version (1.0) to stdout and exit |
-V, --version | — | Print binary version and exit |
-h, --help | — | Print mizar bridge help and exit |
Protocol Contract & Lifecycle
- Ready Handshake: Emits a
bridge.readynotification once initialized, reportingprotocolVersion: "1.0",bridgeVersion,workspace,isolated,mockMode,activeProvider, andactiveModel. - 19 Forward RPCs: Covers lifecycle & routing (
runtime.info,runtime.shutdown,router.reload), sessions (session.create,session.list,session.history,session.fork,session.compact), dynamic prompts (prompt.set_section,prompt.remove_section), dynamic tools (tools.register,tools.unregister,tools.list,tools.set_session_active,tool.emit_update), MCP management (mcp.reload,mcp.status), and turn control (turn.run,turn.cancel). - 14 Push Notifications & Reverse
tool.invoke: Streamsbridge.ready,turn.completed,compaction.end, and 11agent.*events; when a dynamically registered host tool is called, Mizar sends a reversetool.invokeRPC request over the same stdio pipe and awaits the host result (propagating timeouts and cancellation). - Graceful Shutdown: Exits cleanly with code
0onruntime.shutdownRPC (flushing{"ok": true}first),stdinEOF, orSIGTERM/SIGINT, cancelling active runs and disposing MCP/Cordis resources.
Official TypeScript SDK (@mizar/sdk)
Each GitHub Release also publishes the zero-runtime-dependency @mizar/sdk tarball (mizar-sdk-<tag>.tgz, source in sdk/ts/), providing a strict \n-delimited NDJSON parser, typed methods for all 19 RPCs and 14 events, reverse tool.invoke callbacks, onUnexpectedExit, and SHA-256 verified binary resolution (mizar-sdk install / ensureMizarBinary):
pnpm add https://github.com/Mieluoxxx/Mizar/releases/download/v0.2.9/mizar-sdk-v0.2.9.tgz
pnpm exec mizar-sdk install # Download and SHA-256 verify matching mizar binary import { MizarClient, ensureMizarBinary } from "@mizar/sdk";
await ensureMizarBinary();
const client = new MizarClient({
workspace: process.cwd(),
onUnexpectedExit: ({ code, signal }) => {
console.error(`mizar bridge exited: code=${code} signal=${signal}`);
},
});
await client.start();
const { sessionId } = await client.createSession({ title: "sdk-demo" });
const off = client.on("agent.text_delta", (ev) => process.stdout.write(ev.text));
await client.runTurnAndWait({ sessionId, input: "Summarize README.md" });
off();
await client.stop(); Environment Variables Reference
1. LLM Routing & Credentials
| Variable | Description |
|---|---|
API_KEY | Highest-precedence generic credential overriding provider-specific env keys |
OPENAI_API_KEY | Default key for openai / openai-responses |
ANTHROPIC_API_KEY | Default key for anthropic |
DEEPSEEK_API_KEY | Default key for deepseek |
OPENROUTER_API_KEY | OpenRouter credential env var available to router overrides |
PROTOCOL | Override wire protocol (completions / responses / messages) |
BASE_URL | Override API base URL |
MODEL | Override active model ID |
2. Paths & Runtime Diagnostics
| Variable | Default / Behavior |
|---|---|
WORKSPACE | Override workspace root (lower priority than -C/--workspace) |
MIZAR_HOME | Global config directory, default ~/.mizar (settings.json, models.json, mcp.json, sessions/, bin/) |
MIZAR_AGENTS_HOME | Global agent directory, default ~/.agents (AGENTS.md, skills) |
MIZAR_SESSIONS_DIR | Override JSONL sessions directory (default ~/.mizar/sessions); set to none, off, memory, or empty to disable |
MIZAR_CONTEXT_WINDOW | Override context window size (lower priority than --context-window, higher than model catalog) |
MIZAR_CACHE_RETENTION / PI_CACHE_RETENTION | Override default cache retention policy (none / short / long) |
MIZAR_LLM_IDLE_TIMEOUT_SECS | Override HTTP / SSE idle progress timeout in seconds |
MIZAR_BUNDLED_SKILL_DIR | Override bundled skills directory (lower priority than skills.bundledDir) |
MIZAR_TRACE_OUT | Default output path for mizar exec TrajectoryExport JSON |
CORDIS_LOG | Control Cordis microkernel log verbosity (e.g. debug / warn) |
3. Corporate Proxies & Custom TLS CA Roots
mizar-llm-http and mizar-mcp check standard ecosystem CA bundle env vars in order — any one suffices:
| Variable | Description |
|---|---|
SSL_CERT_FILE | OpenSSL / standard PEM CA root bundle file |
CURL_CA_BUNDLE | curl-compatible CA bundle file |
REQUESTS_CA_BUNDLE | Python requests-compatible CA bundle file |
NODE_EXTRA_CA_CERTS | Node.js extra trusted root certificates file |
4. Self-Update, Offline & Tool Installer Controls
| Variable | Description |
|---|---|
MIZAR_OFFLINE / PI_OFFLINE | When 1/true/yes/on, disables startup update checks and mizar install-tools downloads |
MIZAR_SKIP_VERSION_CHECK | When 1/true/yes/on, skips startup async release check |
MIZAR_RELEASE_BASE_URL | Override mizar update download base URL (default https://github.com/Mieluoxxx/Mizar) |
MIZAR_GITHUB_BASE_URL | Override mizar install-tools / TUI download base URL (default https://github.com) |
MIZAR_GITHUB_MIRROR | Fallback mirror prefix ({mirror}/{original_url}, default https://ghfast.top; set off/none/empty to disable) |
MIZAR_BIN_WARMUP_MS / MIZAR_BIN_SLOW_BPS | Warmup window in ms (default 5000) and slow-speed fallback threshold in bytes/s (default 65536) |
MIZAR_BIN_STALL_MS | Continuous stall timeout in ms before switching to mirror (default 8000) |
5. Terminal, TUI Emphasis & Editor Integration
| Variable | Description |
|---|---|
COLORTERM | Set to truecolor or 24bit for full Oklab 24-bit rendering |
TERM / COLORFGBG | Used for capability probing and auto dark/light detection |
SHELL | Fallback shell for bash tool when /bin/bash, /usr/bin/bash, and /bin/sh are absent |
VISUAL / EDITOR | External editor binary |
MIZAR_TUI_EMPHASIS | Set 0/false/off to disable pi-emphasis visual rendering |
MIZAR_TUI_ROUND_CAPS / PI_EMPHASIS_ROUND_CAPS | Set 0/false/off to turn off rounded pill caps |
MIZAR_TUI_PILL_ICONS / PI_EMPHASIS_PILL_ICONS | Set 0/false/off to hide Nerd Font pill icons |
MIZAR_TUI_EMPHASIS_GUIDANCE / PI_EMPHASIS_GUIDANCE | Set 0/false/off to omit emphasis prompt guidance |
MIZAR_TUI_PROGRAM_STATUS | Controls terminal window/progress status reporting |