Skip to main content

ClientBuilder

Struct ClientBuilder 

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

Builder for creating a Copilot client.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new() -> Self

Create a new builder.

Source

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

Set the CLI executable path.

Source

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

Set additional CLI arguments passed to the Copilot CLI.

Source

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

Add a single CLI argument passed to the Copilot CLI.

Source

pub fn use_stdio(self, use_stdio: bool) -> Self

Use stdio mode (default).

Source

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

Set the CLI URL for TCP mode.

Supports: "host:port", "http://host:port", or "port" (defaults to localhost).

Source

pub fn port(self, port: u16) -> Self

Set port for TCP mode (ignored for stdio mode).

Use 0 to let the CLI choose a random available port.

Source

pub fn auto_start(self, auto_start: bool) -> Self

Auto-start the connection on first use.

Source

pub fn auto_restart(self, auto_restart: bool) -> Self

Auto-restart the connection after a fatal failure.

Source

pub fn log_level(self, level: LogLevel) -> Self

Set the log level.

Source

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

Set the working directory.

Source

pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self

Add an environment variable.

Source

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

Set a GitHub personal access token for authentication.

Source

pub fn use_logged_in_user(self, value: bool) -> Self

Set whether to use the logged-in user for auth.

Source

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

Add a single tool specification to deny.

Passed as --deny-tool to the CLI. Takes precedence over allow options.

§Example
use copilot_sdk::Client;

let client = Client::builder()
    .deny_tool("shell(git push)")
    .deny_tool("shell(git commit)")
    .deny_tool("shell(rm)")
    .build()?;
Source

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

Set multiple tool specifications to deny.

Passed as --deny-tool arguments to the CLI.

Source

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

Add a single tool specification to allow without manual approval.

Passed as --allow-tool to the CLI.

Source

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

Set multiple tool specifications to allow without manual approval.

Passed as --allow-tool arguments to the CLI.

Source

pub fn allow_all_tools(self, allow: bool) -> Self

Allow all tools without manual approval.

Passes --allow-all-tools to the CLI. Use with deny_tool() to create an allowlist with specific exceptions.

§Example
use copilot_sdk::Client;

// Allow everything except dangerous git operations and rm
let client = Client::builder()
    .allow_all_tools(true)
    .deny_tool("shell(git push)")
    .deny_tool("shell(git commit)")
    .deny_tool("shell(rm)")
    .build()?;
Source

pub fn build(self) -> Result<Client>

Build the client.

Trait Implementations§

Source§

impl Debug for ClientBuilder

Source§

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

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

impl Default for ClientBuilder

Source§

fn default() -> ClientBuilder

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<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