store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package store handles persistent storage using SQLite

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertRecord

type AlertRecord struct {
	ID        string    `json:"id"`
	AgentID   string    `json:"agent_id"`
	Level     string    `json:"level"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	Read      bool      `json:"read"`
	Metadata  string    `json:"metadata"`
}

AlertRecord represents a stored alert

type MetricRecord

type MetricRecord struct {
	ID        string    `json:"id"`
	AgentID   string    `json:"agent_id"`
	Metric    string    `json:"metric"`
	Value     float64   `json:"value"`
	Timestamp time.Time `json:"timestamp"`
}

MetricRecord represents a stored metric point

type SessionRecord

type SessionRecord struct {
	ID            string    `json:"id"`
	AgentID       string    `json:"agent_id"`
	AgentType     string    `json:"agent_type"`
	AgentName     string    `json:"agent_name"`
	Directory     string    `json:"directory"`
	ProjectID     string    `json:"project_id"`
	Status        string    `json:"status"`
	StartTime     time.Time `json:"start_time"`
	EndTime       time.Time `json:"end_time"`
	LastActivity  time.Time `json:"last_activity"`
	TokensIn      int64     `json:"tokens_in"`
	TokensOut     int64     `json:"tokens_out"`
	EstimatedCost float64   `json:"estimated_cost"`
	ToolCalls     int       `json:"tool_calls"`
	ErrorCount    int       `json:"error_count"`
	Output        string    `json:"output"`
	Metadata      string    `json:"metadata"`
}

SessionRecord represents a stored session

type Store

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

Store handles persistent storage

func New

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

New creates a new store

func (*Store) AppendOutput

func (s *Store) AppendOutput(sessionID string, chunk string) error

AppendOutput appends output to a session

func (*Store) Cleanup

func (s *Store) Cleanup(maxAgeDays int) error

Cleanup removes old data

func (*Store) Close

func (s *Store) Close() error

Close closes the database

func (*Store) ExportJSON

func (s *Store) ExportJSON() ([]byte, error)

ExportJSON exports all data as JSON

func (*Store) GetMetrics

func (s *Store) GetMetrics(agentID string, metric string, since time.Time) ([]*MetricRecord, error)

GetMetrics gets metrics for an agent

func (*Store) GetOutput

func (s *Store) GetOutput(sessionID string) (string, error)

GetOutput gets all output for a session

func (*Store) GetSession

func (s *Store) GetSession(id string) (*SessionRecord, error)

GetSession gets a session by ID

func (*Store) GetStats

func (s *Store) GetStats() (map[string]interface{}, error)

GetStats gets aggregate statistics

func (*Store) ListAlerts

func (s *Store) ListAlerts(limit int, unreadOnly bool) ([]*AlertRecord, error)

ListAlerts lists alerts

func (*Store) ListSessions

func (s *Store) ListSessions(limit int, status string) ([]*SessionRecord, error)

ListSessions lists sessions with optional filters

func (*Store) MarkAlertRead

func (s *Store) MarkAlertRead(id string) error

MarkAlertRead marks an alert as read

func (*Store) MarkAllAlertsRead

func (s *Store) MarkAllAlertsRead() error

MarkAllAlertsRead marks all alerts as read

func (*Store) SaveAlert

func (s *Store) SaveAlert(rec *AlertRecord) error

SaveAlert saves an alert

func (*Store) SaveMetric

func (s *Store) SaveMetric(rec *MetricRecord) error

SaveMetric saves a metric point

func (*Store) SaveSession

func (s *Store) SaveSession(rec *SessionRecord) error

SaveSession saves or updates a session

Jump to

Keyboard shortcuts

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