pub struct PythonTool { /* private fields */ }Expand description
A plugin’s Python tool.
Implementations§
Source§impl PythonTool
impl PythonTool
Sourcepub fn new(
name: String,
plugin: PluginRef,
decl: ManifestTool,
interpreter: Vec<OsString>,
) -> Option<Self>
pub fn new( name: String, plugin: PluginRef, decl: ManifestTool, interpreter: Vec<OsString>, ) -> Option<Self>
decl must be a script tool (ToolKind::Script); None otherwise.
Sourcepub fn with_python(self, python: Option<PluginPython>) -> Self
pub fn with_python(self, python: Option<PluginPython>) -> Self
Run with the plugin’s own Python (built on first use if it has requirements).
Sourcepub fn with_sandbox(self, sandbox: Option<Sandbox>) -> Self
pub fn with_sandbox(self, sandbox: Option<Sandbox>) -> Self
Run the script in sandbox (see run_script_sandboxed); None: unsandboxed.
pub fn with_timeout(self, timeout: Duration) -> Self
pub fn plugin(&self) -> &PluginRef
Sourcepub fn declared(&self) -> &ManifestTool
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
impl Tool for PythonTool
Source§fn pending_title(&self, args: &Value) -> String
fn pending_title(&self, args: &Value) -> String
The declared title too while it runs, on approval cards and when it fails (not “Run describe_sheet”).
fn spec(&self) -> ToolSpec
Source§fn title(&self, args: &Value) -> String
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
fn access(&self, _args: &Value) -> Access
What this call would do; drives the permission gate. Must not have side effects.
Source§fn always_ask(&self, args: &Value) -> Option<String>
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.Source§fn run(&self, args: &Value, ctx: &ToolContext<'_>) -> ToolOutput
fn run(&self, args: &Value, ctx: &ToolContext<'_>) -> ToolOutput
Do it.
args is untrusted model output: validate everything, never panic.Source§fn preview(&self, args: &Value, _workspace: &Path) -> Option<Preview>
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 card(&self, _args: &Value) -> Option<Card>
fn card(&self, _args: &Value) -> Option<Card>
The card a person confirms this call on, in plain words (
Card); None: the
preview, then the arguments in full. Only used for calls that must be confirmed.Source§fn concurrent(&self) -> bool
fn concurrent(&self) -> bool
Calls of this tool start before the other calls of the same round and run side by
side, each on a thread of its own (results still go back in call order). For tools
that mostly wait, like
delegate.Source§fn repeatable(&self, _args: &Value) -> bool
fn repeatable(&self, _args: &Value) -> bool
The same call can mean something new each time, so the turn’s repeat guard (“you
already called this”) lets it through: reads of state that changes, or undo.
Auto Trait Implementations§
impl Forget for PythonTool
impl Freeze for PythonToolwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
PhantomData<String>: Freeze,
PhantomData<OsString>: Freeze,
*const ArcInner<PyEnvs> is !null: Freeze,
PhantomData<ArcInner<PyEnvs>>: Freeze,
*const ArcInner<PyEnv> is !null: Freeze,
PhantomData<ArcInner<PyEnv>>: Freeze,
*const ArcInner<OnceLock<Enforcement>> is !null: Freeze,
PhantomData<ArcInner<OnceLock<Enforcement>>>: Freeze,
impl Move for PythonTool
impl RefUnwindSafe for PythonToolwhere
Atomic<usize>: RefUnwindSafe,
OnceLock<Result<PathBuf, String>>: RefUnwindSafe,
Mutex<BTreeMap<String, Arc<PyEnv>>>: RefUnwindSafe,
Mutex<State>: RefUnwindSafe,
Mutex<()>: RefUnwindSafe,
OnceLock<Enforcement>: RefUnwindSafe,
impl Send for PythonTool
impl Sync for PythonTool
impl Unpin for PythonTool
impl UnsafeUnpin for PythonToolwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<OsString>: UnsafeUnpin,
*const ArcInner<PyEnvs> is !null: UnsafeUnpin,
PhantomData<ArcInner<PyEnvs>>: UnsafeUnpin,
*const ArcInner<PyEnv> is !null: UnsafeUnpin,
PhantomData<ArcInner<PyEnv>>: UnsafeUnpin,
*const ArcInner<OnceLock<Enforcement>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<Enforcement>>>: UnsafeUnpin,
impl UnwindSafe for PythonToolwhere
RawVecInner: UnwindSafe,
BTreeMap<String, String>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
Arc<PyEnvs>: UnwindSafe,
Arc<PyEnv>: UnwindSafe,
Arc<OnceLock<Enforcement>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more