Skip to main content

Wizard

Struct Wizard 

Source
pub struct Wizard {
Show 24 fields pub step: Step, pub cursor: usize, pub providers: Vec<ProviderRow>, pub detail: usize, pub defaults: Vec<Field>, pub limits: Vec<Field>, pub agents: Vec<AgentRow>, pub mcp: Vec<McpRow>, pub mcp_scan_errors: Vec<String>, pub edit: Option<Edit>, pub reveal: bool, pub show_help: bool, pub confirm: Option<PendingConfirm>, pub dirty: bool, pub claude_code_tos_accepted: bool, pub should_quit: bool, pub finished: bool, pub message: Option<String>, pub base: Config, pub env_only: HashMap<&'static str, String>, pub opener: BrowserOpener, pub verify_tx: UnboundedSender<VerifyRequest>, pub reply_rx: UnboundedReceiver<VerifyReply>, pub ticks: u64, /* private fields */
}
Expand description

The whole wizard.

Fields§

§step: Step§cursor: usize

Selected row within the current step.

§providers: Vec<ProviderRow>§detail: usize

Which selected provider the credential screen is showing.

§defaults: Vec<Field>§limits: Vec<Field>§agents: Vec<AgentRow>§mcp: Vec<McpRow>§mcp_scan_errors: Vec<String>§edit: Option<Edit>§reveal: bool

Show credentials in clear text.

§show_help: bool§confirm: Option<PendingConfirm>

A confirmation dialog is on screen, and (after Ctrl-C) it is the only thing keys mean until it is answered.

§dirty: bool

The user has changed something since the wizard opened, so quitting silently would discard real choices.

§claude_code_tos_accepted: bool

The user has acknowledged the Claude Code transport’s terms risk. A hard gate on saving: the transport cannot be written to the config without it, and deselecting the transport withdraws it.

§should_quit: bool§finished: bool

Set once the plan has been applied, so the loop knows to stop.

§message: Option<String>

A one-line status message.

§base: Config

The config as loaded from the file, which is what the plan is diffed against and built on.

§env_only: HashMap<&'static str, String>

Credentials present only in the environment. Shown, never written.

§opener: BrowserOpener

Opens a provider’s signup page. Injected rather than called directly: lev dash once had a unit test launch a real browser, and this is the same shape of hazard.

§verify_tx: UnboundedSender<VerifyRequest>§reply_rx: UnboundedReceiver<VerifyReply>§ticks: u64

Tick counter, for the spinner.

Implementations§

Source§

impl Wizard

Source

pub fn handle_key(&mut self, key: KeyEvent) -> Action

Handle one key press.

Source§

impl Wizard

Source

pub fn new( base: Config, env_lookup: &dyn Fn(&str) -> Option<String>, candidates: Vec<(String, Candidate)>, scan_errors: Vec<String>, agents_dir: &Path, opener: BrowserOpener, ) -> Self

Build the wizard from the config file and the surrounding environment.

base must come from reading the file, not from Config::load(): load folds $ANTHROPIC_API_KEY and friends into the struct, and the old wizard then re-serialized the whole thing - silently writing a key the user had deliberately kept in their environment into ~/.leviath/config.toml. Environment-supplied credentials are tracked separately in env_only and shown as such.

Source

pub fn take_verify_ends( &mut self, ) -> Option<(UnboundedReceiver<VerifyRequest>, UnboundedSender<VerifyReply>)>

Hand the background verifier loop its channel ends. Returns None if already taken.

Source

pub fn selected_providers(&self) -> Vec<usize>

Providers the user picked, in table order.

Source

pub fn detail_row(&self) -> Option<usize>

The provider row the credential screen is currently showing.

Source

pub fn claude_code_selected(&self) -> bool

Whether the Claude Code transport is one of the picked providers.

Source

pub fn needs_tos_confirmation(&self) -> bool

Whether saving must first ask the user to acknowledge Anthropic’s terms. Enabling the transport routes inference through a subscription session, so the risk is confirmed once, explicitly, rather than being buried in a paragraph nobody reads.

Source

pub fn fields(&self) -> &[Field]

The fields the current step edits, if it edits fields.

Source

pub fn row_count(&self) -> usize

How many selectable rows the current step has.

Source

pub fn nav_rows(&self) -> usize

How many cursor positions the current step has: its rows plus the Continue/action button that every step ends with.

Source

pub fn on_continue(&self) -> bool

Whether the cursor sits on the step’s Continue/action button (the virtual row after the last real one).

Source

pub fn continue_label(&self) -> String

The label of the current step’s Continue/action button. It carries state (selection counts, what screen is next) so advancing is never a surprise.

Source

pub fn move_cursor(&mut self, delta: isize)

Move the selection, clamped to the step’s rows plus its button.

Source

pub fn next_step(&mut self)

Advance to the next step, skipping ones with nothing to show. Skipping the credential screen is announced rather than silent: it looks exactly like a bug when a screen the breadcrumb promises never appears.

Source

pub fn prev_step(&mut self)

Go back a step, skipping empty ones. No-op on the first.

Source

pub fn enter(&mut self, step: Step)

Switch to step, resetting per-step state.

Source

pub fn next_detail(&mut self) -> bool

Within the credential screen, move to the next selected provider; returns false when there is no next one.

Source

pub fn prev_detail(&mut self) -> bool

The reverse of Self::next_detail.

Source

pub fn request_verification(&mut self, index: usize)

Ask the background verifier about the provider at index.

A provider with nothing to check is left alone rather than queued: a blank API key would fail with a message about the key rather than saying the obvious, that none was given.

Source

pub fn verify_all(&mut self)

Ask about every selected provider at once.

Source

pub fn drain_verifications(&mut self)

Take whatever the background verifier has answered.

Source

pub fn discovered_models(&self) -> Vec<String>

Every model id any provider reported, deduplicated, for the picker.

Source

pub fn rebuild_defaults(&mut self)

Rebuild the Defaults screen. Called on entry, since both the provider list and the discovered models can change between visits.

Source

pub fn apply_provider_concurrency_default(&mut self)

Set the concurrency default that suits the chosen provider.

A local Ollama serves one model at a time, so eight concurrent inferences against it queue and thrash rather than going faster. Only applied while the field still holds the general default, so a number the user typed is never overwritten.

Source

pub fn open_quit_confirm(&mut self)

q/Ctrl-C with unsaved choices: ask before discarding them.

Source

pub fn open_tos_confirm(&mut self)

Saving with the Claude Code transport selected: the terms risk is confirmed once, explicitly, on a dialog with real buttons.

Source

pub fn open_no_providers_confirm(&mut self)

Leaving the Providers screen with nothing selected: Leviath cannot run an agent without a provider, so this is almost always a slip.

Source

pub fn commit_edit(&mut self)

Commit an edited text buffer into wherever it belongs.

Source

pub fn build_config(&self) -> Config

Fold every choice into the config that will be written.

Source

pub fn build_plan(&self) -> SetupPlan

The plan this wizard describes.

Source

pub fn review_lines(&self) -> Vec<String>

Lines for the review screen.

Source

pub fn selected_inline_secrets(&self) -> Vec<String>

MCP rows carrying a credential copied verbatim out of another tool’s config, which importing would duplicate into ~/.leviath/config.toml.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more