Skip to main content

OptionsBuilder

Struct OptionsBuilder 

Source
pub struct OptionsBuilder {
    inner: Options,
}
Expand description

Builder for Options.

Fields§

§inner: Options

Implementations§

Source§

impl OptionsBuilder

Source

pub fn new() -> Self

Start from defaults.

Source

pub fn binary(self, binary: impl Into<String>) -> Self

Override the claude binary path or name.

Source

pub fn cwd(self, cwd: impl Into<PathBuf>) -> Self

Set the working directory for the subprocess.

Source

pub fn resume(self, session_id: impl Into<String>) -> Self

Resume an existing session.

Source

pub fn model(self, model: impl Into<String>) -> Self

Override the model.

Source

pub fn permission_mode(self, mode: PermissionMode) -> Self

Set the permission mode.

Source

pub fn can_use_tool<C>(self, callback: C) -> Self
where C: CanUseToolCallback + 'static,

Register a permission callback. Any type implementing CanUseToolCallback works - including plain async functions via the blanket impl.

Source

pub fn auto_approve_tool<F>(self, predicate: F) -> Self
where F: Fn(&str) -> bool + Send + Sync + 'static,

Auto-approve any tool whose name satisfies the predicate. forge-sdk consults this before invoking can_use_tool; the permission flow short-circuits with an allow decision for matches. Caller typically passes a closure that checks mcp__<server>__ prefixes for its in-process MCP servers.

Source

pub fn mcp_server(self, name: impl Into<String>, server: McpServer) -> Self

Register an in-process MCP server under the given name. The model sees tools as mcp__<name>__<tool>.

Source

pub fn hooks(self, hooks: Hooks) -> Self

Attach hooks.

Source

pub fn allowed_tools<I, S>(self, tools: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Set the --allowedTools list explicitly.

Source

pub fn permission_prompt_tool_name(self, name: impl Into<String>) -> Self

Set an orthogonal permission-prompt tool name (CLI flag --permission-prompt-tool). Alternative to can_use_tool - the CLI invokes the named tool (typically via MCP) instead of routing permission requests to the SDK callback.

Source

pub fn system_prompt(self, sp: SystemPromptKind) -> Self

Set the system prompt.

Source

pub fn max_turns(self, n: u64) -> Self

Cap the turn count.

Source

pub fn session_id(self, id: impl Into<String>) -> Self

Set an explicit session id for a new session (distinct from resume).

Source

pub fn plugins(self, plugins: Vec<SdkPluginConfig>) -> Self

Replace the whole plugin list.

Source

pub fn env(self, k: impl Into<String>, v: impl Into<String>) -> Self

Add one env var to the subprocess environment.

Source

pub fn extra_arg(self, flag: impl Into<String>, value: Option<String>) -> Self

Add one extra argv flag (pass None for bare flags).

Source

pub fn effort(self, e: SubagentEffort) -> Self

Set the reasoning-effort hint.

Source

pub fn tee_inbound(self, cb: impl Fn(&str) + Send + Sync + 'static) -> Self

Attach an inbound wire-tee callback. Receives every stream-json line read from the subprocess stdout (without trailing newline) before the SDK decodes it. Used by forge-test-harness to capture conformance baselines.

Source

pub fn tee_outbound(self, cb: impl Fn(&str) + Send + Sync + 'static) -> Self

Attach an outbound wire-tee callback. Receives every stream-json line about to be written to the subprocess stdin (without trailing newline). Counterpart to tee_inbound.

Source

pub fn build(self) -> Options

Finalise and return the Options.

Trait Implementations§

Source§

impl Clone for OptionsBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OptionsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OptionsBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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