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: StringExecutable 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:
| Placeholder | Substitution |
|---|---|
{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
impl CliBindingConfig
Sourcepub fn from_value(v: &Value) -> Result<Self, CliBindingConfigError>
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.
Sourcepub fn to_value(&self) -> Value
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
impl Clone for CliBindingConfig
Source§fn clone(&self) -> CliBindingConfig
fn clone(&self) -> CliBindingConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CliBindingConfig
impl Debug for CliBindingConfig
Source§impl Default for CliBindingConfig
impl Default for CliBindingConfig
Source§fn default() -> CliBindingConfig
fn default() -> CliBindingConfig
Source§impl<'de> Deserialize<'de> for CliBindingConfig
impl<'de> Deserialize<'de> for CliBindingConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CliBindingConfig
impl PartialEq for CliBindingConfig
Source§fn eq(&self, other: &CliBindingConfig) -> bool
fn eq(&self, other: &CliBindingConfig) -> bool
self and other values to be equal, and is used by ==.