session

package
v0.32.42 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultKeepRecentMessages = 20
	MinKeepRecentMessages     = 5
	MaxKeepRecentMessages     = 200
	DefaultKeepRecentTokens   = 12000
	MinKeepRecentTokens       = 1
	MaxKeepRecentTokens       = 64000
	DefaultKeepRecentFraction = 0.30
	MinKeepRecentFraction     = 0.05
	MaxKeepRecentFraction     = 0.90
)
View Source
const (
	SessionGoalStatusActive    = "active"
	SessionGoalStatusSatisfied = "satisfied"
	SessionGoalStatusExhausted = "exhausted"

	DefaultGoalMaxAutoContinues = 3
	MaxGoalMaxAutoContinues     = 20
	MaxGoalDescriptionLen       = 2000
)

Session goal status values.

View Source
const (
	DefaultAutoResumeAfterMinutes = 30

	AutoResumeModeProceedWithAssumption      = "proceed_with_assumption"
	AutoResumeModeMoveToNextTask             = "move_to_next_task"
	AutoResumeModeRecordAssumptionAndProceed = "record_assumption_and_proceed"
)
View Source
const (
	SessionCriticStatusIdle      = "idle"
	SessionCriticStatusReviewing = "reviewing"
	SessionCriticStatusSatisfied = "satisfied"
	SessionCriticStatusExhausted = "exhausted"

	// DefaultCriticMaxIterations is the default per-plan-transition review
	// budget. Three rounds matches the goal-judge default and is the value
	// users see in the wizard prose.
	DefaultCriticMaxIterations = 3
	// MaxCriticMaxIterations caps the configurable budget. Five is generous
	// for a single plan transition; anything higher tends to be a runaway
	// rather than productive critique.
	MaxCriticMaxIterations = 5
	// MaxCriticFeedbackLen bounds the feedback string we persist so the
	// transcript JSON does not balloon when a reviewer emits a very long
	// bullet list.
	MaxCriticFeedbackLen = 4000
)

SessionCritic status values.

View Source
const (
	DefaultAutoContinueMaxIterations = 5
	AutoContinueIterationsHardCap    = 10
	AutoContinueIterationWindow      = 24 * time.Hour
)

Auto-continue iteration limits. The hard upper bound is enforced regardless of per-plan overrides, and the rolling window is the period over which audit-log entries are counted toward the cap.

View Source
const (
	PlanStatusDrafting  = "drafting"
	PlanStatusProposed  = "proposed"
	PlanStatusExecuting = "executing"
	PlanStatusPaused    = "paused"
	PlanStatusCompleted = "completed"
	PlanStatusAborted   = "aborted"
)

Plan status constants — enumerate the states a plan can be in.

View Source
const (
	ContractStatusDraft    = "draft"
	ContractStatusApproved = "approved"
)
View Source
const (
	EvidenceTypeTestResult           = "test_result"
	EvidenceTypeImage                = "image"
	EvidenceTypeLogExcerpt           = "log_excerpt"
	EvidenceTypePRLink               = "pr_link"
	EvidenceTypeReleaseTag           = "release_tag"
	EvidenceTypeCommandOutputSummary = "command_output_summary"
)
View Source
const (
	// TasksInjectionHeader marks task state that was deliberately reinserted
	// after context compression so later compactions can replace stale copies.
	TasksInjectionHeader = "## Active Plan (preserved across compression)"
)

Variables

View Source
var ErrCwdNotEligible = errors.New("session: cwd not in eligible work_dirs")

ErrCwdNotEligible is returned by SetCurrentDir when the supplied directory is not present in the session's normalized work_dirs (i.e. neither the artifact dir nor any user-registered work_dir).

View Source
var ErrSessionKindUnsupported = errors.New("session: kind does not support goals")

ErrSessionKindUnsupported is returned by goal mutations when the session kind does not permit a goal (currently only "main" kind sessions support goals).

View Source
var ErrSessionNotFound = errors.New("session not found")

ErrSessionNotFound is returned when a session ID does not resolve to an entry in the index. The message is intentionally kept stable for callers that match on the substring "session not found".

Functions

func AppendMessage

func AppendMessage(path string, msg Message) error

AppendMessage appends a single message as one JSON line to the JSONL file at path.

func ArchiveSummary added in v0.20.0

func ArchiveSummary(st SessionTasks) string

ArchiveSummary returns a human-readable summary of the plan and tasks for memory archival.

func BuildCompactionSummary

func BuildCompactionSummary(messages []Message) string

func BuildCompactionSummaryWithOptions added in v0.10.2

func BuildCompactionSummaryWithOptions(messages []Message, opts CompactionSummaryOptions) string

func EstimateMessageTokenCost added in v0.27.0

func EstimateMessageTokenCost(msg Message) int

EstimateMessageTokenCost is the exported wrapper for single-message token estimation.

func EstimateTokens

func EstimateTokens(messages []Message) int

func EvidenceTypeLabel added in v0.31.100

func EvidenceTypeLabel(kind string) string

func FormatTasksForInjection added in v0.20.0

func FormatTasksForInjection(st SessionTasks) string

FormatTasksForInjection renders active tasks for system prompt injection after context compression. Only includes pending and in_progress tasks.

func IsTasksInjectionMessage added in v0.31.16

func IsTasksInjectionMessage(msg Message) bool

IsTasksInjectionMessage reports whether msg is a previously injected active plan block. Compaction replaces these blocks with fresh task state.

func NextEvidenceID added in v0.31.100

func NextEvidenceID(tasks []Task) string

func NextTaskID added in v0.20.0

func NextTaskID(tasks []Task) string

NextTaskID returns the next sequential task ID based on existing tasks.

func NormalizeAutoResumeModes added in v0.31.114

func NormalizeAutoResumeModes(values []string) []string

func NowRFC3339 added in v0.20.0

func NowRFC3339() string

NowRFC3339 returns current time in RFC3339 format.

func RewriteMessages

func RewriteMessages(path string, messages []Message) error

RewriteMessages replaces the transcript contents with the provided messages.

func TaskSummary added in v0.20.0

func TaskSummary(tasks []Task) map[string]int

TaskSummary returns a compact summary of task statuses.

func ValidEvidenceType added in v0.31.100

func ValidEvidenceType(kind string) bool

func ValidPlanStatus added in v0.31.10

func ValidPlanStatus(s string) bool

ValidPlanStatus reports whether s is a recognized plan status.

func ValidTaskStatus added in v0.20.0

func ValidTaskStatus(status string) bool

ValidTaskStatus checks if a status string is valid.

Types

type CompactOptions

type CompactOptions struct {
	BeforeRewrite       func(summary string, compactedCount int, originalCount int) error
	SummaryBuilder      func(messages []Message, previousContext string) (string, error)
	PostSummaryMessages []Message
	KeepRecentTokens    int
	KeepRecentFraction  float64
	SummaryInstructions string
	// PreloadedMessages supplies already-read messages to avoid a second ReadMessages
	// call on the same path. When set, ReadMessages is skipped, preventing a
	// reentrant-lock deadlock when the caller already holds the path lock.
	PreloadedMessages []Message
}

CompactOptions configures CompactTranscriptWithOptions.

KeepRecent strategies are tried in priority order — the first non-zero option wins, lower options are ignored:

  1. KeepRecentFraction (if > 0): retain the most recent X% of total transcript tokens (clamped to MinKeepRecentFraction..MaxKeepRecentFraction).
  2. KeepRecentTokens (if > 0): retain a specific token budget (clamped to MinKeepRecentTokens..MaxKeepRecentTokens).
  3. keepRecent positional argument: retain a specific message count (clamped to MinKeepRecentMessages..MaxKeepRecentMessages, default DefaultKeepRecentMessages = 20).

Setting both KeepRecentFraction and KeepRecentTokens is supported but the fraction wins — set only the strategy you want.

type CompactResult

type CompactResult struct {
	Compacted      bool
	OriginalCount  int
	FinalCount     int
	CompactedCount int
	Summary        string
}

func CompactTranscript

func CompactTranscript(path string, keepRecent int, now time.Time) (CompactResult, error)

func CompactTranscriptWithOptions

func CompactTranscriptWithOptions(path string, keepRecent int, now time.Time, opts CompactOptions) (CompactResult, error)

type CompactionSummaryOptions added in v0.10.2

type CompactionSummaryOptions struct {
	FocusInstructions string
	PreviousContext   string
}

type ForkOptions added in v0.31.105

type ForkOptions struct {
	Title  string
	Reason string
}

ForkOptions controls how a child session is created from an existing transcript message.

type ForkPromotionCandidate added in v0.31.107

type ForkPromotionCandidate struct {
	ID                  string    `json:"id"`
	SessionID           string    `json:"session_id"`
	ParentSessionID     string    `json:"parent_session_id"`
	RootSessionID       string    `json:"root_session_id,omitempty"`
	ForkedFromMessageID string    `json:"forked_from_message_id,omitempty"`
	ForkedFromIndex     *int      `json:"forked_from_index,omitempty"`
	MessageID           string    `json:"message_id"`
	MessageIndex        int       `json:"message_index"`
	Role                string    `json:"role"`
	Category            string    `json:"category"`
	Summary             string    `json:"summary"`
	CreatedAt           time.Time `json:"created_at"`
}

ForkPromotionCandidate is a reviewable insight from a forked session that can be queued into Memory Inbox for explicit user approval.

func DetectForkPromotionCandidates added in v0.31.107

func DetectForkPromotionCandidates(sess Session, messages []Message, opts ForkPromotionOptions) []ForkPromotionCandidate

DetectForkPromotionCandidates extracts reusable post-fork insights without mutating any session transcript. It is intentionally deterministic so the UI can refresh and submit stable candidate IDs.

type ForkPromotionOptions added in v0.31.107

type ForkPromotionOptions struct {
	Now             time.Time
	MaxCandidates   int
	MaxSummaryRunes int
}

ForkPromotionOptions controls deterministic candidate extraction from a fork.

type HistorySnapshot

type HistorySnapshot struct {
	Messages       []Message
	Tokens         int
	CompactionUsed bool
}

HistorySnapshot captures the portion of transcript loaded into model context.

func LoadHistorySnapshot

func LoadHistorySnapshot(path string, maxTokens int) (HistorySnapshot, error)

LoadHistorySnapshot reads transcript history and returns the loaded messages together with token and compaction-boundary metadata.

type Message

type Message struct {
	ID          string    `json:"id,omitempty"`
	Role        string    `json:"role"`
	Content     string    `json:"content"`
	Timestamp   time.Time `json:"timestamp"`
	ToolName    string    `json:"tool_name,omitempty"`
	ToolCallID  string    `json:"tool_call_id,omitempty"`
	ToolArgs    string    `json:"tool_args,omitempty"`
	ToolIsError bool      `json:"tool_is_error,omitempty"`
}

Message represents a single chat message in a session transcript. Tool fields are optional (omitempty) for backward compatibility with existing transcripts.

func LoadHistory

func LoadHistory(path string, maxTokens int) ([]Message, error)

LoadHistory reads messages from a JSONL file, returning only the most recent messages that fit within the given token budget. Tokens are estimated as len(content)/4. Messages are returned in chronological order (oldest first). Returns an empty slice if the file does not exist.

func ReadMessages

func ReadMessages(path string) ([]Message, error)

ReadMessages reads all messages from a JSONL file. Returns an empty slice if the file does not exist or is empty.

type Plan added in v0.20.0

type Plan struct {
	Goal        string `json:"goal"`
	Constraints string `json:"constraints,omitempty"`
	CreatedAt   string `json:"created_at"`
	Status      string `json:"status,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`

	// AutoContinueEnabled, when true, lets pulse auto-continue this session
	// after the current plan completes — either by proposing a follow-up
	// plan or marking the goal achieved. The hard iteration cap is enforced
	// via the automation audit log (counting successful auto-continue turns
	// in a rolling window) so it survives plan replacement. Opt-in (default
	// false).
	AutoContinueEnabled bool `json:"auto_continue_enabled,omitempty"`

	// AutoContinueMaxIterations caps how many auto-continue turns may run
	// for this session in the rolling AutoContinueIterationWindow. Zero
	// means use DefaultAutoContinueMaxIterations.
	AutoContinueMaxIterations int `json:"auto_continue_max_iterations,omitempty"`
}

