localstore

package
v0.0.0-...-53658a8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(id, reportPath, firstPinFeedback, firstPinURL string) string

BuildPrompt returns the host-owned clipboard prompt.

func DefaultRoot

func DefaultRoot() (string, error)

DefaultRoot returns the platform data directory for local sessions.

func ValidateRelativePath

func ValidateRelativePath(raw string) (string, error)

ValidateRelativePath rejects absolute paths, traversal, and empty path segments.

Types

type CommittedReport

type CommittedReport struct {
	ID        string `json:"id"`
	Path      string `json:"path"`
	Prompt    string `json:"prompt"`
	CreatedAt string `json:"created_at"`
}

CommittedReport describes a report after it has been indexed.

type ListOptions

type ListOptions struct {
	Limit int
	Query string
}

ListOptions configures local session listing.

type ListResponse

type ListResponse struct {
	Results    []SessionSummary `json:"results"`
	NextCursor *string          `json:"next_cursor"`
	Count      int              `json:"count"`
}

ListResponse mirrors the cloud list response shape with local string ids.

type PinSearchHit

type PinSearchHit struct {
	Pin     map[string]any `json:"pin"`
	Session SessionSummary `json:"session"`
}

PinSearchHit is a local pin search result with the parent session summary.

type PinSearchResponse

type PinSearchResponse struct {
	Results []PinSearchHit `json:"results"`
	Total   int            `json:"total"`
}

PinSearchResponse is the local search_pins response.

type Pragmas

type Pragmas struct {
	JournalMode string
	Synchronous string
}

Pragmas reports the index SQLite runtime settings.

type PruneOptions

type PruneOptions struct {
	OlderThan time.Duration
	Now       time.Time
}

PruneOptions configures local retention cleanup.

type Report

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

Report is an in-progress local report written under a temporary directory.

func (*Report) AppendFile

func (r *Report) AppendFile(relPath string, _ string, data []byte) error

AppendFile appends chunk data under the report temp directory.

func (*Report) Commit

func (r *Report) Commit(ctx context.Context) (*CommittedReport, error)

Commit atomically moves the temp report into the sessions directory and indexes it.

func (*Report) WriteFile

func (r *Report) WriteFile(relPath string, _ string, data []byte) error

WriteFile writes a complete file under the report temp directory.

type ReportMetadata

type ReportMetadata struct {
	URL              string `json:"url,omitempty"`
	CreatedAt        string `json:"created_at,omitempty"`
	ExtensionVersion string `json:"extension_version,omitempty"`
	SchemaVersion    int    `json:"schema_version,omitempty"`
	TotalSize        int64  `json:"total_size,omitempty"`
	FirstPinFeedback string `json:"first_pin_feedback,omitempty"`
	FirstPinURL      string `json:"first_pin_url,omitempty"`
}

ReportMetadata is local-only report metadata supplied by the extension.

type SessionSummary

type SessionSummary struct {
	ID               string `json:"id"`
	URL              string `json:"url"`
	Status           string `json:"status"`
	PinCount         int    `json:"pin_count"`
	FirstPinFeedback string `json:"first_pin_feedback"`
	UpdatedAt        string `json:"updated_at"`
	CreatedAt        string `json:"created_at"`
	ReportPath       string `json:"report_path"`
	TotalSize        int64  `json:"total_size"`
}

SessionSummary is a compact local session row.

type Store

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

Store is the local report store used by native-host and MCP.

func Open

func Open(root string) (*Store, error)

Open opens or initializes the local report store.

func (*Store) BeginReport

func (s *Store) BeginReport(ctx context.Context, metadata ReportMetadata) (*Report, error)

BeginReport creates a new temporary report.

func (*Store) Close

func (s *Store) Close() error

Close closes the local index.

func (*Store) DeleteSession

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

DeleteSession removes a local report directory and index rows.

func (*Store) GetPin

func (s *Store) GetPin(ctx context.Context, id string, number int, fields []string) (map[string]any, error)

GetPin reads a local pin and returns file path envelopes for heavy assets.

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, id string) (map[string]any, error)

GetSession reads a local session.json and stamps the local report id.

func (*Store) GetSessionSummary

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

GetSessionSummary returns indexed local session metadata, including the report path.

func (*Store) LatestSession

func (s *Store) LatestSession(ctx context.Context) (SessionSummary, error)

LatestSession returns the newest committed local session.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context, opts ListOptions) (ListResponse, error)

ListSessions returns newest committed local sessions first.

func (*Store) Pragmas

func (s *Store) Pragmas(ctx context.Context) (Pragmas, error)

Pragmas returns the SQLite journal and synchronous settings.

func (*Store) Prune

func (s *Store) Prune(ctx context.Context, opts PruneOptions) (int, error)

Prune removes sessions older than the supplied retention duration.

func (*Store) Root

func (s *Store) Root() string

Root returns the local store root.

func (*Store) SearchPins

func (s *Store) SearchPins(ctx context.Context, query string, limit int) (PinSearchResponse, error)

SearchPins searches local pin feedback and URLs.

func (*Store) SearchSessions

func (s *Store) SearchSessions(ctx context.Context, query string, limit int) (ListResponse, error)

SearchSessions searches local sessions by URL, id, and first pin feedback.

Jump to

Keyboard shortcuts

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