pub struct SessionService { /* private fields */ }Expand description
Stable programmatic facade for session lifecycle operations.
Implementations§
Source§impl SessionService
impl SessionService
Sourcepub async fn accept_agent_plan(
&self,
session_id: &SessionId,
request: AcceptTaskPlanRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn start_plan_then_implement(
&self,
session_id: &SessionId,
request: StartPlanThenImplementRequest,
) -> Result<(), SessionError>
pub async fn start_plan_then_implement( &self, session_id: &SessionId, request: StartPlanThenImplementRequest, ) -> Result<(), SessionError>
Starts one Planner attempt with a captured provider/model selection.
§Errors
Returns an error for identity conflicts, ineligible sessions, or failed admission.
Sourcepub async fn get_task_chain(
&self,
chain_id: &str,
) -> Result<Option<TaskChain>, SessionError>
pub async fn get_task_chain( &self, chain_id: &str, ) -> Result<Option<TaskChain>, SessionError>
Reads a durable workflow snapshot without dispatching work.
§Errors
Returns an error when the host cannot read or decode the workflow.
Sourcepub async fn list_task_chains(
&self,
session_id: &SessionId,
) -> Result<Vec<TaskChain>, SessionError>
pub async fn list_task_chains( &self, session_id: &SessionId, ) -> Result<Vec<TaskChain>, SessionError>
Lists workflows owned by one session.
§Errors
Returns an error when the host cannot read workflow snapshots.
Sourcepub async fn accept_task_chain_plan(
&self,
chain_id: &str,
request: AcceptTaskChainPlanRequest,
) -> Result<(), SessionError>
pub async fn accept_task_chain_plan( &self, chain_id: &str, request: AcceptTaskChainPlanRequest, ) -> Result<(), SessionError>
Accepts an exact latest plan and admits its isolated Implementer attempt.
§Errors
Returns an error for stale/ineligible plans, conflicts, or failed admission.
Sourcepub async fn continue_task_chain(
&self,
chain_id: &str,
request: ContinueTaskChainRequest,
) -> Result<(), SessionError>
pub async fn continue_task_chain( &self, chain_id: &str, request: ContinueTaskChainRequest, ) -> Result<(), SessionError>
Explicitly revises, clarifies, or retries the current stage.
§Errors
Returns an error for unfinished attempts, conflicts, or failed admission.
Sourcepub async fn cancel_task_chain(
&self,
chain_id: &str,
) -> Result<(), SessionError>
pub async fn cancel_task_chain( &self, chain_id: &str, ) -> Result<(), SessionError>
Requests cancellation of this workflow’s current attempt.
§Errors
Returns an error when the workflow is missing or cancellation cannot persist.
Sourcepub async fn reply_to_task_chain(
&self,
session_id: &SessionId,
request: ReplyToTaskChainRequest,
) -> Result<TaskChainReplyOutcome, SessionError>
pub async fn reply_to_task_chain( &self, session_id: &SessionId, request: ReplyToTaskChainRequest, ) -> Result<TaskChainReplyOutcome, SessionError>
Records a user reply once and lets the host decide what it means.
While a plan awaits acceptance, the host decides through a model run
whether the reply clearly approves the plan. Only clear approval with
no requested changes starts the Implementer; anything else, including
a failed or uncertain decision, revises the plan. In every other
settled phase the reply continues the current role. Redelivering the
same reply_id returns the original outcome.
§Errors
Returns SessionError::TaskChainNotFound when the session owns no
workflow, SessionError::TaskChainBusy while an agent is working
or an earlier reply is being decided, and other errors for invalid
input, conflicts, or failed admission.
Sourcepub fn new(backend: Arc<dyn SessionBackend>) -> Self
pub fn new(backend: Arc<dyn SessionBackend>) -> Self
Creates an owned session capability backed by a shared host handle.
Sourcepub async fn submit_agent_task(
&self,
session_id: &SessionId,
request: SubmitAgentTaskRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn get_agent_task_history(
&self,
task_id: &str,
) -> Result<Option<TaskAgentHistory>, SessionError>
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.
Sourcepub async fn create_task(
&self,
session_id: &SessionId,
request: CreateTaskRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn list_tasks(
&self,
session_id: &SessionId,
) -> Result<Vec<Task>, SessionError>
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.
Sourcepub async fn submit_task(
&self,
session_id: &SessionId,
request: SubmitTaskRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn get_task(
&self,
task_id: &str,
) -> Result<Option<Task>, SessionError>
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.
Sourcepub async fn complete_task(&self, task_id: &str) -> Result<(), SessionError>
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.
Sourcepub async fn create_session(
&self,
request: CreateSessionRequest,
) -> Result<SessionId, SessionError>
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.
Sourcepub async fn get_session(
&self,
session_id: &SessionId,
) -> Result<Option<Session>, SessionError>
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.
Sourcepub async fn send_message(
&self,
session_id: &SessionId,
message: impl Into<String> + Send,
) -> Result<(), SessionError>
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.
Sourcepub async fn submit_durable_message(
&self,
session_id: &SessionId,
request: DurableMessageRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn answer_questions(
&self,
session_id: &SessionId,
request: AnswerQuestionsRequest,
) -> Result<(), SessionError>
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.
Sourcepub async fn cancel_session(
&self,
session_id: &SessionId,
) -> Result<(), SessionError>
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.
Sourcepub async fn merge_session(
&self,
session_id: &SessionId,
) -> Result<(), SessionError>
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.
Sourcepub async fn create_review_request(
&self,
session_id: &SessionId,
) -> Result<ReviewRequest, SessionError>
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.