deck

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCompleted = sessions.StatusCompleted
	StatusFailed    = sessions.StatusFailed
	StatusAbandoned = sessions.StatusAbandoned
	StatusUnknown   = sessions.StatusUnknown
)

Status constants re-exported from pkg/sessions so existing TUI callers (`deck.StatusCompleted` etc.) keep working without an import change.

Variables

View Source
var ErrEmptyChain = errors.New("empty session chain")

ErrEmptyChain is returned when SessionDetail receives an empty chain back from the API. Exported so callers can branch on it if needed.

Functions

func HasLLMCredentials

func HasLLMCredentials(cfg LLMCallerConfig) bool

HasLLMCredentials checks whether an API key can be resolved from the config without creating a caller. Used for auto-enabling insights.

func SeedDemoToDriver added in v0.5.0

func SeedDemoToDriver(ctx context.Context, driver storage.Driver) (int, int, error)

func SeedDemoViaAPI added in v0.5.0

func SeedDemoViaAPI(ctx context.Context, apiTarget string, overwrite bool) (int, int, error)

func SortSessions

func SortSessions(sessions []SessionSummary, sortKey, sortDir string)

SortSessions sorts session summaries in place by the given key and direction.

Types

type Filters

type Filters struct {
	Since   time.Duration
	From    *time.Time
	To      *time.Time
	Model   string
	Status  string
	Project string
	Sort    string
	SortDir string
	Session string
}

Filters describes the user-facing filter set the deck applies on top of the data returned by the API. Time filters are evaluated client-side against SessionSummary.StartTime / EndTime; the per-field string filters are also applied client-side after the rich /v1/sessions/summary fetch.

type HTTPQuery added in v0.4.0

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

HTTPQuery is a Querier implementation that talks to a remote (or in-process) tapes API server over HTTP. It mirrors the Querier surface of the local query path so callers can swap implementations without changes.

func NewHTTPQuery added in v0.4.0

func NewHTTPQuery(apiTarget string, pricing PricingTable) *HTTPQuery

NewHTTPQuery constructs an HTTPQuery pointed at apiTarget (e.g. "http://127.0.0.1:8081"). The pricing table is retained for client-side recalculation if needed; in practice the API server already returns fully-populated SessionSummary objects.

func (*HTTPQuery) Overview added in v0.4.0

func (q *HTTPQuery) Overview(ctx context.Context, filters Filters) (*Overview, error)

Overview fetches a single recent page from /v1/sessions/summary, then runs the existing deck-side grouping, filtering, and rollup logic on that bounded result set.

Filters that the API understands natively (since/from, to/until, project, model) are pushed down to the request as query params so the server can narrow the SQL work before building rich summaries. Filters that depend on derived state (status, sort order) stay client-side and are applied to the smaller page returned below.

func (*HTTPQuery) OverviewPage added in v0.5.0

func (q *HTTPQuery) OverviewPage(ctx context.Context, filters Filters, cursor string, limit int) (*OverviewPage, error)

OverviewPage fetches one bounded page from /v1/sessions/summary and returns the API cursor needed to request the next page. The first page replaces the detail cache; subsequent pages merge into it so group/detail lookups keep working for every loaded row.

func (*HTTPQuery) SessionDetail added in v0.4.0

func (q *HTTPQuery) SessionDetail(ctx context.Context, sessionID string) (*SessionDetail, error)

SessionDetail fetches the chain for a single session via /v1/sessions/:hash and renders the per-turn message data using the cached SessionSummary for the same ID. Group IDs (synthetic IDs from groupSessionCandidates) are resolved against the cached candidates.

type LLMCallFunc

type LLMCallFunc func(ctx context.Context, prompt string) (string, error)

LLMCallFunc is the signature for an LLM inference call.

func NewLLMCaller

func NewLLMCaller(cfg LLMCallerConfig) (LLMCallFunc, error)

NewLLMCaller creates a LLMCallFunc based on the provided configuration. Resolution order for API key:

  1. Explicit APIKey in config
  2. credentials.Manager (from tapes auth)
  3. Environment variables (OPENAI_API_KEY / ANTHROPIC_API_KEY)

type LLMCallerConfig

type LLMCallerConfig struct {
	Provider string               // "openai", "anthropic", or "ollama"
	Model    string               // e.g. "gpt-4o-mini", "claude-haiku-4-5-20251001"
	APIKey   string               // explicit API key (highest priority)
	BaseURL  string               // override base URL
	CredMgr  *credentials.Manager // credentials from tapes auth
}

LLMCallerConfig holds configuration for creating an LLM caller.

type ModelCost

type ModelCost = sessions.ModelCost

ModelCost aliases sessions.ModelCost for the same reason.

type Overview

type Overview struct {
	Sessions       []SessionSummary     `json:"sessions"`
	TotalCost      float64              `json:"total_cost"`
	TotalTokens    int64                `json:"total_tokens"`
	InputTokens    int64                `json:"input_tokens"`
	OutputTokens   int64                `json:"output_tokens"`
	TotalDuration  time.Duration        `json:"total_duration_ns"`
	TotalToolCalls int                  `json:"total_tool_calls"`
	SuccessRate    float64              `json:"success_rate"`
	Completed      int                  `json:"completed"`
	Failed         int                  `json:"failed"`
	Abandoned      int                  `json:"abandoned"`
	CostByModel    map[string]ModelCost `json:"cost_by_model"`
	PreviousPeriod *PeriodComparison    `json:"previous_period,omitempty"`
}

