pub struct Workflows { /* private fields */ }Expand description
The workflow observer over a host’s graph agents (spec 3.3 §12). Cheap to clone.
§Example
use std::sync::Arc;
use adk_surface::workflow::Workflows;
let workflows = Workflows::new("adk-rust").graph(graph).runner(runner);
assert_eq!(workflows.graphs().len(), 1);Implementations§
Source§impl Workflows
impl Workflows
Sourcepub fn new(app: impl Into<String>) -> Self
pub fn new(app: impl Into<String>) -> Self
An observer for the graph agents a runner of application app runs (spec 3.3 §12).
Sourcepub fn graph(self, graph: Arc<GraphAgent>) -> Self
pub fn graph(self, graph: Arc<GraphAgent>) -> Self
Observes graph, a graph agent with a checkpointer that the host’s runner runs.
Sourcepub fn runner(self, runner: Arc<Runner>) -> Self
pub fn runner(self, runner: Arc<Runner>) -> Self
Starts a fork’s run through runner, the runner whose root agent is the graph.
Sourcepub fn sessions(self, sessions: Arc<dyn SessionService>) -> Self
pub fn sessions(self, sessions: Arc<dyn SessionService>) -> Self
Reads and creates sessions through sessions; the runner’s when unset.
Sourcepub fn hide_keys(
self,
keys: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn hide_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Shows the values of these state keys, at any depth, as [hidden].
Sourcepub fn utc_offset(self, offset: FixedOffset) -> Self
pub fn utc_offset(self, offset: FixedOffset) -> Self
Shows times at offset east of UTC instead of the host’s time zone.
Sourcepub fn graphs(&self) -> Vec<GraphView>
pub fn graphs(&self) -> Vec<GraphView>
Every graph agent observed, with its nodes, edges and channels.
Sourcepub async fn runs(
&self,
caller: &Caller,
session: &str,
graph: Option<&str>,
) -> Result<RunsResponse>
pub async fn runs( &self, caller: &Caller, session: &str, graph: Option<&str>, ) -> Result<RunsResponse>
Every run of session, from the checkpoints’ records only (spec 3.3 §12).
§Errors
Returns surface.not_found for a session that is not the caller’s (S-I8), or for a
workflow graph does not name; the checkpointer’s error otherwise.
Sourcepub async fn run(
&self,
engine: &SurfaceEngine,
caller: &Caller,
session: &str,
graph: Option<&str>,
) -> Result<WorkflowRun>
pub async fn run( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, graph: Option<&str>, ) -> Result<WorkflowRun>
The latest run of session, as the Runs tab shows it (spec 3.3 §12): each node’s
state, the steps, the lineage and forks, and the decision each waiting node waits on,
matched in the inbox by origin and node.
§Errors
Returns surface.not_found for a session that is not the caller’s (S-I8), or for a
workflow graph does not name; the checkpointer’s or the source’s error otherwise.
Sourcepub async fn step(
&self,
engine: &SurfaceEngine,
caller: &Caller,
session: &str,
checkpoint: &str,
) -> Result<StepDetail>
pub async fn step( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, checkpoint: &str, ) -> Result<StepDetail>
One step of session, from the checkpoint checkpoint (spec 3.3 §12): its nodes,
“What changed” since the checkpoint before it, its state, and what a fork from it would
do. Reading it changes nothing.
§Errors
Returns surface.not_found for a session that is not the caller’s, or a checkpoint that
is not of the session’s thread (S-I8); the checkpointer’s error otherwise.
Sourcepub async fn version(
&self,
caller: &Caller,
session: &str,
) -> Result<Option<u64>>
pub async fn version( &self, caller: &Caller, session: &str, ) -> Result<Option<u64>>
The newest checkpoint version of session’s thread, which the Runs tab’s feed watches;
None before the first checkpoint.
§Errors
Returns surface.not_found for a session that is not the caller’s (S-I8).
Sourcepub async fn fork(
&self,
engine: &SurfaceEngine,
caller: &Caller,
session: &str,
request: ForkRequest,
) -> Result<ForkOutcome>
pub async fn fork( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, request: ForkRequest, ) -> Result<ForkOutcome>
Forks session at the completed checkpoint request.from into a new session of the
caller, with request.set written over whole channels, and starts it when
request.start is set (spec 3.3 §12).
| Refused | With |
|---|---|
| A paired device, or any surface but the web home | 403 surface.not_here |
| A session that is not the caller’s, or a checkpoint not of its thread | 404 surface.not_found (S-I8) |
| A decision of the session waits | 409 workflow.decision_waiting: “Answer the waiting decision first” |
A pause, a step with nothing after it, an edit of a key the graph does not declare, a value over FORK_VALUE_LIMIT | 400 with the fork’s fork.* code |
The original thread is never written; a governed call the fork makes unchanged is
answered from its record. While Stop all is on the fork is made and not started.
The fork is recorded as SURFACE_AUDIT_WORKFLOW_FORK with the session, the
checkpoint, the fork’s session, the edited keys and the caller’s surface and origin.
§Errors
As the table says, and the stores’ errors.
Sourcepub async fn start(
&self,
engine: &SurfaceEngine,
caller: &Caller,
session: &str,
) -> Result<ForkOutcome>
pub async fn start( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, ) -> Result<ForkOutcome>
Starts a fork made and not started, such as one made while everything was stopped.
§Errors
Returns 403 surface.not_here from a paired device or another surface,
404 surface.not_found for a session that is not the caller’s, 409 workflow.stopped
while everything is stopped, and 400 workflow.started for a run that already started.
Sourcepub fn approval_router(
&self,
fallback: impl ApprovalRouter + 'static,
) -> WorkflowRouter
pub fn approval_router( &self, fallback: impl ApprovalRouter + 'static, ) -> WorkflowRouter
An approval router that keeps fallback’s route and raises the risk of a call from a
governed node that spends money to high, so chat, voice and the kernel’s own routes
treat it as money (spec 3.3 §7.2, §7.4 rule 4).
§Example
use adk_core::{ApprovalPolicy, ApproverSelector};
use adk_surface::workflow::Workflows;
let router = Workflows::new("adk-rust")
.approval_router(ApprovalPolicy::new([ApproverSelector::group("owner")]));Trait Implementations§
Source§impl CardHints for Workflows
impl CardHints for Workflows
Source§fn hint<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<CardHint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn hint<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<CardHint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A governed node’s card (spec 3.3 §7.1, §12): never Always allow, money for a node that spends it, “Can’t be undone” for a non-idempotent one, and “From the invoice-run workflow · Open in Runs”.
Source§fn names<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn names<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
request’s call acts on, as the person knows it — “News digest” — which the
record of an answer to it names beside the card’s summary (spec 3.3 §8, §11). None,
the default, for a call that names nothing a person knows or that is not this
feature’s.Auto Trait Implementations§
impl !RefUnwindSafe for Workflows
impl !UnwindSafe for Workflows
impl Forget for Workflows
impl Freeze for Workflows
impl Move for Workflows
impl Send for Workflows
impl Sync for Workflows
impl Unpin for Workflows
impl UnsafeUnpin for Workflows
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 more