Skip to main content

Crate warble_claude_code

Crate warble_claude_code 

Source
Expand description

Warble back-end for the Claude Code CLI target.

Consumes a compiled Warble IR (JSON) and emits a Claude Code agent runtime (agent files under .claude/agents/, settings, and RUN.md) — the static-file target, which needs no SDK, so it lives natively in Rust alongside the compiler and is driven by the warble CLI. Also hosts the deterministic reference renderer (render) and the capability-manifest projection (manifest).

Dispatch is keyed on IR enums (realization_kind, trigger.kind, effect.outcome.kind), never on a component’s id/verb. Enum arms not yet realized fail loudly (a “wall-hit”).

This crate is not a standalone tool — you install warble-cli (the warble binary), which links this crate in directly, and warble dispatch --target claude-code (or claude-code:headless / claude-code:interactive, the default) selects it at dispatch time.

Modules§

conditional
Deterministic realization of a conditional step’s closed-vocabulary when guard — mirrors dispatcher/claude-agent-sdk/src/conditional.ts field-for-field (see that module’s doc for the full R1 repair-fold-into-loop / R2 guarded-skip design).
ir
Typed view of the Warble IR (warble_ir_version: 0.3) that this back-end consumes.

Structs§

CapabilityManifest
DispatchError
A dispatch/render/resolve failure with a human-facing message. Every unsupported IR arm and every failed capability resolution surfaces as one of these (loud-fail) rather than emitting a silently-wrong agent.
Envelope
A parsed Warble render envelope (blocks + optional summary + optional verify facet).
ModelConfig
An ordered tier→binding map. Declaration order is priority: earlier tiers are “stronger” — used to pick the single model when a multi-tier component collapses to one agent. Alongside the authoring tiers (strong/cheap/custom, which components declare on steps) it carries the reserved ORCHESTRATOR_TIER used by the split driver.
RenderOptions
Document rendering options.
ResolvedCapability
TierBinding
A tier’s full runtime binding: which provider serves it, at what endpoint (for OpenAI-compatible providers), running which model. The shorthand YAML form tier: <model> is a { provider: anthropic, endpoint: none, model: <model> } binding — so existing configs are unchanged, and the file target (which only reads model) behaves exactly as before.

Enums§

HybridRealization
How the file target realizes a hybrid binding’s LOCAL step (llm:per_step_provider, see capability-model.md §7.2): BashScript emits a Bash-run local-inference script (needs bash in the allowlist); McpServer emits a .mcp.json registering warble mcp-serve so the driver calls a local_infer MCP tool (a separate permission gate — no bash widening). Default BashScript.
RenderFlavor
Render flavor (ir-schema.md §v0.3 §4). programmatic (default): the agent stays read-only and emits a {blocks} envelope; a downstream renderer produces HTML deterministically. prompt: the plain-file fallback — the agent is granted scoped write and writes dashboard.html itself.
TargetId
The two claude-code targets: engine × mode.

Constants§

ANTHROPIC_PROVIDER
Well-known provider name: rides the Claude runtime (the default when provider: is absent).
BINDING_SPEC_VERSION
The binding spec version this module implements — see binding-spec.md, the authoritative, versioned source both back-ends conform to (kept in lockstep to avoid the IR’s own version-drift history).
DEFAULT_RENDER_FLAVOR
DEFAULT_TARGET
claude-code target’s default mode when the caller doesn’t specify one.
OPENAI_COMPAT_PROVIDER
Well-known provider name: an OpenAI-compatible endpoint (e.g. ollama’s /v1); requires endpoint.

Functions§

build_manifest
Project a resolved IR into its runtime-agnostic capability manifest.
emit_claude_code
emit_claude_code_with_models
Emit Claude Code agent runtime files for a resolved IR into out_dir. Errors on any unsupported enum value rather than emitting a silently-wrong file. Runs the capability resolution pass first; on abort it errors and writes nothing. models resolves each step’s tier to a concrete model. A hybrid binding uses the default HybridRealization::BashScript; call emit_claude_code_with_realization to choose.
emit_claude_code_with_realization
As emit_claude_code_with_models, choosing how a hybrid binding’s LOCAL step is realized on the file target (bash-script script vs an MCP server). Only affects the hybrid path.
is_known_target
known_target_names
parse_envelope
Extract a Warble render envelope from raw agent output. The agent is asked to emit only the JSON envelope, but models routinely wrap it in ```json fences or surround it with a sentence. This is deliberately forgiving:
render_envelope_to_html
Render a full envelope to a single self-contained HTML document. Pure and deterministic: no clock, no randomness, stable ordering — the same envelope always produces identical bytes.
resolve_capabilities
Resolve every capability required by node against profile. Returns the report on success; errors (loud-fail) naming the capability + target if any required capability resolves to fail.
resolve_node_capabilities
Resolve one node’s required capabilities against target_id, erroring on any fail outcome (no silent degradation). Callers must not emit files when this errors.

Type Aliases§

Provider
Which provider serves a tier’s model — an open string, opaque to warble (mirrors how the IR treats tier; see binding-spec.md). Two well-known values get behavior baked into TierBinding parsing below (ANTHROPIC_PROVIDER, the default; OPENAI_COMPAT_PROVIDER, which requires endpoint), but warble does not validate this field against a fixed provider list — any other string is a valid, warble-unrecognized provider that passes through unchanged. Rejecting a genuinely unsupported provider is the consuming harness/back-end’s job (its per-provider adapter registry), never warble’s — warble stays opaque pass-through.
ResolutionReport