pub trait BackgroundTaskHost: Send + Sync {
Show 20 methods
// Required methods
fn register<'life0, 'async_trait>(
&'life0 self,
request: BackgroundTaskRegisterRequest,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
update: BackgroundTaskUpdate,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
outcome: BackgroundTaskCompletion,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn request_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
reason: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<BackgroundTaskRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
filter: BackgroundTaskFilter,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundTaskRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn transfer<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
new_scope: BackgroundTaskScope,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn subscribe(
&self,
filter: BackgroundTaskFilter,
) -> BoxStream<'static, BackgroundTaskEvent>;
fn spawn_hidden<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
label: &'life2 str,
task: PluginSessionTask,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn await_hidden<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn spawn_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
task: PluginSessionTask,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn register_external<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
cancel: Option<LocalBackgroundTaskCancel>,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn unregister_external<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn mark_terminal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn mark_live_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn cancel_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn list_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundTaskRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<BackgroundTaskRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn transfer_managed<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
from_session_id: &'life1 str,
to_session_id: &'life2 str,
task_ids: &'life3 [String],
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn cancel_all_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<BackgroundTaskRecord>, PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Host-owned background task lifecycle policy.
Required Methods§
fn register<'life0, 'async_trait>(
&'life0 self,
request: BackgroundTaskRegisterRequest,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
update: BackgroundTaskUpdate,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
outcome: BackgroundTaskCompletion,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
reason: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
filter: BackgroundTaskFilter,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transfer<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
new_scope: BackgroundTaskScope,
) -> Pin<Box<dyn Future<Output = Result<BackgroundTaskRecord, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn subscribe( &self, filter: BackgroundTaskFilter, ) -> BoxStream<'static, BackgroundTaskEvent>
Sourcefn spawn_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
task: PluginSessionTask,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn spawn_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
task: PluginSessionTask,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Spawn a tokio-backed background task and register it under spec.id.
Local host owns the Tokio future and can abort it via cancel_managed.
Sourcefn register_external<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
cancel: Option<LocalBackgroundTaskCancel>,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_external<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
spec: BackgroundTaskRegistration,
cancel: Option<LocalBackgroundTaskCancel>,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Register an externally-owned task (e.g. a subagent session) so it
shows up in list_managed. The local host does not hold a JoinHandle;
if cancel is supplied it will be invoked when the registry receives
a cancel request, otherwise cancellation only updates bookkeeping.
fn unregister_external<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn mark_terminal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_terminal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update the state of a registered task to a terminal value. No-op if the task is unknown or already terminal.
Sourcefn mark_live_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_live_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
state: BackgroundTaskState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Transition a still-live task between the non-terminal Running
and Waiting states. Used by subagents to reflect whether the
session is actively working on a task or waiting for a
follow-up. No-op if the task is unknown or already terminal.
Sourcefn cancel_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cancel_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Cancel a tokio-backed task by id. No-op for externally-owned entries;
callers should also mark those terminal via mark_terminal.
Sourcefn list_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read-only snapshot of every registered task for the session.
Sourcefn get_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_managed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<BackgroundTaskRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Look up a single task’s metadata.
Sourcefn transfer_managed<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
from_session_id: &'life1 str,
to_session_id: &'life2 str,
task_ids: &'life3 [String],
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn transfer_managed<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
from_session_id: &'life1 str,
to_session_id: &'life2 str,
task_ids: &'life3 [String],
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Move still-registered tasks from one session scope to another.
Sourcefn cancel_all_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<BackgroundTaskRecord>, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_all_managed<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<BackgroundTaskRecord>, PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel every live task in a session scope and return updated snapshots.