Skip to main content

PythonTool

Struct PythonTool 

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

A plugin’s Python tool.

Implementations§

Source§

impl PythonTool

Source

pub fn new( name: String, plugin: PluginRef, decl: ManifestTool, interpreter: Vec<OsString>, ) -> Option<Self>

decl must be a script tool (ToolKind::Script); None otherwise.

Source

pub fn with_sandbox(self, sandbox: Option<Sandbox>) -> Self

Run the script in sandbox (see run_script_sandboxed); None: unsandboxed.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Source

pub fn plugin(&self) -> &PluginRef

Source

pub fn declared(&self) -> &ManifestTool

The tool as the manifest declares it (its name may differ from the name the model sees when that one was taken).

Trait Implementations§

Source§

impl Tool for PythonTool

Source§

fn spec(&self) -> ToolSpec

Source§

fn title(&self, args: &Value) -> String

Short human title for the finished call, e.g. “Wrote notes.md”. args is untrusted.
Source§

fn access(&self, _args: &Value) -> Access

What this call would do; drives the permission gate. Must not have side effects.
Source§

fn run(&self, args: &Value, ctx: &ToolContext<'_>) -> ToolOutput

Do it. args is untrusted model output: validate everything, never panic.
Source§

fn pending_title(&self, _args: &Value) -> String

Title for the call before and while it runs, and on approval cards, e.g. “Write notes.md”. Defaults to “Run ”.
Source§

fn preview(&self, args: &Value, _workspace: &Path) -> Option<Preview>

A readable account of what the call would do, for approval cards: e.g. a diff for a file write. Reads only, no side effects; bounded. Defaults to the key arguments.
Source§

fn always_ask(&self, _args: &Value) -> Option<String>

Some(warning) if this call must be approved by a person every time: no policy, “always allow” grant or --auto-approve lets it run (e.g. installing system-wide). The warning is shown on the approval card.

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