Skip to main content

KernelAdapter

Struct KernelAdapter 

Source
pub struct KernelAdapter<T: ?Sized> { /* private fields */ }
Expand description

Any OutcomeTool as a kernel tool: every description of a call (annotations, effects, access, outbound data) comes from the tool’s ToolSemantics.

Implementations§

Source§

impl<T: OutcomeTool + ?Sized> KernelAdapter<T>

Source

pub fn new(tool: Arc<T>) -> Self

Source

pub fn with_call_facts(self, facts: ToolCallContext) -> Self

Call the tool with these facts (who is asking, from which chat) instead of none: what the host knows about the turn the tool is offered in, such as its audience.

Source

pub fn with_spec(self, spec: ToolSpec) -> Self

Offer the tool under this spec instead of its own schema.

Source

pub fn with_trust_roots(self, roots: Arc<Vec<String>>) -> Self

The run’s trusted roots: where an effect lands can decide its class.

Source

pub fn with_owned_folders(self, owned: OwnedFolders) -> Self

The folders the request’s work made for itself: an effect landing there is the work’s own, so its class is judged like one inside the trusted roots (read live: a folder claimed mid-turn counts at once).

Source

pub fn with_validator(self, validator: CallValidator) -> Self

Check arguments with this instead of the schema’s required keys.

Source

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

Source

pub fn with_runner(self, runner: Arc<dyn OutcomeRunner>) -> Self

Run calls through runner instead of OutcomeTool::execute.

Trait Implementations§

Source§

impl<T: OutcomeTool + ?Sized + 'static> Tool for KernelAdapter<T>

Source§

fn annotations(&self) -> ToolAnnotations

Worst case for the tool as a whole: only a tool that is read-only for every call says so; any other may be destructive and egress.

Source§

fn concurrent_peers(&self) -> usize

Sub-agents spawned in one batch run together, up to MAX_CONCURRENT_CHILDREN: the coordination ledger arbitrates what they write. Every other non-read-only tool runs alone.

Source§

fn annotations_for(&self, arguments: &Value) -> ToolAnnotations

Judged per call: a mixed tool such as a shell reads for ls and writes for rm.

Source§

fn effects(&self, arguments: &Value) -> CallEffects

The tool’s own declaration for the arguments it will run with (after its argument canonicalization).

Source§

fn access(&self, arguments: &Value) -> AccessManifest

The declared effects as the kernel’s access manifest: egress targets as hosts, path effects as writes, a shell tool’s command line given as command or script, and a file tool’s guarded paths.

Source§

fn source_trust(&self, _arguments: &Value) -> SourceTrust

Fallback only: a result that knows its trust says so itself.

Source§

fn spec(&self) -> ToolSpec

Source§

fn outbound(&self, arguments: &Value) -> Outbound

What this call carries out of the machine if it only reads. The default says nothing does.
Source§

fn validate(&self, arguments: &Value) -> Result<(), String>

Deterministic argument checks, run before any policy or I/O. The kernel checks the arguments against the declared schema (check_arguments: required keys, types, enums, nested objects and array items) before calling this, whatever a tool does here, so an override only adds checks. The default is that schema check.
Source§

fn timeout(&self) -> Option<Duration>

How long this tool may run, overriding Limits::tool_timeout. Tools that take their own timeout argument (such as a shell) return a value at least as long as their own maximum.
Source§

fn call<'life0, 'life1, 'async_trait>( &'life0 self, arguments: Value, ctx: &'life1 ToolContext, ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn suspends(&self) -> bool

Whether this tool may answer with ToolOutput::suspended. A call of such a tool always runs alone, because a run pauses on one call at a time.
Source§

fn resume_child<'life0, 'life1, 'async_trait>( &'life0 self, _child: RunState, _resolution: Resolution, _ctx: &'life1 ToolContext, ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Continue the child run this tool suspended, with the answer to its interruption, and return what Tool::call would have returned: a result, or ToolOutput::suspended if the child paused again. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for KernelAdapter<T>

§

impl<T> !UnwindSafe for KernelAdapter<T>

§

impl<T> Forget for KernelAdapter<T>
where T: ?Sized,

§

impl<T> Freeze for KernelAdapter<T>
where *const ArcInner<T> is !null: Freeze, PhantomData<ArcInner<T>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, *const ArcInner<Vec<String>> is !null: Freeze, PhantomData<ArcInner<Vec<String>>>: Freeze, *const ArcInner<RwLock<Vec<String>>> is !null: Freeze, PhantomData<ArcInner<RwLock<Vec<String>>>>: Freeze, *const ArcInner<dyn Fn(&Value) -> Result<(), String> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&Value) -> Result<(), String> + Sync + Send>>: Freeze, *const ArcInner<dyn OutcomeRunner> is !null: Freeze, PhantomData<ArcInner<dyn OutcomeRunner>>: Freeze, PhantomData<String>: Freeze, PhantomData<(TypeId, Arc<dyn Any + Sync + Send>)>: Freeze, T: ?Sized,

§

impl<T> Move for KernelAdapter<T>
where T: ?Sized,

§

impl<T> Send for KernelAdapter<T>
where Arc<T>: Send, RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, Arc<Vec<String>>: Send, Arc<RwLock<Vec<String>>>: Send, Arc<dyn Fn(&Value) -> Result<(), String> + Sync + Send>: Send, Arc<dyn OutcomeRunner>: Send, RawTable<(TypeId, Arc<dyn Any + Sync + Send>)>: Send, T: ?Sized,

§

impl<T> Sync for KernelAdapter<T>
where Arc<T>: Sync, RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, Arc<Vec<String>>: Sync, Arc<RwLock<Vec<String>>>: Sync, Arc<dyn Fn(&Value) -> Result<(), String> + Sync + Send>: Sync, Arc<dyn OutcomeRunner>: Sync, RawTable<(TypeId, Arc<dyn Any + Sync + Send>)>: Sync, T: ?Sized,

§

impl<T> Unpin for KernelAdapter<T>
where Arc<T>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, Arc<Vec<String>>: Unpin, Arc<RwLock<Vec<String>>>: Unpin, Arc<dyn Fn(&Value) -> Result<(), String> + Sync + Send>: Unpin, Arc<dyn OutcomeRunner>: Unpin, *const (): Unpin, Arc<dyn Any + Sync + Send>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for KernelAdapter<T>
where *const ArcInner<T> is !null: UnsafeUnpin, PhantomData<ArcInner<T>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Value>: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin, *const ArcInner<Vec<String>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<String>>>: UnsafeUnpin, *const ArcInner<RwLock<Vec<String>>> is !null: UnsafeUnpin, PhantomData<ArcInner<RwLock<Vec<String>>>>: UnsafeUnpin, *const ArcInner<dyn Fn(&Value) -> Result<(), String> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&Value) -> Result<(), String> + Sync + Send>>: UnsafeUnpin, *const ArcInner<dyn OutcomeRunner> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn OutcomeRunner>>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<(TypeId, Arc<dyn Any + Sync + Send>)>: UnsafeUnpin, T: ?Sized,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more