session

package
v0.0.44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

type ClearWorkerPreview struct {
	Engine      string
	ActiveTasks []model.Task
}

ClearWorkerPreview is what EvaluateClearWorker would touch.

type ClearWorkerResult

type ClearWorkerResult struct {
	Engine         string
	CancelledTasks int64
	DeletedContext bool
}

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

type ExecutionStopper interface {
	StopExecution(executionID string) error
}

ExecutionStopper kills a running worker process by execution ID.

type SessionStore

type SessionStore interface {
	ListActiveSessionContexts(ctx context.Context, sessionKey, beeEngine string) ([]store.SessionAgent, error)
	DeleteSessionContextForEngine(ctx context.Context, sessionKey, agentID, engine string) (bool, error)
}

type StopWorkerResult added in v0.0.42

type StopWorkerResult struct {
	CancelledTasks int64
}

StopWorkerResult is the outcome of a StopWorker execution.

type TaskCanceller

type TaskCanceller interface {
	CancelTask(ctx context.Context, taskID string) error
}

TaskCanceller marks a single task cancelled in the DB and (for in-process implementations) drains it from the dispatcher's in-memory queue.

type TaskStore

type TaskStore interface {
	List(ctx context.Context, f store.TaskFilter) ([]model.Task, error)
	Cancel(ctx context.Context, f store.CancelFilter) (int64, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL