Skip to main content

CliBindingConfig

Struct CliBindingConfig 

Source
pub struct CliBindingConfig {
    pub cmd: String,
    pub args: Vec<String>,
    pub args_template: Option<String>,
    pub env: BTreeMap<String, String>,
    pub output_format: Option<CliOutputFormat>,
    pub page_all_flag: Option<String>,
    pub dry_run_flag: Option<String>,
    pub exit_code_map: BTreeMap<i32, String>,
}
Expand description

Canonical CLI binding config (SP-cli-binding-v2).

All fields except cmd are optional and use skip_serializing_if so existing {"cmd": "..."} configs from before SP-cli-binding-v2 still round-trip byte-identically.

Fields§

§cmd: String

Executable name or absolute path. Required.

§args: Vec<String>

Fixed prefix arguments prepended to args_template expansion. Useful for subcommand routing (e.g. ["api", "v1"] so a tool always invokes cmd api v1 <rendered template>).

§args_template: Option<String>

Templated argv tail. Placeholders are replaced before spawn:

PlaceholderSubstitution
{tool_id}ATD tool id, e.g. mycli:gmail.users.messages.list
{params_json}RunTool.args serialized as one JSON argv slot (quoting handled by the dispatcher)
{dry_run}Empty string when dry_run=false; the value of Self::dry_run_flag when dry_run=true
{page_all}Empty string normally; Self::page_all_flag when the dispatcher is fanning out for call_all

The split between cmd + args (fixed) and args_template (per-call) lets servers reuse one binding for many tool ids by changing only the template. Servers are free to extend the placeholder vocabulary; consumers that don’t recognize a placeholder should pass it through literally.

§env: BTreeMap<String, String>

Environment variables injected into the spawned process.

The literal value "$ATD_BEARER" opts into bearer-token passthrough — the dispatcher replaces it with the connection’s bearer (from the SP-12 hello handshake) at spawn time. Other $NAME syntax is not interpolated; values are passed verbatim.

§output_format: Option<CliOutputFormat>

How to parse the subprocess stdout into the ToolResult.data field. Defaults to CliOutputFormat::Json when absent.

§page_all_flag: Option<String>

CLI-side flag the dispatcher appends when fanning out for call_all pagination. Absent = tool doesn’t support pagination; the dispatcher MUST surface call_page / call_all requests as unsupported instead of silently calling the tool without paging.

§dry_run_flag: Option<String>

CLI-side flag passed when the ATD client sets dry_run: true on RunTool. Absent = tool doesn’t expose dry-run; the dispatcher MUST reject the call rather than silently execute the side effect.

§exit_code_map: BTreeMap<i32, String>

Process exit-code → ATD ToolResult.code mapping for the error envelope. Codes not present in the map default to "TOOL_FAILED"; exit code 0 always succeeds and never consults the map. String values are domain-specific (e.g. "auth_required" for an OAuth refresh, "invalid_args" for CLI-side validation errors).

Implementations§

Source§

impl CliBindingConfig

Source

pub fn from_value(v: &Value) -> Result<Self, CliBindingConfigError>

Parse from a crate::tool::ToolBinding::config value. Returns Err when cmd is missing or other fields fail to deserialize. Unknown fields are tolerated (serde’s default) so future SP-cli-binding-v3 additions don’t break v2 parsers.

Source

pub fn to_value(&self) -> Value

Serialize to a serde_json::Value suitable for crate::tool::ToolBinding::config.

Trait Implementations§

Source§

impl Clone for CliBindingConfig

Source§

fn clone(&self) -> CliBindingConfig

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 CliBindingConfig

Source§

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

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

impl Default for CliBindingConfig

Source§

fn default() -> CliBindingConfig

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

impl<'de> Deserialize<'de> for CliBindingConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CliBindingConfig

Source§

fn eq(&self, other: &CliBindingConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CliBindingConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CliBindingConfig

Source§

impl StructuralPartialEq for CliBindingConfig

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.

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> 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 = 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,