Documentation
¶
Overview ¶
Package sessions is the business layer for sessions: listing, details with summaries, and event timelines. The HTTP API, MCP tools and context builder all use it, so they apply the same ownership rules.
Index ¶
- Constants
- func Events(ctx context.Context, db *sql.DB, sessionID, afterAt, afterID string, limit int) (*model.EventPage, error)
- func Get(ctx context.Context, db *sql.DB, owner, sessionID string) (*model.SessionInfo, error)
- func List(ctx context.Context, db *sql.DB, owner string, q Query) ([]model.SessionInfo, error)
- func Summary(ctx context.Context, db *sql.DB, si *model.SessionInfo) (*summary.Summary, error)
- type Query
Constants ¶
const HasPrompt = `EXISTS (SELECT 1 FROM events ep WHERE ep.session_id = s.session_id AND ep.event_type = 'user.prompt')`
HasPrompt is the SQL condition (on sessions aliased "s") for a session the user actually talked in. Sessions without a prompt (an agent opened and closed, or a CLI subcommand such as `claude mcp list` that fires SessionEnd) are kept but not listed, summarized or offered as context.
Variables ¶
This section is empty.
Functions ¶
func Events ¶
func Events(ctx context.Context, db *sql.DB, sessionID, afterAt, afterID string, limit int) (*model.EventPage, error)
Events returns up to limit events after the (occurred_at, event_id) position.
Types ¶
type Query ¶
type Query struct {
ProjectIDs []string // empty: all of the owner's projects
AgentType string
DeviceID string
Status string
ExcludeID string
Since *time.Time
// Before/BeforeID page backwards: sessions whose last activity is before
// Before, or equal to it with a smaller session id (the last row of the
// previous page).
Before *time.Time
BeforeID string
Limit int
// IncludeEmpty also lists sessions without a user prompt.
IncludeEmpty bool
}
Query filters List.