sessioncore

package
v0.8.2-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 13 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 sessioncore owns the durable session lifecycle: sessions, messages and parts are written to the flat JSON storage and every change is published on the bus.

Index

Constants

This section is empty.

Variables

View Source
var (
	EventCreated = bus.Define("session.created", nil)
	EventUpdated = bus.Define("session.updated", nil)
	EventDeleted = bus.Define("session.deleted", nil)
	EventDiff    = bus.Define("session.diff", nil)
	EventError   = bus.Define("session.error", nil)

	EventMessageUpdated     = bus.Define(msgmodel.EventMessageUpdated, nil)
	EventMessageRemoved     = bus.Define(msgmodel.EventMessageRemoved, nil)
	EventMessagePartUpdated = bus.Define(msgmodel.EventMessagePartUpdated, nil)
	EventMessagePartDelta   = bus.Define(msgmodel.EventMessagePartDelta, nil)
	EventMessagePartRemoved = bus.Define(msgmodel.EventMessagePartRemoved, nil)
)

Functions

func GetUsage

func GetUsage(input calc.GetUsageInput) calc.UsageResult

func IsDefaultTitle

func IsDefaultTitle(title string) bool

Types

type CreateInput

type CreateInput struct {
	ID          string
	ParentID    string
	Title       string
	Agent       string
	Model       *Model
	Permission  json.RawMessage
	WorkspaceID string
	Directory   string
	Path        string
}

type Info

type Info struct {
	ID          string          `json:"id"`
	Slug        string          `json:"slug"`
	ProjectID   string          `json:"projectID"`
	WorkspaceID *string         `json:"workspaceID,omitempty"`
	Directory   string          `json:"directory"`
	Path        *string         `json:"path,omitempty"`
	ParentID    *string         `json:"parentID,omitempty"`
	Title       string          `json:"title"`
	Agent       *string         `json:"agent,omitempty"`
	Model       *Model          `json:"model,omitempty"`
	Version     string          `json:"version"`
	Summary     *Summary        `json:"summary,omitempty"`
	Share       *Share          `json:"share,omitempty"`
	Revert      *Revert         `json:"revert,omitempty"`
	Permission  json.RawMessage `json:"permission,omitempty"`
	Time        Time            `json:"time"`
}

Info is the durable session record.

func FromRow

func FromRow(row Row) Info

type Model

type Model struct {
	ID         string  `json:"id"`
	ProviderID string  `json:"providerID"`
	Variant    *string `json:"variant,omitempty"`
}

type Options

type Options struct {
	Store       *storage.Store
	Bus         *bus.Bus
	ProjectID   string
	Worktree    string
	Directory   string
	WorkspaceID string
	Version     string
	Now         func() time.Time
	Slug        func() string
}

type Revert

type Revert struct {
	MessageID string  `json:"messageID"`
	PartID    *string `json:"partID,omitempty"`
	Snapshot  *string `json:"snapshot,omitempty"`
	Diff      *string `json:"diff,omitempty"`
}

type Row

type Row struct {
	ID               string              `json:"id"`
	ProjectID        string              `json:"project_id"`
	WorkspaceID      *string             `json:"workspace_id,omitempty"`
	ParentID         *string             `json:"parent_id,omitempty"`
	Slug             string              `json:"slug"`
	Directory        string              `json:"directory"`
	Path             *string             `json:"path,omitempty"`
	Title            string              `json:"title"`
	Agent            *string             `json:"agent,omitempty"`
	Model            *Model              `json:"model,omitempty"`
	Version          string              `json:"version"`
	ShareURL         *string             `json:"share_url,omitempty"`
	SummaryAdditions *uint64             `json:"summary_additions,omitempty"`
	SummaryDeletions *uint64             `json:"summary_deletions,omitempty"`
	SummaryFiles     *uint64             `json:"summary_files,omitempty"`
	SummaryDiffs     []msgmodel.FileDiff `json:"summary_diffs,omitempty"`
	Revert           *Revert             `json:"revert"`
	Permission       json.RawMessage     `json:"permission,omitempty"`
	TimeCreated      uint64              `json:"time_created"`
	TimeUpdated      uint64              `json:"time_updated"`
	TimeCompacting   *uint64             `json:"time_compacting,omitempty"`
	TimeArchived     *float64            `json:"time_archived,omitempty"`
}

Row is the storage-row projection consumed by FromRow and produced by ToRow.

func ToRow

func ToRow(info Info) Row

type Service

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

Service is safe for concurrent processor and observer use.

func New

func New(opts Options) (*Service, error)

func (*Service) Children

func (s *Service) Children(ctx context.Context, parentID string) ([]Info, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, input CreateInput) (Info, error)

func (*Service) Get

func (s *Service) Get(_ context.Context, sessionID string) (Info, error)

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Info, error)

func (*Service) Messages

func (s *Service) Messages(ctx context.Context, sessionID string) ([]msgmodel.WithParts, error)

Messages returns the session's messages oldest-first, each with its parts.

func (*Service) Remove

func (s *Service) Remove(ctx context.Context, sessionID string) error

func (*Service) Touch

func (s *Service) Touch(ctx context.Context, sessionID string) error

func (*Service) UpdateMessage

func (s *Service) UpdateMessage(_ context.Context, info msgmodel.Info) error

func (*Service) UpdateMessageWithParts

func (s *Service) UpdateMessageWithParts(
	_ context.Context, info msgmodel.Info, parts ...msgmodel.Part,
) error

UpdateMessageWithParts makes the message visible only after all of its parts are durable. The files are written part-first under one store operation, then projected message-first so SQLite foreign keys observe a complete turn.

func (*Service) UpdatePart

func (s *Service) UpdatePart(_ context.Context, part msgmodel.Part) error

func (*Service) UpdatePartDelta

func (s *Service) UpdatePartDelta(_ context.Context, input msgmodel.PartDeltaEvent)

type Share

type Share struct {
	URL string `json:"url"`
}

type Summary

type Summary struct {
	Additions uint64              `json:"additions"`
	Deletions uint64              `json:"deletions"`
	Files     uint64              `json:"files"`
	Diffs     []msgmodel.FileDiff `json:"diffs,omitempty"`
}

type Time

type Time struct {
	Created    uint64   `json:"created"`
	Updated    uint64   `json:"updated"`
	Compacting *uint64  `json:"compacting,omitempty"`
	Archived   *float64 `json:"archived,omitempty"`
}

Jump to

Keyboard shortcuts

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