Plan represents a high-level goal for the current session. At most one plan is active per session; setting a new plan archives the previous one.

Status follows a small state machine:

drafting ──plan_propose──► proposed ──plan_approve──► executing
   ▲                                                     │
   │                                                     │ plan_pause
   │                                                     ▼
   │                                                  paused
   │                                                     │
   │ user edit                       plan_resume         │
   └────────────────────                 ◄───────────────┘

executing ─(all tasks completed/cancelled)──► completed
any (except completed/aborted) ──plan_abort──► aborted

Empty Status (legacy plans saved before this field existed) is treated as "executing" on load so existing sessions keep their prior behavior.

func (*Plan) EffectiveAutoContinueMaxIterations added in v0.31.145

func (p *Plan) EffectiveAutoContinueMaxIterations() int

EffectiveAutoContinueMaxIterations returns the cap that applies to this plan, clamping to the hard upper bound and falling back to the default when unset.

type Session

type Session struct {
	ID                  string                    `json:"id"`
	Title               string                    `json:"title"`
	Kind                string                    `json:"kind,omitempty"`
	Hidden              bool                      `json:"hidden,omitempty"`
	ParentSessionID     string                    `json:"parent_session_id,omitempty"`
	RootSessionID       string                    `json:"root_session_id,omitempty"`
	ForkedFromMessageID string                    `json:"forked_from_message_id,omitempty"`
	ForkedFromIndex     *int                      `json:"forked_from_index,omitempty"`
	ForkReason          string                    `json:"fork_reason,omitempty"`
	ToolConfig          *SessionToolConfig        `json:"tool_config,omitempty"`
	AutomationConsent   *SessionAutomationConsent `json:"automation_consent,omitempty"`
	StyleControl        *SessionStyleControl      `json:"style_control,omitempty"`
	LastCompactionMode  string                    `json:"last_compaction_mode,omitempty"`
	PromptOverride      string                    `json:"prompt_override,omitempty"`
	WorkDirs            []string                  `json:"work_dirs,omitempty"`
	CurrentDir          string                    `json:"current_dir,omitempty"`
	ArchivedAt          *time.Time                `json:"archived_at,omitempty"`
	PinnedAt            *time.Time                `json:"pinned_at,omitempty"`
	Goal                *SessionGoal              `json:"goal,omitempty"`
	Critic              *SessionCritic            `json:"critic,omitempty"`
	CreatedAt           time.Time                 `json:"created_at"`
	UpdatedAt           time.Time                 `json:"updated_at"`
}

type SessionAutomationConsent added in v0.31.108

type SessionAutomationConsent struct {
	AutoResume             bool       `json:"auto_resume,omitempty"`
	AutoResumeEnabled      bool       `json:"auto_resume_enabled,omitempty"`
	AutoResumeAfterMinutes int        `json:"auto_resume_after_minutes,omitempty"`
	AllowedResumeModes     []string   `json:"allowed_resume_modes,omitempty"`
	GitMutations           bool       `json:"git_mutations,omitempty"`
	AutonomousMutations    bool       `json:"autonomous_mutations,omitempty"`
	UpdatedAt              *time.Time `json:"updated_at,omitempty"`
}

func (*SessionAutomationConsent) AllowsAutoResume added in v0.31.114

func (c *SessionAutomationConsent) AllowsAutoResume() bool

func (*SessionAutomationConsent) AllowsAutonomousMutation added in v0.31.108

func (c *SessionAutomationConsent) AllowsAutonomousMutation() bool

func (*SessionAutomationConsent) EffectiveAllowedResumeModes added in v0.31.114

func (c *SessionAutomationConsent) EffectiveAllowedResumeModes() []string

func (*SessionAutomationConsent) EffectiveAutoResumeAfterMinutes added in v0.31.114

func (c *SessionAutomationConsent) EffectiveAutoResumeAfterMinutes() int

type SessionCritic added in v0.32.42

type SessionCritic struct {
	Enabled             bool       `json:"enabled"`
	MaxIterations       int        `json:"max_iterations,omitempty"`
	CurrentIteration    int        `json:"current_iteration,omitempty"`
	Status              string     `json:"status,omitempty"`
	LastFeedback        string     `json:"last_feedback,omitempty"`
	LastTrigger         string     `json:"last_trigger,omitempty"`
	LastReviewedPlanSig string     `json:"last_reviewed_plan_sig,omitempty"`
	UpdatedAt           *time.Time `json:"updated_at,omitempty"`
}

SessionCritic captures the per-session critic-agent configuration plus the runtime state for the active review cycle. The chat handler reads/writes this through Store.SetCritic / Store.UpdateCriticProgress, so all mutation paths share one normalization routine.

Lifecycle:

  • User toggles Enabled = true (status starts "idle", iteration 0).
  • On a plan transition (Proposed or Completed) the hook bumps CurrentIteration, sets Status = "reviewing", records LastTrigger and the plan signature used to dedupe a single transition.
  • When the reviewer returns Acceptable=true the hook sets Status = "satisfied" and resets CurrentIteration.
  • When CurrentIteration reaches MaxIterations without acceptance, the hook sets Status = "exhausted" and stops issuing feedback until the next plan transition.

func NormalizeCritic added in v0.32.42

func NormalizeCritic(c *SessionCritic) *SessionCritic

NormalizeCritic trims and clamps fields and defaults Status when unset. Returns nil when the input is nil so callers can store-or-clear with a single statement.

func (*SessionCritic) EffectiveMaxIterations added in v0.32.42

func (c *SessionCritic) EffectiveMaxIterations() int

EffectiveMaxIterations clamps the configured budget into [1, MaxCriticMaxIterations] and falls back to DefaultCriticMaxIterations on zero/negative input.

func (*SessionCritic) IsEnabled added in v0.32.42

func (c *SessionCritic) IsEnabled() bool

IsEnabled reports whether the critic agent should run for this session.

type SessionGoal added in v0.32.41

type SessionGoal struct {
	Description       string     `json:"description"`
	CreatedAt         time.Time  `json:"created_at"`
	MaxAutoContinues  int        `json:"max_auto_continues"`
	AutoContinueCount int        `json:"auto_continue_count"`
	LastJudgedAt      *time.Time `json:"last_judged_at,omitempty"`
	Status            string     `json:"status"`
}

SessionGoal captures a single active goal for a chat session. When set, the chat handler appends the goal to the system prompt and runs an independent judge LLM after each turn; if the judge says "not satisfied" the loop may auto-continue up to MaxAutoContinues times.

func NormalizeGoal added in v0.32.41

func NormalizeGoal(goal *SessionGoal) *SessionGoal

NormalizeGoal trims and clamps fields, defaulting status/max where unset. Returns nil when the description is empty (treated as "no goal").

func (*SessionGoal) IsActive added in v0.32.41

func (g *SessionGoal) IsActive() bool

IsActive reports whether the goal is in the active state and should be surfaced to the LLM / agent loop.

type SessionStyleControl added in v0.31.120

type SessionStyleControl struct {
	Directness *int       `json:"directness,omitempty"`
	Humor      *int       `json:"humor,omitempty"`
	Caution    *int       `json:"caution,omitempty"`
	Autonomy   *int       `json:"autonomy,omitempty"`
	UpdatedAt  *time.Time `json:"updated_at,omitempty"`
}

func NormalizeStyleControl added in v0.31.120

func NormalizeStyleControl(style *SessionStyleControl) *SessionStyleControl

type SessionTasks added in v0.20.0

type SessionTasks struct {
	Plan     *Plan         `json:"plan,omitempty"`
	Contract *TaskContract `json:"contract,omitempty"`
	Tasks    []Task        `json:"tasks"`
}

SessionTasks holds the current plan and its associated tasks for a session.

func (SessionTasks) MarshalJSON added in v0.23.0

func (st SessionTasks) MarshalJSON() ([]byte, error)

MarshalJSON keeps the API contract stable by always emitting tasks as an array.

type SessionToolConfig added in v0.16.0

