Skip to main content

SessionService

Struct SessionService 

Source
pub struct SessionService { /* private fields */ }
Expand description

Stable programmatic facade for session lifecycle operations.

Implementations§

Source§

impl SessionService

Source

pub async fn generate_graph_proposal( &self, request: GenerateGraphProposalRequest, ) -> Result<(), SessionError>

Generates a proposal through the host’s bounded worker workflow.

§Errors

Returns admission, permissions, or persistence errors.

Source

pub async fn get_graph_proposal( &self, id: &str, ) -> Result<Option<GraphProposalState>, SessionError>

Queries pending, restored, or approved state without execution.

§Errors

Returns query delivery or persistence errors.

Source

pub async fn answer_graph_proposal( &self, id: &str, version: u32, answers: Vec<String>, ) -> Result<(), SessionError>

Answers the complete question set on an exact proposal version.

§Errors

Returns stale-version, incomplete-answer, or generation-limit errors.

Source

pub async fn regenerate_graph_proposal( &self, id: &str, version: u32, ) -> Result<(), SessionError>

Regenerates within the original captured generation ceiling.

§Errors

Returns stale-version, approved-proposal, or exhausted-limit errors.

Source

pub async fn revise_graph_proposal( &self, id: &str, version: u32, feedback: TurnPrompt, ) -> Result<(), SessionError>

Regenerates with user feedback, including its images, added to the generation history, within the original captured generation ceiling.

§Errors

Returns stale-version, empty-feedback, approved-proposal, or exhausted-limit errors.

Source

pub async fn approve_graph_proposal( &self, id: &str, version: u32, ) -> Result<(), SessionError>

Approves the exact preview before dispatch. Redelivery never dispatches.

§Errors

Returns stale-version, resolution, permissions, or publication errors.

Source

pub async fn cancel_graph_proposal( &self, id: &str, version: u32, ) -> Result<(), SessionError>

Cancels a pending proposal and any active generating utility.

§Errors

Returns stale-version or already-approved errors.

Source

pub async fn get_execution_graph( &self, graph_id: &str, ) -> Result<Option<ExecutionGraphProgress>, SessionError>

Reads graph/node progress and immutable execution history.

§Errors

Returns failed persistence or query delivery errors.

Source

pub async fn session_graphs( &self, request: SessionGraphsRequest, ) -> Result<SessionGraphs, SessionError>

Reads a session’s graphs as an inspector shows them: every graph, the latest proposal with its preview, and the selected graph with its live progress and the selected node’s outputs.

§Errors

Rejects a graph_id of another session, and returns failed persistence or query delivery errors.

Source

pub async fn act_on_session_graph( &self, request: SessionGraphActionRequest, ) -> Result<(), SessionError>

Accepts an output, cancels, resumes, or retries a graph, replies to one of its nodes, or adds provider calls to its spent budget, as the graph’s inspector does.

§Errors

Rejects a graph of another session, a graph that changed since request.snapshot was read, an action that snapshot does not offer, an empty reply, and a budget increase outside 1..=crate::ExtendGraphBudgetRequest::MAX_ADDITIONAL_CALLS, and returns failed admission or delivery errors.

Source

pub async fn cancel_execution_graph( &self, request: GraphControlRequest, ) -> Result<(), SessionError>

Permanently cancels this graph without canceling unrelated session work.

§Errors

Rejects missing/stale graphs and failed durable cancellation.

Source

pub async fn resume_execution_graph( &self, request: ResumeExecutionGraphRequest, ) -> Result<(), SessionError>

Resumes dispatch explicitly; failed nodes still require a new action.

§Errors

Rejects canceled/stale graphs, graphs without recorded launch limits, or ineligible sessions.

Source

pub async fn extend_execution_graph_budget( &self, request: ExtendGraphBudgetRequest, ) -> Result<(), SessionError>

Adds provider calls to one launched budget through a recorded, idempotent extension; the launch limits stay unchanged.

§Errors

Rejects stale, completed, or canceled graphs, unknown budgets, amounts outside 1..=ExtendGraphBudgetRequest::MAX_ADDITIONAL_CALLS, conflicting action identities, and failed persistence.

Source

pub async fn continue_execution_graph_node( &self, request: ContinueGraphNodeRequest, ) -> Result<(), SessionError>

Retries a failed node or answers its exact settled clarification set.

§Errors

Rejects stale sources, partial answers, conflicting action identities, canceled graphs, and failed persistence or delivery.

Source

pub async fn start_execution_graph( &self, request: StartExecutionGraphRequest, ) -> Result<(), SessionError>

