pub struct VisionToolset { /* private fields */ }Expand description
The governed vision tools over a VisionRuntime.
Images are named by their sha256: digest, as the tools return them, or by the name of
an artifact in the session; the toolset stores each one it reads in the runtime’s media
store, by digest. Install three pieces on the agent and run:
| Piece | Where | Why |
|---|---|---|
| The toolset | LlmAgentBuilder::toolset | The tools |
evidence_callback | LlmAgentBuilder::before_tool_callback | A held remote call carries its egress image |
egress_policy | RunConfig::tool_policy or Runner::builder().tool_policy | .adk/vision.toml decides each remote call: deny, ask or allow |
The adk-harness vision pack installs all three.
§Example
use std::sync::Arc;
use adk_artifact::InMemoryArtifactService;
use adk_vision::{DeterministicEditor, MediaStore, VisionRuntime, VisionToolset};
let store = MediaStore::new(Arc::new(InMemoryArtifactService::new()));
let runtime = VisionRuntime::builder()
.editor(Arc::new(DeterministicEditor::new()))
.media_store(store)
.build()
.unwrap();
let toolset = VisionToolset::builder(Arc::new(runtime)).build().unwrap();
// Only the tasks the runtime has a backend for become tools.
assert_eq!(toolset.tool_names(), vec!["vision_crop", "vision_redact", "vision_annotate"]);Implementations§
Source§impl VisionToolset
impl VisionToolset
Sourcepub fn builder(runtime: Arc<VisionRuntime>) -> VisionToolsetBuilder
pub fn builder(runtime: Arc<VisionRuntime>) -> VisionToolsetBuilder
A builder over runtime, which needs a media store.
Sourcepub fn runtime(&self) -> &Arc<VisionRuntime> ⓘ
pub fn runtime(&self) -> &Arc<VisionRuntime> ⓘ
The runtime the tools call.
Sourcepub fn tools(&self) -> Vec<Arc<dyn Tool>>
pub fn tools(&self) -> Vec<Arc<dyn Tool>>
The tools, one per task the runtime has a backend for, and vision_watch when the
toolset has frame sources.
Sourcepub fn tool_names(&self) -> Vec<&'static str>
pub fn tool_names(&self) -> Vec<&'static str>
The names of tools.
Sourcepub fn frame_sources(&self) -> Option<&FrameSources>
pub fn frame_sources(&self) -> Option<&FrameSources>
The frame sources vision_watch serves, when the toolset has them.
Sourcepub fn approve_egress(&self, digest: Digest)
pub fn approve_egress(&self, digest: Digest)
Approves an egress digest for EgressApproval::Explicit: the next call whose
staged image has this digest may release it.
Sourcepub fn is_remote_call(&self, tool: &str, args: &Value) -> bool
pub fn is_remote_call(&self, tool: &str, args: &Value) -> bool
Whether a call of tool with args would send an image off the machine: its route’s
primary backend is remote.
Sourcepub fn egress_action(&self, tool: &str, args: &Value) -> Option<EgressAction>
pub fn egress_action(&self, tool: &str, args: &Value) -> Option<EgressAction>
What the egress rules say about a call of tool with args: None for a call that
stays on the device (or does not parse), else the rule’s action for its destination
and data class. A harness classes the call by it (spec 3.7 X15).
Sourcepub fn evidence_callback(&self) -> BeforeToolCallback
pub fn evidence_callback(&self) -> BeforeToolCallback
The BeforeToolCallback that stages what a remote call would send, so the call is
held with the exact egress image (spec 3.7 S4).
For a vision tool call routed to a remote backend it resolves the image, runs the
egress gate’s destination, minimise and redact steps, stores the egress copy, and
keeps the copy’s evidence for the tool’s approval_evidence. It answers no call it
can stage; a call the gate refuses outright — an unlisted host, a missing redactor, a
rule that denies — is answered with the refusal, so nobody is asked about an image
that can never leave.
Sourcepub fn egress_policy(&self) -> Arc<dyn ToolPolicy> ⓘ
pub fn egress_policy(&self) -> Arc<dyn ToolPolicy> ⓘ
The ToolPolicy that applies the egress rules to each vision call: deny refuses,
ask requires a person’s approval, allow and on-device calls are allowed. Compose
it with the run’s other policies (StrictestPolicy); it decides no other tool.
Trait Implementations§
Source§impl Clone for VisionToolset
impl Clone for VisionToolset
Source§impl Debug for VisionToolset
impl Debug for VisionToolset
Source§impl Toolset for VisionToolset
impl Toolset for VisionToolset
Source§fn tools<'life0, 'async_trait>(
&'life0 self,
_ctx: Arc<dyn ReadonlyContext>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Arc<dyn Tool>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn tools<'life0, 'async_trait>(
&'life0 self,
_ctx: Arc<dyn ReadonlyContext>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Arc<dyn Tool>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn process_llm_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: Arc<dyn ReadonlyContext>,
_request: &'life1 mut LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn process_llm_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: Arc<dyn ReadonlyContext>,
_request: &'life1 mut LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for VisionToolset
impl !UnwindSafe for VisionToolset
impl Forget for VisionToolset
impl Freeze for VisionToolset
impl Move for VisionToolset
impl Send for VisionToolset
impl Sync for VisionToolset
impl Unpin for VisionToolset
impl UnsafeUnpin for VisionToolset
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.