Documentation
¶
Index ¶
- type ContextSummary
- type DisplayApproval
- type DisplayApprovalDecision
- type DisplayContentPart
- type DisplayItem
- type DisplayItemType
- type DisplayMediaPart
- type DisplayPage
- type DisplayPageQuery
- type DisplayPendingApproval
- type DisplayToolCall
- type DisplayToolResult
- type DisplayToolResultContentPart
- type DisplayTurn
- type FileStore
- func (s *FileStore) AppendDisplayItem(ctx context.Context, id string, item DisplayItem) (DisplayItem, error)
- func (s *FileStore) Close() error
- func (s *FileStore) Delete(ctx context.Context, id string) error
- func (s *FileStore) Get(ctx context.Context, id string) (*Session, error)
- func (s *FileStore) IsLocked(ctx context.Context, id string) (bool, error)
- func (s *FileStore) List(ctx context.Context, filter ListFilter) ([]Metadata, error)
- func (s *FileStore) ListDisplayItems(ctx context.Context, id string) ([]DisplayItem, bool, error)
- func (s *FileStore) Lock(ctx context.Context, id string) error
- func (s *FileStore) Put(ctx context.Context, sess *Session) error
- func (s *FileStore) Unlock(ctx context.Context, id string) error
- type ListFilter
- type Manager
- func (m *Manager) AppendDisplayItem(id string, item DisplayItem) (DisplayItem, error)
- func (m *Manager) Close() error
- func (m *Manager) CreateNew(workDir string) (*Session, error)
- func (m *Manager) Delete(id string) error
- func (m *Manager) IsLocked(id string) bool
- func (m *Manager) ListByDir(workDir string) ([]Metadata, error)
- func (m *Manager) ListDisplayItems(id string) ([]DisplayItem, bool, error)
- func (m *Manager) Load(id string) (*Session, error)
- func (m *Manager) Lock(id string) error
- func (m *Manager) Save(sess *Session) error
- func (m *Manager) Unlock(id string) error
- type Metadata
- type OrderBy
- type SafetyDecision
- type SafetyDecisionSource
- type SafetyEvent
- type Session
- type SnapshotStatus
- type Store
- type Turn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextSummary ¶
type ContextSummary struct {
UserPrompt string `json:"user_prompt,omitempty"`
RecentActions []string `json:"recent_actions,omitempty"`
Trigger string `json:"trigger,omitempty"`
}
ContextSummary stores a compact audit summary instead of full raw context.
type DisplayApproval ¶
type DisplayApproval struct {
ID string `json:"id,omitempty"`
TurnID string `json:"turn_id,omitempty"`
Pending []DisplayPendingApproval `json:"pending,omitempty"`
Decisions []DisplayApprovalDecision `json:"decisions,omitempty"`
}
type DisplayApprovalDecision ¶
type DisplayContentPart ¶
type DisplayContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ToolCall *DisplayToolCall `json:"tool_call,omitempty"`
ToolResult *DisplayToolResult `json:"tool_result,omitempty"`
}
type DisplayItem ¶
type DisplayItem struct {
ID string `json:"id"`
Sequence uint64 `json:"sequence"`
Type DisplayItemType `json:"type"`
Role string `json:"role,omitempty"`
Content []DisplayContentPart `json:"content,omitempty"`
Turn *DisplayTurn `json:"turn,omitempty"`
Approval *DisplayApproval `json:"approval,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type DisplayItemType ¶
type DisplayItemType string
const ( DisplayItemUserMessage DisplayItemType = "user_message" DisplayItemAssistantMessage DisplayItemType = "assistant_message" DisplayItemError DisplayItemType = "error" DisplayItemTurnStarted DisplayItemType = "turn_started" DisplayItemTurnPaused DisplayItemType = "turn_paused" DisplayItemTurnCompleted DisplayItemType = "turn_completed" DisplayItemTurnFailed DisplayItemType = "turn_failed" DisplayItemTurnInterrupted DisplayItemType = "turn_interrupted" DisplayItemApprovalRequest DisplayItemType = "approval_request" DisplayItemApprovalDecision DisplayItemType = "approval_decision" DisplayItemContextCompacted DisplayItemType = "context_compacted" )
type DisplayMediaPart ¶
type DisplayPage ¶
type DisplayPage struct {
Items []DisplayItem
NextCursor string
PrevCursor string
HasMore bool
}
func PageDisplayItems ¶
func PageDisplayItems(items []DisplayItem, query DisplayPageQuery) DisplayPage
type DisplayPageQuery ¶
type DisplayPendingApproval ¶
type DisplayPendingApproval struct {
ToolCallID string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Description string `json:"description,omitempty"`
Reason string `json:"reason,omitempty"`
RiskLevel string `json:"risk_level,omitempty"`
Source string `json:"source,omitempty"`
RequiresSnapshot bool `json:"requires_snapshot,omitempty"`
}
type DisplayToolCall ¶
type DisplayToolResult ¶
type DisplayToolResult struct {
ToolCallID string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
ResultType string `json:"result_type,omitempty"`
Text string `json:"text,omitempty"`
JSON any `json:"json,omitempty"`
Reason string `json:"reason,omitempty"`
Content []DisplayToolResultContentPart `json:"content,omitempty"`
IsError bool `json:"is_error,omitempty"`
}
type DisplayToolResultContentPart ¶
type DisplayToolResultContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Image *DisplayMediaPart `json:"image,omitempty"`
}
type DisplayTurn ¶
type DisplayTurn struct {
ID string `json:"id,omitempty"`
Reason string `json:"reason,omitempty"`
Status string `json:"status,omitempty"`
ProviderFinishReason string `json:"provider_finish_reason,omitempty"`
LastAgentMessage string `json:"last_agent_message,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
}
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements Store using the local filesystem. Sessions are stored as JSON files in a configurable directory.
func NewFileStore ¶
NewFileStore creates a new file-based session store. If rootDir is empty, it defaults to ~/.zotigo
func (*FileStore) AppendDisplayItem ¶
func (s *FileStore) AppendDisplayItem(ctx context.Context, id string, item DisplayItem) (DisplayItem, error)
func (*FileStore) ListDisplayItems ¶
type ListFilter ¶
type ListFilter struct {
// WorkingDirectory filters by project path.
// Empty string means no filter.
WorkingDirectory string
// Limit limits the number of results.
// 0 means no limit.
Limit int
// OrderBy specifies the sort order.
OrderBy OrderBy
}
ListFilter defines filtering criteria for listing sessions.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles session storage, retrieval, and locking. It uses a Store backend for persistence.
func NewManager ¶
NewManager creates a new Manager with the default FileStore.
func NewManagerWithStore ¶
NewManagerWithStore creates a new Manager with a custom Store backend.
func (*Manager) AppendDisplayItem ¶
func (m *Manager) AppendDisplayItem(id string, item DisplayItem) (DisplayItem, error)
func (*Manager) ListByDir ¶
ListByDir returns all sessions for a given directory, sorted by UpdatedAt desc.
func (*Manager) ListDisplayItems ¶
func (m *Manager) ListDisplayItems(id string) ([]DisplayItem, bool, error)
type Metadata ¶
type Metadata struct {
ID string `json:"id"`
WorkingDirectory string `json:"working_directory"` // The project path this session belongs to
LastPrompt string `json:"last_prompt"` // Preview of the last user interaction
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Metadata holds the summary info for listing/indexing.
type OrderBy ¶
type OrderBy int
OrderBy defines sort order options.
const ( // OrderByUpdatedDesc sorts by UpdatedAt descending (newest first). OrderByUpdatedDesc OrderBy = iota // OrderByUpdatedAsc sorts by UpdatedAt ascending (oldest first). OrderByUpdatedAsc // OrderByCreatedDesc sorts by CreatedAt descending. OrderByCreatedDesc // OrderByCreatedAsc sorts by CreatedAt ascending. OrderByCreatedAsc )
type SafetyDecision ¶
type SafetyDecision string
SafetyDecision captures the outcome of a safety gate.
const ( SafetyDecisionAllow SafetyDecision = "allow" SafetyDecisionDeny SafetyDecision = "deny" SafetyDecisionAskUser SafetyDecision = "ask_user" )
type SafetyDecisionSource ¶
type SafetyDecisionSource string
SafetyDecisionSource identifies where a safety decision came from.
const ( SafetyDecisionSourceHardRule SafetyDecisionSource = "hard_rule" SafetyDecisionSourceClassifier SafetyDecisionSource = "classifier" SafetyDecisionSourceUserApproval SafetyDecisionSource = "user_approval" )
type SafetyEvent ¶
type SafetyEvent struct {
Timestamp time.Time `json:"timestamp"`
TurnID string `json:"turn_id"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
ToolArgsSummary string `json:"tool_args_summary,omitempty"`
DecisionSource SafetyDecisionSource `json:"decision_source"`
Decision SafetyDecision `json:"decision"`
Reason string `json:"reason,omitempty"`
RiskLevel string `json:"risk_level,omitempty"`
SnapshotStatus SnapshotStatus `json:"snapshot_status,omitempty"`
SnapshotID string `json:"snapshot_id,omitempty"`
ClassifierProvider string `json:"classifier_provider,omitempty"`
ClassifierModel string `json:"classifier_model,omitempty"`
ContextSummary ContextSummary `json:"context_summary,omitempty"`
RawContext string `json:"raw_context,omitempty"`
}
SafetyEvent stores a compact auditable safety decision tied to a turn.
type Session ¶
type Session struct {
Metadata
AgentSnapshot agent.Snapshot `json:"agent_snapshot"`
Turns []Turn `json:"turns,omitempty"`
}
Session represents the full state on disk.
func (*Session) EnsureInitialized ¶
func (s *Session) EnsureInitialized()
EnsureInitialized backfills fields added in newer versions so old sessions remain usable.
type SnapshotStatus ¶
type SnapshotStatus string
SnapshotStatus captures snapshot behavior for a turn or event.
const ( SnapshotStatusNotNeeded SnapshotStatus = "not_needed" SnapshotStatusCreated SnapshotStatus = "created" SnapshotStatusFailed SnapshotStatus = "failed" SnapshotStatusMissingGitRepo SnapshotStatus = "missing_git_repo" // SnapshotStatusNotInstalled mirrors agent.SnapshotStatusNotInstalled for // persistence; kept in sync with that source of truth. SnapshotStatusNotInstalled SnapshotStatus = "not_installed" )
type Store ¶
type Store interface {
// Get retrieves a session by ID.
// Returns nil if not found.
Get(ctx context.Context, id string) (*Session, error)
// Put stores a session.
Put(ctx context.Context, sess *Session) error
// AppendDisplayItem appends one display-log item to the session's per-session log.
AppendDisplayItem(ctx context.Context, id string, item DisplayItem) (DisplayItem, error)
// ListDisplayItems returns the session's per-session display log.
ListDisplayItems(ctx context.Context, id string) ([]DisplayItem, bool, error)
// Delete removes a session by ID.
Delete(ctx context.Context, id string) error
// List returns all sessions matching the filter.
List(ctx context.Context, filter ListFilter) ([]Metadata, error)
// Lock acquires an exclusive lock on a session.
// Returns error if already locked.
Lock(ctx context.Context, id string) error
// Unlock releases the lock on a session.
Unlock(ctx context.Context, id string) error
// IsLocked checks if a session is currently locked.
IsLocked(ctx context.Context, id string) (bool, error)
// Close releases any resources held by the store.
Close() error
}
Store defines the interface for session storage backends. Implementations can be file-based (local), Redis, database, etc.
type Turn ¶
type Turn struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
UserPromptSummary string `json:"user_prompt_summary,omitempty"`
SafetyEvents []SafetyEvent `json:"safety_events,omitempty"`
SnapshotStatus SnapshotStatus `json:"snapshot_status,omitempty"`
SnapshotID string `json:"snapshot_id,omitempty"`
}
Turn stores compact turn-scoped execution metadata for auditing.