Overview is the response a Querier returns from Overview. It holds the filtered list of session summaries plus dashboard rollups.

type OverviewPage added in v0.5.0

type OverviewPage struct {
	Overview   *Overview
	NextCursor string
	HasMore    bool
}

OverviewPage is one page of the deck overview plus the API cursor needed to fetch the next page. HasMore is true when NextCursor is non-empty.

type OverviewPager added in v0.5.0

type OverviewPager interface {
	OverviewPage(ctx context.Context, filters Filters, cursor string, limit int) (*OverviewPage, error)
}

OverviewPager is an optional extension implemented by query backends that can return bounded overview pages. TUI callers use it to lazily load more sessions without forcing every Querier implementation to support pagination.

type PeriodComparison

type PeriodComparison struct {
	TotalCost      float64       `json:"total_cost"`
	TotalTokens    int64         `json:"total_tokens"`
	TotalDuration  time.Duration `json:"total_duration_ns"`
	TotalToolCalls int           `json:"total_tool_calls"`
	SuccessRate    float64       `json:"success_rate"`
	Completed      int           `json:"completed"`
}

PeriodComparison holds the previous-period metrics shown alongside the current period in the deck overview.

type Pricing

type Pricing = sessions.Pricing

Pricing aliases sessions.Pricing so the deck and the API both speak the same model-cost type. The standalone definition was removed when pricing logic moved to pkg/sessions.

type PricingTable

type PricingTable = sessions.PricingTable

PricingTable aliases sessions.PricingTable so the deck and the API speak the same map type without conversion at every boundary.

func DefaultPricing

func DefaultPricing() PricingTable

DefaultPricing returns the canonical pricing table from pkg/sessions. Re-exported as a function so consumers that already imported deck.DefaultPricing keep working without an import change.

type Querier

type Querier interface {
	Overview(ctx context.Context, filters Filters) (*Overview, error)
	SessionDetail(ctx context.Context, sessionID string) (*SessionDetail, error)
}

Querier is the interface the deck TUI use to fetch session data. The HTTPQuery implementation in this package talks to a tapes API server (in-process or remote) over HTTP.

type SeedDemoResponse added in v0.5.0

type SeedDemoResponse struct {
	Sessions int `json:"sessions"`
	Messages int `json:"messages"`
}

type SessionDetail

type SessionDetail struct {
	Summary         SessionSummary        `json:"summary"`
	Messages        []SessionMessage      `json:"messages"`
	GroupedMessages []SessionMessageGroup `json:"grouped_messages,omitempty"`
	ToolFrequency   map[string]int        `json:"tool_frequency"`
	SubSessions     []SessionSummary      `json:"sub_sessions,omitempty"`
}

SessionDetail is the response a Querier returns from SessionDetail. It holds the per-session SessionSummary plus its rendered transcript.

type SessionMessage

type SessionMessage struct {
	Hash         string        `json:"hash"`
	Role         string        `json:"role"`
	Model        string        `json:"model"`
	Timestamp    time.Time     `json:"timestamp"`
	Delta        time.Duration `json:"delta_ns"`
	InputTokens  int64         `json:"input_tokens"`
	OutputTokens int64         `json:"output_tokens"`
	TotalTokens  int64         `json:"total_tokens"`
	InputCost    float64       `json:"input_cost"`
	OutputCost   float64       `json:"output_cost"`
	TotalCost    float64       `json:"total_cost"`
	ToolCalls    []string      `json:"tool_calls"`
	Text         string        `json:"text"`
}

SessionMessage is the per-turn render shape used by the deck's transcript view. It is built client-side from the API's Turn objects in HTTPQuery and is not part of any HTTP API surface.

type SessionMessageGroup

type SessionMessageGroup struct {
	Role         string        `json:"role"`
	StartTime    time.Time     `json:"start_time"`
	EndTime      time.Time     `json:"end_time"`
	Delta        time.Duration `json:"delta_ns"`
	InputTokens  int64         `json:"input_tokens"`
	OutputTokens int64         `json:"output_tokens"`
	TotalTokens  int64         `json:"total_tokens"`
	InputCost    float64       `json:"input_cost"`
	OutputCost   float64       `json:"output_cost"`
	TotalCost    float64       `json:"total_cost"`
	ToolCalls    []string      `json:"tool_calls"`
	Text         string        `json:"text"`
	Count        int           `json:"count"`
	StartIndex   int           `json:"start_index"`
	EndIndex     int           `json:"end_index"`
}

SessionMessageGroup is a batched run of adjacent same-role messages, used by the deck's transcript view to collapse rapid back-and-forth turns into a single visual entry.

type SessionSummary

type SessionSummary = sessions.SessionSummary

SessionSummary aliases sessions.SessionSummary. The deck used to define its own copy with identical fields; the alias removes the duplication while keeping deck.SessionSummary working for the dozens of TUI sites that reference it.

Jump to

Keyboard shortcuts

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