Documentation
¶
Overview ¶
Package session contains domain operations on bee sessions reused by the IM slash-command handlers (/clear, /clear <worker>) and the RPC tool layer (clear_session, clear_worker_session, cancel_task).
Index ¶
- type ClearService
- func (s *ClearService) CancelTask(ctx context.Context, taskID string) error
- func (s *ClearService) ClearSession(ctx context.Context, sessionKey string, preview ClearSessionPreview) (ClearSessionResult, error)
- func (s *ClearService) ClearWorker(ctx context.Context, sessionKey string, w model.Worker, ...) (ClearWorkerResult, error)
- func (s *ClearService) EvaluateClearSession(ctx context.Context, sessionKey string) (ClearSessionPreview, error)
- func (s *ClearService) EvaluateClearWorker(ctx context.Context, sessionKey string, w model.Worker) (ClearWorkerPreview, error)
- func (s *ClearService) StopWorker(ctx context.Context, sessionKey string, w model.Worker) (StopWorkerResult, error)
- type ClearServiceDeps
- type ClearSessionPreview
- type ClearSessionResult
- type ClearWorkerPreview
- type ClearWorkerResult
- type Dispatcher
- type ExecutionFinalizer
- type ExecutionStopper
- type SessionStore
- type StopWorkerResult
- type TaskCanceller
- type TaskStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClearService ¶
type ClearService struct {
// contains filtered or unexported fields
}
ClearService performs the shared destructive operations behind /clear and ctl session clear*. Evaluate* methods are read-only previews; Clear* methods always execute. Callers gate the destructive path on their own UX.
func NewClearService ¶
func NewClearService(deps ClearServiceDeps) *ClearService
func (*ClearService) CancelTask ¶
func (s *ClearService) CancelTask(ctx context.Context, taskID string) error
CancelTask resolves the running execution for taskID, stops and finalizes it (if any), then marks the task cancelled via the TaskCanceller.
func (*ClearService) ClearSession ¶
func (s *ClearService) ClearSession(ctx context.Context, sessionKey string, preview ClearSessionPreview) (ClearSessionResult, error)
ClearSession stops the running executions, cancels immediate tasks, and drains the dispatcher queues for sessionKey. Always executes; callers pass the preview returned by EvaluateClearSession so this method doesn't repeat the lookups.
func (*ClearService) ClearWorker ¶
func (s *ClearService) ClearWorker(ctx context.Context, sessionKey string, w model.Worker, preview ClearWorkerPreview) (ClearWorkerResult, error)
ClearWorker stops the running executions, cancels the worker's immediate tasks, deletes the session context for the worker's engine, and drains the dispatcher queue for the pair. Always executes; callers pass the preview returned by EvaluateClearWorker so this method doesn't repeat the lookups.
func (*ClearService) EvaluateClearSession ¶
func (s *ClearService) EvaluateClearSession(ctx context.Context, sessionKey string) (ClearSessionPreview, error)
EvaluateClearSession is a read-only lookup of what a ClearSession call would clear. The destructive path is ClearSession.
func (*ClearService) EvaluateClearWorker ¶
func (s *ClearService) EvaluateClearWorker(ctx context.Context, sessionKey string, w model.Worker) (ClearWorkerPreview, error)
EvaluateClearWorker is a read-only lookup of what a ClearWorker call would touch for one worker in sessionKey.
func (*ClearService) StopWorker ¶ added in v0.0.42
func (s *ClearService) StopWorker(ctx context.Context, sessionKey string, w model.Worker) (StopWorkerResult, error)
StopWorker stops the running executions, cancels the worker's immediate tasks, and drains the dispatcher queue for the pair — the same as ClearWorker but WITHOUT deleting the worker's session context. This backs /stop {workerName}: interrupt in-flight work while preserving conversation memory.
type ClearServiceDeps ¶
type ClearServiceDeps struct {
Sessions SessionStore
Tasks TaskStore
ExecStopper ExecutionStopper
ExecFinalizer ExecutionFinalizer
Dispatcher Dispatcher
TaskCanceller TaskCanceller
RunningExecs utils.RunningExecLookup
EngineCfg *enginecfg.Store
}
ClearServiceDeps bundles the collaborators NewClearService needs.
type ClearSessionPreview ¶
type ClearSessionPreview struct {
Agents []store.SessionAgent
ActiveTasks []model.Task
}
ClearSessionPreview is what EvaluateClearSession would touch. When both fields are empty the session has nothing to clear.
type ClearSessionResult ¶
type ClearSessionResult struct {
Agents []store.SessionAgent
CancelledTasks int64
}
ClearSessionResult is the outcome of a ClearSession execution.
type ClearWorkerPreview ¶
ClearWorkerPreview is what EvaluateClearWorker would touch.
type ClearWorkerResult ¶
ClearWorkerResult is the outcome of a ClearWorker execution.
type Dispatcher ¶
type Dispatcher interface {
ClearSession(sessionKey string)
ClearWorker(sessionKey, workerID string)
}
Dispatcher drains the dispatcher's in-memory queues for a session or worker. The destructive DB operations live in this service; Dispatcher methods are best-effort signals to the dispatcher's Run loop.
type ExecutionFinalizer ¶
type ExecutionFinalizer interface {
MarkAbandoned(ctx context.Context, executionID, reason string) (bool, error)
}
ExecutionFinalizer marks an execution row abandoned when the process is no longer alive in this instance.
type ExecutionStopper ¶
ExecutionStopper kills a running worker process by execution ID.
type SessionStore ¶
type StopWorkerResult ¶ added in v0.0.42
type StopWorkerResult struct {
CancelledTasks int64
}
StopWorkerResult is the outcome of a StopWorker execution.
type TaskCanceller ¶
TaskCanceller marks a single task cancelled in the DB and (for in-process implementations) drains it from the dispatcher's in-memory queue.