session

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionBudgetExceeded = errors.New("session budget exceeded")

Functions

This section is empty.

Types

type Session

type Session struct {
	ID          string     `json:"id"`
	TenantID    string     `json:"tenant_id"`
	AgentID     string     `json:"agent_id"`
	Status      Status     `json:"status"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`
	TotalCost   float64    `json:"total_cost"`
	TotalTokens int        `json:"total_tokens"`
	MaxCost     float64    `json:"max_cost,omitempty"`
	Reasoning   string     `json:"reasoning,omitempty"`
}

type StageCounts

type StageCounts struct {
	Generation int `json:"generation"`
	Judge      int `json:"judge"`
	Commit     int `json:"commit"`
}

type Status

type Status string
const (
	StatusActive          Status = "active"
	StatusPendingApproval Status = "pending_approval"
	StatusExecuting       Status = "executing"
	StatusCompleted       Status = "completed"
	StatusFailed          Status = "failed"
	StatusTimedOut        Status = "timed_out"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) AddUsage

func (s *Store) AddUsage(ctx context.Context, id string, cost float64, tokens int) error

func (*Store) CheckBudget

func (s *Store) CheckBudget(ctx context.Context, id string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) Complete

func (s *Store) Complete(ctx context.Context, id string, cost float64, tokens int) error

func (*Store) Create

func (s *Store) Create(ctx context.Context, tenantID, agentID, reasoning string, maxCost float64) (*Session, error)

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*Session, error)

func (*Store) GetStageCounts

func (s *Store) GetStageCounts(ctx context.Context, sessionID string) (*StageCounts, error)

func (*Store) IncrementStageCount

func (s *Store) IncrementStageCount(ctx context.Context, sessionID, stage string) error

func (*Store) Join

func (s *Store) Join(ctx context.Context, id, tenantID string) (*Session, error)

func (*Store) ListByTenant

func (s *Store) ListByTenant(ctx context.Context, tenantID string, status Status) ([]*Session, error)

Jump to

Keyboard shortcuts

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