type SessionToolConfig struct {
	ToolsEnabled     []string `json:"tools_enabled,omitempty"`
	ToolsCustom      bool     `json:"tools_custom,omitempty"`
	ToolsDisabled    []string `json:"tools_disabled,omitempty"`
	ToolsAllowGroups []string `json:"tools_allow_groups,omitempty"`
	ToolsDenyGroups  []string `json:"tools_deny_groups,omitempty"`
	SkillsEnabled    []string `json:"skills_enabled,omitempty"`
	SkillsCustom     bool     `json:"skills_custom,omitempty"`
	CommandsEnabled  []string `json:"commands_enabled,omitempty"`
	CommandsCustom   bool     `json:"commands_custom,omitempty"`
	MCPEnabled       []string `json:"mcp_enabled,omitempty"`
	MCPCustom        bool     `json:"mcp_custom,omitempty"`
}

SessionToolConfig holds per-session tool/skill/MCP configuration. nil slices mean "inherit all from system defaults".

type SessionWithPlanTasks added in v0.31.90

type SessionWithPlanTasks struct {
	Session        Session        `json:"session"`
	Plan           *Plan          `json:"plan,omitempty"`
	Contract       *TaskContract  `json:"contract,omitempty"`
	Tasks          []Task         `json:"tasks"`
	Summary        map[string]int `json:"summary"`
	UpdatedAt      time.Time      `json:"updated_at"`
	StaleCompleted bool           `json:"stale_completed"`
}

type Store

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

func NewStore

func NewStore(dir string) *Store

func (*Store) ClearGoal added in v0.32.41

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

ClearGoal removes the session's goal regardless of status. Safe to call when no goal is set.

func (*Store) Create

func (s *Store) Create(title string) (Session, error)

func (*Store) CreateWithOptions

func (s *Store) CreateWithOptions(title string, kind string, hidden bool) (Session, error)

func (*Store) Delete

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

func (*Store) EligibleCwds added in v0.31.162

func (s *Store) EligibleCwds(id string) ([]string, error)

EligibleCwds returns the canonical list of directories the session may use as its current working directory. The result always contains the session's artifact dir (as element 0) followed by any user-registered work_dirs in insertion order, deduplicated. The slice is a defensive copy.

func (*Store) EnsureMain

func (s *Store) EnsureMain() (Session, error)

func (*Store) EnsureWorker

func (s *Store) EnsureWorker(projectID string) (Session, error)

func (*Store) ForkFromMessage added in v0.31.105

func (s *Store) ForkFromMessage(parentID string, messageID string, opts ForkOptions) (Session, error)

ForkFromMessage creates a new visible session whose transcript contains the parent transcript prefix through the selected message.

func (*Store) Get

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

func (*Store) GetCurrentDir added in v0.31.162

func (s *Store) GetCurrentDir(id string) (string, error)

GetCurrentDir returns the session's active cwd, falling back to the artifact dir when no explicit current_dir is set.

func (*Store) GetTasks added in v0.20.0

func (s *Store) GetTasks(sessionID string) (SessionTasks, error)

GetTasks reads the tasks file for a session. Returns empty SessionTasks if not found.

func (*Store) Latest

func (s *Store) Latest() (Session, error)

func (*Store) LatestAll

func (s *Store) LatestAll() (Session, error)

func (*Store) List

func (s *Store) List() ([]Session, error)

func (*Store) ListAll

func (s *Store) ListAll() ([]Session, error)

func (*Store) ListSessionsWithPlans added in v0.31.90

func (s *Store) ListSessionsWithPlans(includeHidden bool, activeOnly bool) ([]SessionWithPlanTasks, error)

func (*Store) SaveTasks added in v0.20.0

func (s *Store) SaveTasks(sessionID string, tasks SessionTasks) error

SaveTasks writes the tasks file for a session.

func (*Store) SetArchived added in v0.32.7

func (s *Store) SetArchived(id string, archived bool) (Session, error)

func (*Store) SetAutomationConsent added in v0.31.108

func (s *Store) SetAutomationConsent(id string, consent *SessionAutomationConsent) error

SetAutomationConsent updates the per-session automation consent policy.

func (*Store) SetCritic added in v0.32.42

func (s *Store) SetCritic(id string, critic *SessionCritic) (Session, error)

SetCritic replaces the session's critic configuration. Only "main" sessions are permitted (matching the SetGoal policy — critic relies on a single plan-transition stream and worker sessions have no user-visible plan). A nil critic clears the configuration entirely.

func (*Store) SetCurrentDir added in v0.22.0

