store

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package store implements the persistent memory engine for Engram.

It uses SQLite with FTS5 full-text search to store and retrieve observations from AI coding sessions. This is the core of Engram — everything else (HTTP server, MCP server, CLI, plugins) talks to this.

Index

Constants

View Source
const (
	DefaultSyncTargetKey = "cloud"
	LocalChunkTargetKey  = "local"

	SyncLifecycleIdle     = "idle"
	SyncLifecyclePending  = "pending"
	SyncLifecycleRunning  = "running"
	SyncLifecycleHealthy  = "healthy"
	SyncLifecycleDegraded = "degraded"

	SyncEntitySession     = "session"
	SyncEntityObservation = "observation"
	SyncEntityPrompt      = "prompt"

	SyncOpUpsert = "upsert"
	SyncOpDelete = "delete"

	SyncSourceLocal  = "local"
	SyncSourceRemote = "remote"
)
View Source
const (
	UpgradeStagePlanned           = "planned"
	UpgradeStageDoctorReady       = "doctor_ready"
	UpgradeStageDoctorBlocked     = "doctor_blocked"
	UpgradeStageRepairApplied     = "repair_applied"
	UpgradeStageBootstrapEnrolled = "bootstrap_enrolled"
	UpgradeStageBootstrapPushed   = "bootstrap_pushed"
	UpgradeStageBootstrapVerified = "bootstrap_verified"
	UpgradeStageRolledBack        = "rolled_back"

	UpgradeRepairClassNone       = "none"
	UpgradeRepairClassReady      = "ready"
	UpgradeRepairClassRepairable = "repairable"
	UpgradeRepairClassBlocked    = "blocked"
	UpgradeRepairClassPolicy     = "policy"
)
View Source
const (
	UpgradeReasonRepairableLegacyMutationPayload = "upgrade_repairable_legacy_mutation_payload"
	UpgradeReasonBlockedLegacyMutationManual     = "upgrade_blocked_legacy_mutation_manual"
)

Variables

View Source
var (
	ErrSessionNotFound        = errors.New("session not found")
	ErrSessionHasObservations = errors.New("session still has observations")
	ErrSessionDeleteBlocked   = errors.New("session deletion is blocked while cloud sync enrollment is active")
	ErrObservationNotFound    = errors.New("observation not found")
	ErrPromptNotFound         = errors.New("prompt not found")
)

Sentinel errors returned by delete operations so callers can use errors.Is.

Functions

func ClassifyTool

func ClassifyTool(toolName string) string

ClassifyTool returns the observation type for a given tool name.

func ExtractLearnings

func ExtractLearnings(text string) []string

ExtractLearnings parses structured learning items from text. It looks for sections like "## Key Learnings:" or "## Aprendizajes Clave:" and extracts numbered (1. text) or bullet (- text) items. Returns learnings from the LAST matching section (most recent output).

func NormalizeProject added in v1.11.0

func NormalizeProject(project string) (normalized string, warning string)

NormalizeProject applies canonical project name normalization: lowercase + trim whitespace + collapse consecutive hyphens/underscores. Returns the normalized name and a warning message if the name was changed (empty string if no change was needed). Exported so MCP and CLI handlers can surface the warning to users.

func Now

func Now() string

Now returns the current time formatted for SQLite.

func SuggestTopicKey

func SuggestTopicKey(typ, title, content string) string