Starts an explicit static graph without waiting for model execution.

§Errors

Rejects unsupported profiles, stale/conflicting identities, missing budgets, ineligible sessions, and failed persistence or delivery.

Source

pub async fn accept_execution_graph_result( &self, reference: GraphResultRef, ) -> Result<(), SessionError>

Accepts one exact validated output and releases its acceptance gate.

§Errors

Rejects stale or unvalidated references and failed persistence.

Source

pub async fn accept_agent_plan( &self, session_id: &SessionId, request: AcceptTaskPlanRequest, ) -> Result<(), SessionError>

Accepts a standalone Planner version from durable task history.

§Errors

Returns an error for stale/ineligible versions or failed persistence.

Source

pub fn new(backend: Arc<dyn SessionBackend>) -> Self

Creates an owned session capability backed by a shared host handle.

Source

pub async fn submit_agent_task( &self, session_id: &SessionId, request: SubmitAgentTaskRequest, ) -> Result<(), SessionError>

Admits an isolated role-bound attempt, acknowledging durable admission. Identical redeliveries do not execute again. Task completion is explicit.

§Errors

Returns an error for invalid input, unaccepted implementation plans, conflicting identity, or a session unable to accept work.

Source

pub async fn get_agent_task_history( &self, task_id: &str, ) -> Result<Option<TaskAgentHistory>, SessionError>

Reads the task’s own responses. Attempt status remains authoritative.

§Errors

Returns an error when the host cannot load the isolated conversation.

Source

pub async fn create_task( &self, session_id: &SessionId, request: CreateTaskRequest, ) -> Result<(), SessionError>

Persists a task with zero attempts in an existing session, regardless of its execution status. Does not start work or change session state. Identical creation requests preserve the task and its history.

§Errors

Returns an error for empty inputs, conflicting identity, a missing session, or a host that cannot persist tasks.

Source

pub async fn list_tasks( &self, session_id: &SessionId, ) -> Result<Vec<Task>, SessionError>

Lists all tasks owned by a session in creation order, including their attempt histories in one snapshot. Equal timestamps retain insertion order. Returns an empty list for a missing session or one without tasks.

§Errors

Returns an error when the host cannot read tasks.

Source

pub async fn submit_task( &self, session_id: &SessionId, request: SubmitTaskRequest, ) -> Result<(), SessionError>

Admits one task attempt through the existing serialized session worker. Creates the task atomically if it does not already exist. Acceptance does not wait for execution or imply task completion. Identical deliveries are acknowledged without running again.

§Errors

Returns an error for conflicting identity, an unavailable host, a completed task, or a session that cannot accept a new durable turn.

Source

pub async fn get_task( &self, task_id: &str, ) -> Result<Option<Task>, SessionError>

Loads a task and all its attempts from durable storage.

§Errors

Returns an error when the host cannot read tasks.

Source

pub async fn complete_task(&self, task_id: &str) -> Result<(), SessionError>

Explicitly accepts the outcome. Successful model execution alone never completes a task. Repeated completion retains its original timestamp.

§Errors

Returns an error if the task is missing, an attempt is unfinished, or the host cannot persist completion.

Source

pub fn supports(&self, operation: SessionOperation) -> bool

Reports whether the host serves operation to frontends that ask first.

Source

pub async fn host_context(&self) -> Result<HostContext, SessionError>

Describes the active project new sessions are created in.

§Errors

Returns an error when the host does not describe its project or cannot load its defaults.

Source

pub async fn project_status(&self) -> Result<HostProjectStatus, SessionError>

Reports the active project’s branch, its distance from upstream, and its latest explicit sync.

§Errors

Returns an error when the host does not report its project status.

Source

pub async fn sync_project(&self) -> Result<(), SessionError>

Starts or queues a sync of the active project’s branch with its upstream. The host acknowledges admission; Self::project_status reports the progress and the outcome.

§Errors

Returns an error when the host cannot start the sync now, such as while a merge runs, or does not support syncing its project.

Source

pub async fn create_session( &self, request: CreateSessionRequest, ) -> Result<SessionId, SessionError>

Creates one session and returns its stable identifier.

§Errors

Returns an error when the host cannot create the requested session.

Source

pub async fn get_session( &self, session_id: &SessionId, ) -> Result<Option<Session>, SessionError>

Loads one complete session aggregate by identifier.

§Errors

Returns an error when persisted data cannot be loaded or decoded.

Source

pub async fn get_session_diff( &self, session_id: &SessionId, ) -> Result<Option<Vec<SessionDiffFile>>, SessionError>

Loads the files one session changes against its base branch, or None when the host has not loaded the session.

§Errors

Returns an error when the host does not serve diffs or cannot compute or load this one.

Source

pub async fn list_session_files( &self, session_id: &SessionId, ) -> Result<Option<Vec<SessionFileEntry>>, SessionError>

Lists the files and directories in one session’s worktree, directories first, or None when the host has not loaded the session.

§Errors

Returns an error when the host does not serve file listings or cannot read this one.

Source

pub async fn list_project_files( &self, ) -> Result<Vec<SessionFileEntry>, SessionError>

Lists the files and directories in the active project’s checkout, directories first.

§Errors

Returns an error when the host does not serve project file listings or cannot read the checkout.

Source

pub async fn list_sessions(&self) -> Result<Vec<SessionSummary>, SessionError>

Lists the host’s loaded sessions in its display order.

§Errors

Returns an error when the host cannot list sessions.

Source

pub async fn list_session_entries( &self, ) -> Result<Vec<SessionListEntry>, SessionError>

Lists the host’s loaded sessions in its display order, with list stats when the host provides them.

§Errors

Returns an error when the host cannot list sessions.

Source

pub async fn send_message( &self, session_id: &SessionId, message: impl Into<String> + Send, ) -> Result<(), SessionError>

Sends a text message to one session.

§Errors

Returns an error when the session cannot accept or enqueue the message.

Source

pub async fn send_message_with_images( &self, session_id: &SessionId, message: impl Into<String> + Send, images: Vec<MessageImage>, ) -> Result<(), SessionError>

Sends a message with images to one session. The host attaches the images as [Image #n], numbered in images order from 1.

§Errors

Returns an error when the host does not take images in messages, or the session cannot accept or enqueue the message.

Source

pub async fn submit_durable_message( &self, session_id: &SessionId, request: DurableMessageRequest, ) -> Result<(), SessionError>

Submits one durable turn directly to the serialized worker.

§Errors

Returns an error when the session is busy or cannot accept the turn.

Source

pub async fn answer_questions( &self, session_id: &SessionId, request: AnswerQuestionsRequest, ) -> Result<(), SessionError>

Answers the complete current clarification-question set.

§Errors

Returns an error when the answers are stale, incomplete, or cannot be enqueued as a follow-up turn.

Source

pub async fn cancel_session( &self, session_id: &SessionId, ) -> Result<(), SessionError>

Cancels one session through its host lifecycle workflow.

§Errors

Returns an error when the session does not exist or cannot be canceled in its current state.

Source

pub async fn stop_turn( &self, session_id: &SessionId, ) -> Result<(), SessionError>

Stops the session’s running turn and returns the session to review. Unlike Self::cancel_session, the worktree and its changes stay; messages queued behind the turn are discarded.

§Errors

Returns an error when the session does not exist, has no running turn, or the host does not support stopping a turn.

Source

pub async fn rebase_session( &self, session_id: &SessionId, ) -> Result<(), SessionError>

Starts or queues a rebase of the session branch onto its base branch. The host acknowledges admission; a conflict starts an agent-assisted resolution turn.

§Errors

Returns an error when the session does not exist, cannot be rebased in its current state, or the host does not support syncing.

Source

pub async fn update_session_settings( &self, session_id: &SessionId, change: SessionSettingsChange, ) -> Result<(), SessionError>

Changes the session’s model, reasoning, style, or speed for later turns, where the terminal’s composer could change them.

The host refuses the whole change, applying none of it, when the session’s status has no composer, the model is not one the session’s agent offers, or fast mode does not suit the model the session will have. It then applies the model, reasoning, style, and speed in that order. Reasoning and style apply at once; a model or speed change waits while the session still has accepted work. Changes are not transactional: when one fails to apply, the ones before it stay applied.

§Errors

Returns an error when the session does not exist or its status has no composer, a model is not available to it, fast mode does not suit the resulting model, switching or persisting a setting fails, or the host does not support the change.

Source

pub async fn merge_session( &self, session_id: &SessionId, ) -> Result<(), SessionError>

Requests merge processing for one session.

§Errors

Returns an error when the session is not mergeable or queueing fails.

Source

pub async fn create_review_request( &self, session_id: &SessionId, ) -> Result<ReviewRequest, SessionError>

Queues publication of one session and creates or refreshes its review request.

§Errors

Returns an error when queueing, branch publication, forge access, or persistence fails.

Trait Implementations§

Source§

impl Clone for SessionService

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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