func (s *Store) SetCurrentDir(id string, dir string) error

SetCurrentDir updates only the current working directory for a session.

func (*Store) SetGoal added in v0.32.41

func (s *Store) SetGoal(id string, goal *SessionGoal) (Session, error)

SetGoal replaces the session's active goal. Only "main" sessions are permitted. Passing nil or a goal with empty description clears it.

func (*Store) SetLastCompactionMode added in v0.25.0

func (s *Store) SetLastCompactionMode(id string, mode string) error

func (*Store) SetPinned added in v0.32.7

func (s *Store) SetPinned(id string, pinned bool) (Session, error)

func (*Store) SetPromptOverride added in v0.16.0

func (s *Store) SetPromptOverride(id string, override string) error

SetPromptOverride updates the per-session prompt override.

func (*Store) SetStyleControl added in v0.31.120

func (s *Store) SetStyleControl(id string, style *SessionStyleControl) error

SetStyleControl updates the per-session behavioral style override.

func (*Store) SetTitle added in v0.15.0

func (s *Store) SetTitle(id string, title string) error

SetTitle renames a session.

func (*Store) SetToolConfig added in v0.16.0

func (s *Store) SetToolConfig(id string, config *SessionToolConfig) error

SetToolConfig updates the per-session tool configuration.

func (*Store) SetWorkDirs added in v0.22.0

func (s *Store) SetWorkDirs(id string, dirs []string, currentDir string) error

SetWorkDirs updates the per-session working directories and current directory.

func (*Store) Touch

func (s *Store) Touch(id string, updatedAt time.Time) error

func (*Store) TranscriptPath

func (s *Store) TranscriptPath(id string) string

func (*Store) UpdateCriticProgress added in v0.32.42

func (s *Store) UpdateCriticProgress(id string, mutate func(*SessionCritic) *SessionCritic) (Session, error)

UpdateCriticProgress applies a mutation to the session's critic state. The mutator may return nil to clear runtime state (typically only useful in tests). A no-op when no critic config is present.

func (*Store) UpdateGoalProgress added in v0.32.41

func (s *Store) UpdateGoalProgress(id string, mutate func(*SessionGoal) *SessionGoal) (Session, error)

UpdateGoalProgress applies a mutation to the session's goal (e.g. to bump AutoContinueCount or change Status). If the mutator returns nil the goal is cleared. If no goal is present the call is a no-op.

func (*Store) WorkspaceDir

func (s *Store) WorkspaceDir() string

type Task added in v0.20.0

type Task struct {
	ID          string         `json:"id"`
	Title       string         `json:"title"`
	Status      string         `json:"status"` // pending, in_progress, completed, cancelled
	Description string         `json:"description,omitempty"`
	Evidence    []TaskEvidence `json:"evidence,omitempty"`
	// RunID, when set, names the agentruntime run that is (or was) executing
	// this task. Set when the run is spawned with a task_id; read-only
	// metadata for UI consumers that want to navigate from a task to the
	// run that worked on it.
	RunID string `json:"run_id,omitempty"`
}

Task represents a single work item linked to the session plan.

type TaskContract added in v0.31.98

type TaskContract struct {
	Goal                 string   `json:"goal,omitempty"`
	Scope                string   `json:"scope,omitempty"`
	DoneCriteria         []string `json:"done_criteria,omitempty"`
	VerificationCommands []string `json:"verification_commands,omitempty"`
	Artifacts            []string `json:"artifacts,omitempty"`
	Status               string   `json:"status,omitempty"`
	CreatedAt            string   `json:"created_at,omitempty"`
	UpdatedAt            string   `json:"updated_at,omitempty"`
}

TaskContract makes the implicit work agreement explicit for a session plan. It is stored next to the active plan/tasks so reload, compaction, and archive flows can keep success criteria attached to the work rather than only in chat.

type TaskEvidence added in v0.31.100

type TaskEvidence struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Title     string `json:"title,omitempty"`
	Summary   string `json:"summary,omitempty"`
	URL       string `json:"url,omitempty"`
	Command   string `json:"command,omitempty"`
	Path      string `json:"path,omitempty"`
	Status    string `json:"status,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
}

Jump to

Keyboard shortcuts

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