SuggestTopicKey generates a stable topic key suggestion from type/title/content. It infers a topic family (e.g. architecture/*, bug/*) and then appends a normalized segment from title/content for stable cross-session keys.

Types

type AddObservationParams

type AddObservationParams struct {
	SessionID string `json:"session_id"`
	Type      string `json:"type"`
	Title     string `json:"title"`
	Content   string `json:"content"`
	ToolName  string `json:"tool_name,omitempty"`
	Project   string `json:"project,omitempty"`
	Scope     string `json:"scope,omitempty"`
	TopicKey  string `json:"topic_key,omitempty"`
}

type AddPromptParams

type AddPromptParams struct {
	SessionID string `json:"session_id"`
	Content   string `json:"content"`
	Project   string `json:"project,omitempty"`
}

type CloudUpgradeLegacyMutationFinding added in v1.13.0

type CloudUpgradeLegacyMutationFinding struct {
	Seq        int64  `json:"seq"`
	Entity     string `json:"entity"`
	Op         string `json:"op"`
	ReasonCode string `json:"reason_code"`
	Message    string `json:"message"`
	Repairable bool   `json:"repairable"`
	RepairHint string `json:"repair_hint,omitempty"`
	EntityKey  string `json:"entity_key,omitempty"`
	TargetKey  string `json:"target_key,omitempty"`
	Project    string `json:"project,omitempty"`
}

type CloudUpgradeLegacyMutationReport added in v1.13.0

type CloudUpgradeLegacyMutationReport struct {
	Project         string                              `json:"project"`
	RepairableCount int                                 `json:"repairable_count"`
	BlockedCount    int                                 `json:"blocked_count"`
	Findings        []CloudUpgradeLegacyMutationFinding `json:"findings,omitempty"`
}

type CloudUpgradeRepairReport added in v1.13.0

type CloudUpgradeRepairReport struct {
	Class         string `json:"class"`
	ReasonCode    string `json:"reason_code"`
	Message       string `json:"message"`
	PlannedAction string `json:"planned_action,omitempty"`
	Applied       bool   `json:"applied"`
}

type CloudUpgradeSnapshot added in v1.13.0

type CloudUpgradeSnapshot struct {
	CloudConfigPresent bool   `json:"cloud_config_present"`
	CloudConfigJSON    string `json:"cloud_config_json,omitempty"`
	ProjectEnrolled    bool   `json:"project_enrolled"`
}

type CloudUpgradeState added in v1.13.0

type CloudUpgradeState struct {
	Project          string               `json:"project"`
	Stage            string               `json:"stage"`
	RepairClass      string               `json:"repair_class"`
	Snapshot         CloudUpgradeSnapshot `json:"snapshot"`
	LastErrorCode    string               `json:"last_error_code,omitempty"`
	LastErrorMessage string               `json:"last_error_message,omitempty"`
	FindingsJSON     string               `json:"findings_json,omitempty"`
	AppliedActions   string               `json:"applied_actions,omitempty"`
	UpdatedAt        string               `json:"updated_at"`
}

type Config

type Config struct {
	DataDir              string
	MaxObservationLength int
	MaxContextResults    int
	MaxSearchResults     int
	DedupeWindow         time.Duration
}

func DefaultConfig

func DefaultConfig() (Config, error)

func FallbackConfig added in v1.9.3

func FallbackConfig(dataDir string) Config

FallbackConfig returns a Config with the given DataDir and default values. Use this when DefaultConfig fails and you have resolved the home directory through alternative means.

type EnrolledProject added in v1.8.0

type EnrolledProject struct {
	Project    string `json:"project"`
	EnrolledAt string `json:"enrolled_at"`
}

EnrolledProject represents a project enrolled for cloud sync.

type ExportData

type ExportData struct {
	Version      string        `json:"version"`
	ExportedAt   string        `json:"exported_at"`
	Sessions     []Session     `json:"sessions"`
	Observations []Observation `json:"observations"`
	Prompts      []Prompt      `json:"prompts"`
}

ExportData is the full serializable dump of the engram database.

type ImportResult

type ImportResult struct {
	SessionsImported     int `json:"sessions_imported"`
	ObservationsImported int `json:"observations_imported"`
	PromptsImported      int `json:"prompts_imported"`
}

type MergeResult added in v1.11.0

type MergeResult struct {
	Canonical           string   `json:"canonical"`
	SourcesMerged       []string `json:"sources_merged"`
	ObservationsUpdated int64    `json:"observations_updated"`
	SessionsUpdated     int64    `json:"sessions_updated"`
	PromptsUpdated      int64    `json:"prompts_updated"`
}

MergeResult summarizes the result of merging multiple project name variants into a single canonical project name.

type MigrateResult added in v1.10.0

type MigrateResult struct {
	Migrated            bool  `json:"migrated"`
	ObservationsUpdated int64 `json:"observations_updated"`
	SessionsUpdated     int64 `json:"sessions_updated"`
	PromptsUpdated      int64 `json:"prompts_updated"`
}

type Observation

type Observation struct {
	ID             int64   `json:"id"`
	SyncID         string  `json:"sync_id"`
	SessionID      string  `json:"session_id"`
	Type           string  `json:"type"`
	Title          string  `json:"title"`
	Content        string  `json:"content"`
	ToolName       *string `json:"tool_name,omitempty"`
	Project        *string `json:"project,omitempty"`
	Scope          string  `json:"scope"`
	TopicKey       *string `json:"topic_key,omitempty"`
	RevisionCount  int     `json:"revision_count"`
	DuplicateCount int     `json:"duplicate_count"`
	LastSeenAt     *string `json:"last_seen_at,omitempty"`
	CreatedAt      string  `json:"created_at"`
	UpdatedAt      string  `json:"updated_at"`
	DeletedAt      *string `json:"deleted_at,omitempty"`
}

type PassiveCaptureParams

type PassiveCaptureParams struct {
	SessionID string `json:"session_id"`
	Content   string `json:"content"`
	Project   string `json:"project,omitempty"`
	Source    string `json:"source,omitempty"` // e.g. "subagent-stop", "session-end"
}

PassiveCaptureParams holds the input for passive memory capture.

type PassiveCaptureResult

type PassiveCaptureResult struct {
	Extracted  int `json:"extracted"`  // Total learnings found in text
	Saved      int `json:"saved"`      // New observations created
	Duplicates int `json:"duplicates"` // Skipped because already existed
}

PassiveCaptureResult holds the output of passive memory capture.

type ProjectNameCount added in v1.11.0

type ProjectNameCount struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

ProjectNameCount holds a project name and how many observations it has.

type ProjectStats added in v1.11.0

type ProjectStats struct {
	Name             string   `json:"name"`
	ObservationCount int      `json:"observation_count"`
	SessionCount     int      `json:"session_count"`
	PromptCount      int      `json:"prompt_count"`
	Directories      []string `json:"directories"` // unique directories from sessions
}

ProjectStats holds aggregate statistics for a single project.

type Prompt

type Prompt struct {
	ID        int64  `json:"id"`
	SyncID    string `json:"sync_id"`
	SessionID string `json:"session_id"`
	Content   string `json:"content"`
	Project   string `json:"project,omitempty"`
	CreatedAt string `json:"created_at"`
}

type PruneResult added in v1.11.0

type PruneResult struct {
	Project         string `json:"project"`
	SessionsDeleted int64  `json:"sessions_deleted"`
	PromptsDeleted  int64  `json:"prompts_deleted"`
}

PruneResult holds the outcome of pruning a single project.

type SearchOptions

type SearchOptions struct {
	Type    string `json:"type,omitempty"`
	Project string `json:"project,omitempty"`
	Scope   string `json:"scope,omitempty"`
	Limit   int    `json:"limit,omitempty"`
}

type SearchResult

type SearchResult struct {
	Observation
	Rank float64 `json:"rank"`
}

type Session

type Session struct {
	ID        string  `json:"id"`
	Project   string  `json:"project"`
	Directory string  `json:"directory"`
	StartedAt string  `json:"started_at"`
	EndedAt   *string `json:"ended_at,omitempty"`
	Summary   *string `json:"summary,omitempty"`
}

type SessionSummary

type SessionSummary struct {
	ID               string  `json:"id"`
	Project          string  `json:"project"`
	StartedAt        string  `json:"started_at"`
	EndedAt          *string `json:"ended_at,omitempty"`
	Summary          *string `json:"summary,omitempty"`
	ObservationCount int     `json:"observation_count"`
}

type Stats

type Stats struct {
	TotalSessions     int      `json:"total_sessions"`
	TotalObservations int      `json:"total_observations"`
	TotalPrompts      int      `json:"total_prompts"`
	Projects          []string `json:"projects"`
}

type Store

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

func New

func New(cfg Config) (*Store, error)

func (*Store) AckSyncMutationSeqs added in v1.8.0

func (s *Store) AckSyncMutationSeqs(targetKey string, seqs []int64) error

AckSyncMutationSeqs acknowledges specific mutation sequence numbers without requiring them to be contiguous.

func (*Store) AckSyncMutations added in v1.8.0

func (s *Store) AckSyncMutations(targetKey string, lastAckedSeq int64) error

func (*Store) AcquireSyncLease added in v1.8.0

func (s *Store) AcquireSyncLease(targetKey, owner string, ttl time.Duration, now time.Time) (bool, error)

func (*Store) AddObservation

func (s *Store) AddObservation(p AddObservationParams) (int64, error)

func (*Store) AddPrompt

func (s *Store) AddPrompt(p AddPromptParams) (int64, error)

func (*Store) AllObservations

func (s *Store) AllObservations(project, scope string, limit int) ([]Observation, error)

AllObservations returns recent observations ordered by most recent first (for TUI browsing).

func (*Store) AllSessions

func (s *Store) AllSessions(project string, limit int) ([]SessionSummary, error)

AllSessions returns recent sessions ordered by most recent first (for TUI browsing).

func (*Store) ApplyPulledChunk added in v1.13.0

func (s *Store) ApplyPulledChunk(targetKey, chunkID string, mutations []SyncMutation) error

ApplyPulledChunk atomically applies all mutations contained in a pulled chunk and records the chunk as synced in the same transaction. This guarantees retry safety: a failed chunk import leaves no partial semantic mutations.

func (*Store) ApplyPulledMutation added in v1.8.0

func (s *Store) ApplyPulledMutation(targetKey string, mutation SyncMutation) error

func (*Store) CanRollbackCloudUpgrade added in v1.13.0

func (s *Store) CanRollbackCloudUpgrade(project string) (bool, error)

func (*Store) ClearCloudUpgradeState added in v1.13.0

func (s *Store) ClearCloudUpgradeState(project string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CountObservationsForProject added in v1.11.0

func (s *Store) CountObservationsForProject(name string) (int, error)

CountObservationsForProject returns the number of non-deleted observations for the given project name. Used by handleSave for the similar-project warning instead of the heavier ListProjectsWithStats.

func (*Store) CreateSession

func (s *Store) CreateSession(id, project, directory string) error

func (*Store) DeleteObservation

func (s *Store) DeleteObservation(id int64, hardDelete bool) error

func (*Store) DeletePrompt added in v1.12.0

func (s *Store) DeletePrompt(id int64) error

DeletePrompt hard-deletes a single prompt by ID and records a sync tombstone. It returns ErrPromptNotFound if no prompt with that ID exists.

func (*Store) DeleteSession added in v1.12.0

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

DeleteSession hard-deletes a session and its prompts. It returns ErrSessionHasObservations if the session has any observations (including soft-deleted ones) to prevent orphaned rows. It returns ErrSessionDeleteBlocked when the session's project is currently enrolled for cloud sync, to avoid local-only deletes diverging from cloud state. It returns ErrSessionNotFound if no session with that ID exists.

Note: this delete only removes local rows. It does not enqueue a delete sync mutation, but any previously enqueued mutations for the session or its prompts may still be synced later if autosync is enabled, and a later pull may recreate the deleted rows locally.

func (*Store) DiagnoseCloudUpgradeLegacyMutations added in v1.13.0

func (s *Store) DiagnoseCloudUpgradeLegacyMutations(project string) (CloudUpgradeLegacyMutationReport, error)

func (*Store) EndSession

func (s *Store) EndSession(id string, summary string) error

func (*Store) EnrollProject added in v1.8.0

func (s *Store) EnrollProject(project string) error

EnrollProject registers a project for cloud sync. Idempotent — re-enrolling an already-enrolled project is a no-op.

func (*Store) Export

func (s *Store) Export() (*ExportData, error)

func (*Store) ExportProject added in v1.13.0

func (s *Store) ExportProject(project string) (*ExportData, error)

ExportProject returns an export restricted to records relevant to a single normalized project. This avoids full-database exports when only one project needs to sync.

func (*Store) FormatContext

func (s *Store) FormatContext(project, scope string) (string, error)

func (*Store) GetCloudUpgradeState added in v1.13.0

func (s *Store) GetCloudUpgradeState(project string) (*CloudUpgradeState, error)

func (*Store) GetObservation

func (s *Store) GetObservation(id int64) (*Observation, error)

func (*Store) GetObservationBySyncID added in v1.8.0

func (s *Store) GetObservationBySyncID(syncID string) (*Observation, error)

func (*Store) GetSession

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

func (*Store) GetSyncState added in v1.8.0

func (s *Store) GetSyncState(targetKey string) (*SyncState, error)

func (*Store) GetSyncedChunks

func (s *Store) GetSyncedChunks() (map[string]bool, error)

GetSyncedChunks returns local-target chunk IDs for backwards compatibility.

func (*Store) GetSyncedChunksForTarget added in v1.13.0

func (s *Store) GetSyncedChunksForTarget(targetKey string) (map[string]bool, error)

GetSyncedChunksForTarget returns chunk IDs tracked for a specific sync target.

func (*Store) HasPendingSyncMutationsForProject added in v1.13.0

func (s *Store) HasPendingSyncMutationsForProject(project string) (bool, error)

func (*Store) Import

func (s *Store) Import(data *ExportData) (*ImportResult, error)

func (*Store) IsProjectEnrolled added in v1.8.0

func (s *Store) IsProjectEnrolled(project string) (bool, error)

IsProjectEnrolled returns true if the given project is enrolled for cloud sync.

func (*Store) ListEnrolledProjects added in v1.8.0

func (s *Store) ListEnrolledProjects() ([]EnrolledProject, error)

ListEnrolledProjects returns all projects currently enrolled for cloud sync, ordered alphabetically by project name.

func (*Store) ListPendingSyncMutations added in v1.8.0

func (s *Store) ListPendingSyncMutations(targetKey string, limit int) ([]SyncMutation, error)

func (*Store) ListPendingSyncMutationsAfterSeq added in v1.13.0

func (s *Store) ListPendingSyncMutationsAfterSeq(targetKey string, afterSeq int64, limit int) ([]SyncMutation, error)

func (*Store) ListProjectNames added in v1.11.0

func (s *Store) ListProjectNames() ([]string, error)

ListProjectNames returns all distinct project names from observations, ordered alphabetically. Used for fuzzy matching and consolidation.

func (*Store) ListProjectsWithStats added in v1.11.0

func (s *Store) ListProjectsWithStats() ([]ProjectStats, error)

ListProjectsWithStats returns all projects with aggregated counts. Ordered by observation count descending.

func (*Store) MarkSyncAuthRequired added in v1.13.0

func (s *Store) MarkSyncAuthRequired(targetKey, message string) error

func (*Store) MarkSyncBlocked added in v1.13.0

func (s *Store) MarkSyncBlocked(targetKey, reasonCode, message string) error

func (*Store) MarkSyncFailure added in v1.8.0

func (s *Store) MarkSyncFailure(targetKey, message string, backoffUntil time.Time) error

func (*Store) MarkSyncHealthy added in v1.8.0

func (s *Store) MarkSyncHealthy(targetKey string) error

func (*Store) MarkSyncPaused added in v1.13.0

func (s *Store) MarkSyncPaused(targetKey, message string) error

func (*Store) MarkSyncPending added in v1.13.0

func (s *Store) MarkSyncPending(targetKey string) error

func (*Store) MaxObservationLength added in v1.8.1

func (s *Store) MaxObservationLength() int

MaxObservationLength returns the configured maximum content length for observations.

func (*Store) MergeProjects added in v1.11.0

func (s *Store) MergeProjects(sources []string, canonical string) (*MergeResult, error)

MergeProjects migrates all records from each source project name into the canonical name. Sources that equal the canonical (after normalization) or have no records are silently skipped — the operation is idempotent. All updates are performed inside a single transaction for atomicity.

func (*Store) MigrateProject added in v1.10.0

func (s *Store) MigrateProject(oldName, newName string) (*MigrateResult, error)

func (*Store) PassiveCapture

func (s *Store) PassiveCapture(p PassiveCaptureParams) (*PassiveCaptureResult, error)

PassiveCapture extracts learnings from text and saves them as observations. It deduplicates against existing observations using content hash matching.

func (*Store) ProjectExists added in v1.13.0

func (s *Store) ProjectExists(name string) (bool, error)

ProjectExists returns true if the named project has at least one record in any of observations, sessions, prompts, or enrollment tables. Uses a single UNION ALL LIMIT 1 query for efficiency (REQ-315). The sync_enrolled_projects branch ensures a project enrolled via EnrollProject() without any other data is still recognized (JC1).

func (*Store) PruneProject added in v1.11.0

func (s *Store) PruneProject(project string) (*PruneResult, error)

PruneProject removes all sessions and prompts for a project that has zero (non-deleted) observations. Returns an error if the project still has observations — the caller must verify first.

func (*Store) RecentObservations

func (s *Store) RecentObservations(project, scope string, limit int) ([]Observation, error)

func (*Store) RecentPrompts

func (s *Store) RecentPrompts(project string, limit int) ([]Prompt, error)

func (*Store) RecentSessions

func (s *Store) RecentSessions(project string, limit int) ([]SessionSummary, error)

func (*Store) RecordSyncedChunk

func (s *Store) RecordSyncedChunk(chunkID string) error

RecordSyncedChunk marks a local-target chunk as imported/exported.

func (*Store) RecordSyncedChunkForTarget added in v1.13.0

func (s *Store) RecordSyncedChunkForTarget(targetKey, chunkID string) error

RecordSyncedChunkForTarget marks a chunk as imported/exported for a target.

func (*Store) ReleaseSyncLease added in v1.8.0

func (s *Store) ReleaseSyncLease(targetKey, owner string) error

func (*Store) RepairCloudUpgrade added in v1.13.0

func (s *Store) RepairCloudUpgrade(project string, apply bool) (CloudUpgradeRepairReport, error)

func (*Store) RollbackCloudUpgrade added in v1.13.0

func (s *Store) RollbackCloudUpgrade(project string) (CloudUpgradeState, error)

func (*Store) SaveCloudUpgradeState added in v1.13.0

func (s *Store) SaveCloudUpgradeState(state CloudUpgradeState) error

func (*Store) Search

func (s *Store) Search(query string, opts SearchOptions) ([]SearchResult, error)

func (*Store) SearchPrompts

func (s *Store) SearchPrompts(query string, project string, limit int) ([]Prompt, error)

func (*Store) SessionObservations

func (s *Store) SessionObservations(sessionID string, limit int) ([]Observation, error)

SessionObservations returns all observations for a specific session.

func (*Store) SkipAckNonEnrolledMutations added in v1.8.0

func (s *Store) SkipAckNonEnrolledMutations(targetKey string) (int64, error)

SkipAckNonEnrolledMutations acks (marks as skipped) all pending mutations that belong to non-enrolled projects, preventing journal bloat. Empty-project mutations are never skipped — they always sync regardless of enrollment.

func (*Store) Stats

func (s *Store) Stats() (*Stats, error)

func (*Store) Timeline

func (s *Store) Timeline(observationID int64, before, after int) (*TimelineResult, error)

func (*Store) UnenrollProject added in v1.8.0

func (s *Store) UnenrollProject(project string) error

UnenrollProject removes a project from cloud sync enrollment. Idempotent — unenrolling a non-enrolled project is a no-op.

func (*Store) UpdateObservation

func (s *Store) UpdateObservation(id int64, p UpdateObservationParams) (*Observation, error)

type SyncMutation added in v1.8.0

type SyncMutation struct {
	Seq        int64   `json:"seq"`
	TargetKey  string  `json:"target_key"`
	Entity     string  `json:"entity"`
	EntityKey  string  `json:"entity_key"`
	Op         string  `json:"op"`
	Payload    string  `json:"payload"`
	Source     string  `json:"source"`
	Project    string  `json:"project"`
	OccurredAt string  `json:"occurred_at"`
	AckedAt    *string `json:"acked_at,omitempty"`
}

type SyncState added in v1.8.0

type SyncState struct {
	TargetKey           string  `json:"target_key"`
	Lifecycle           string  `json:"lifecycle"`
	LastEnqueuedSeq     int64   `json:"last_enqueued_seq"`
	LastAckedSeq        int64   `json:"last_acked_seq"`
	LastPulledSeq       int64   `json:"last_pulled_seq"`
	ConsecutiveFailures int     `json:"consecutive_failures"`
	BackoffUntil        *string `json:"backoff_until,omitempty"`
	LeaseOwner          *string `json:"lease_owner,omitempty"`
	LeaseUntil          *string `json:"lease_until,omitempty"`
	ReasonCode          *string `json:"reason_code,omitempty"`
	ReasonMessage       *string `json:"reason_message,omitempty"`
	LastError           *string `json:"last_error,omitempty"`
	UpdatedAt           string  `json:"updated_at"`
}

type TimelineEntry

type TimelineEntry struct {
	ID             int64   `json:"id"`
	SessionID      string  `json:"session_id"`
	Type           string  `json:"type"`
	Title          string  `json:"title"`
	Content        string  `json:"content"`
	ToolName       *string `json:"tool_name,omitempty"`
	Project        *string `json:"project,omitempty"`
	Scope          string  `json:"scope"`
	TopicKey       *string `json:"topic_key,omitempty"`
	RevisionCount  int     `json:"revision_count"`
	DuplicateCount int     `json:"duplicate_count"`
	LastSeenAt     *string `json:"last_seen_at,omitempty"`
	CreatedAt      string  `json:"created_at"`
	UpdatedAt      string  `json:"updated_at"`
	DeletedAt      *string `json:"deleted_at,omitempty"`
	IsFocus        bool    `json:"is_focus"` // true for the anchor observation
}

type TimelineResult

type TimelineResult struct {
	Focus        Observation     `json:"focus"`        // The anchor observation
	Before       []TimelineEntry `json:"before"`       // Observations before the focus (chronological)
	After        []TimelineEntry `json:"after"`        // Observations after the focus (chronological)
	SessionInfo  *Session        `json:"session_info"` // Session that contains the focus observation
	TotalInRange int             `json:"total_in_range"`
}

type UpdateObservationParams

type UpdateObservationParams struct {
	Type     *string `json:"type,omitempty"`
	Title    *string `json:"title,omitempty"`
	Content  *string `json:"content,omitempty"`
	Project  *string `json:"project,omitempty"`
	Scope    *string `json:"scope,omitempty"`
	TopicKey *string `json:"topic_key,omitempty"`
}

Jump to

Keyboard shortcuts

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