pub struct OptionsBuilder {
inner: Options,
}Expand description
Builder for Options.
Fields§
§inner: OptionsImplementations§
Source§impl OptionsBuilder
impl OptionsBuilder
Sourcepub fn binary(self, binary: impl Into<String>) -> Self
pub fn binary(self, binary: impl Into<String>) -> Self
Override the claude binary path or name.
Sourcepub fn cwd(self, cwd: impl Into<PathBuf>) -> Self
pub fn cwd(self, cwd: impl Into<PathBuf>) -> Self
Set the working directory for the subprocess.
Sourcepub fn permission_mode(self, mode: PermissionMode) -> Self
pub fn permission_mode(self, mode: PermissionMode) -> Self
Set the permission mode.
Sourcepub fn can_use_tool<C>(self, callback: C) -> Selfwhere
C: CanUseToolCallback + 'static,
pub fn can_use_tool<C>(self, callback: C) -> Selfwhere
C: CanUseToolCallback + 'static,
Register a permission callback. Any type implementing
CanUseToolCallback works - including plain async functions
via the blanket impl.
Sourcepub fn auto_approve_tool<F>(self, predicate: F) -> Self
pub fn auto_approve_tool<F>(self, predicate: F) -> Self
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.
Sourcepub fn mcp_server(self, name: impl Into<String>, server: McpServer) -> Self
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>.
Sourcepub fn allowed_tools<I, S>(self, tools: I) -> Self
pub fn allowed_tools<I, S>(self, tools: I) -> Self
Set the --allowedTools list explicitly.
Sourcepub fn permission_prompt_tool_name(self, name: impl Into<String>) -> Self
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.
Sourcepub fn system_prompt(self, sp: SystemPromptKind) -> Self
pub fn system_prompt(self, sp: SystemPromptKind) -> Self
Set the system prompt.
Sourcepub fn session_id(self, id: impl Into<String>) -> Self
pub fn session_id(self, id: impl Into<String>) -> Self
Set an explicit session id for a new session (distinct from resume).
Sourcepub fn plugins(self, plugins: Vec<SdkPluginConfig>) -> Self
pub fn plugins(self, plugins: Vec<SdkPluginConfig>) -> Self
Replace the whole plugin list.
Sourcepub fn env(self, k: impl Into<String>, v: impl Into<String>) -> Self
pub fn env(self, k: impl Into<String>, v: impl Into<String>) -> Self
Add one env var to the subprocess environment.
Sourcepub fn extra_arg(self, flag: impl Into<String>, value: Option<String>) -> Self
pub fn extra_arg(self, flag: impl Into<String>, value: Option<String>) -> Self
Add one extra argv flag (pass None for bare flags).
Sourcepub fn effort(self, e: SubagentEffort) -> Self
pub fn effort(self, e: SubagentEffort) -> Self
Set the reasoning-effort hint.
Sourcepub fn tee_inbound(self, cb: impl Fn(&str) + Send + Sync + 'static) -> Self
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.
Sourcepub fn tee_outbound(self, cb: impl Fn(&str) + Send + Sync + 'static) -> Self
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.