services

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: AGPL-3.0 Imports: 63 Imported by: 0

Documentation

Overview

Package services provides the server-side service implementations.

Package services provides the server-side service implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSettingsNotFound is returned when the Claude settings file is not found.
	ErrSettingsNotFound = fmt.Errorf("settings file not found")
)

Functions

func ExpandPath added in v1.1.2

func ExpandPath(arg string) string

ExpandPath expands tilde and environment variables in a single path token and normalises absolute paths with filepath.Clean.

  • "~" → home directory
  • "~/foo" → filepath.Join(home, "foo")
  • anything else → os.ExpandEnv (handles $HOME, $TMPDIR, $VAR, …)

After expansion, absolute paths are passed through filepath.Clean to remove redundant separators and ".." components (e.g. "/foo/../bar" → "/bar").

func ExtractDomainsFromCommand

func ExtractDomainsFromCommand(cmd string) []string

ExtractDomainsFromCommand parses network-relevant Bash commands and returns the eTLD+1 (registered domain) for each URL found, deduplicated.

func FormatSecretDenyMessage

func FormatSecretDenyMessage(patternName string) string

FormatSecretDenyMessage returns a user-facing denial message for a secret scan hit.

func InjectHookConfig

func InjectHookConfig(rootDir, sessionTitle string) error

InjectHookConfig writes (or merges) the stapler-squad PermissionRequest HTTP hook into <rootDir>/.claude/settings.local.json.

If the file already contains a hook pointing to hookApprovalURL, it is left unchanged. If the file exists but lacks our hook, the hook is prepended to PermissionRequest. If the file does not exist, it is created with just our hook config.

func InjectHooksConfig added in v1.17.0

func InjectHooksConfig(rootDir, sessionTitle string, hooks []HookName) error

InjectHooksConfig writes (or merges) hook entries into <rootDir>/.claude/settings.local.json.

  • HookPermissionApproval is always injected regardless of the hooks slice.
  • Each hook entry is a curl command POSTing to the server endpoint with X-CS-Session-ID set to sessionTitle.
  • The write is atomic (temp file + rename).
  • Idempotent: existing entries pointing to our URL are preserved.

func InjectMCPConfig added in v1.17.0

func InjectMCPConfig(rootDir, binaryPath string) error

InjectMCPConfig writes (or merges) the stapler-squad MCP server entry into <rootDir>/.claude/settings.local.json.

Behavior:

  • If the file already contains our entry pointing to the same binary, it is a no-op.
  • If the file exists without our entry, the entry is merged in.
  • If the file does not exist, it is created.
  • The write is atomic (temp file + rename).

binaryPath should be the absolute path to the stapler-squad binary (use os.Executable()).

func LoadClaudeSettingsRules

func LoadClaudeSettingsRules(projectDir string) []classifier.Rule

LoadClaudeSettingsRules parses both the global and project-level Claude settings and returns AutoAllow rules derived from their permissions.allow lists.

Search order:

  1. ~/.claude/settings.json (global)
  2. ~/.claude/settings.local.json (global local overrides)
  3. <projectDir>/.claude/settings.json (project)
  4. <projectDir>/.claude/settings.local.json (project local)

Project settings take precedence: if both define the same tool pattern, the project rule will be checked first due to higher priority.

func RemoveMCPConfig added in v1.17.0

func RemoveMCPConfig(rootDir string) error

RemoveMCPConfig removes the stapler-squad entry from <rootDir>/.claude/settings.local.json. If the file is missing, it is a no-op.

func StartExpirationCleanup

func StartExpirationCleanup(ctx context.Context, store *ApprovalStore)

StartExpirationCleanup starts a background goroutine that periodically removes expired approvals. The goroutine stops when ctx is canceled.

func WriteSnapshot

func WriteSnapshot(snap *DebugSnapshot, dir string) (string, error)

WriteSnapshot serializes the snapshot to a JSON file in the given directory. Returns the absolute path of the written file.

Types

type AnalyticsEntry

type AnalyticsEntry struct {
	ID             string    `json:"id"`
	Timestamp      time.Time `json:"timestamp"`
	SessionID      string    `json:"session_id"`
	ToolName       string    `json:"tool_name"`
	CommandPreview string    `json:"command_preview"` // first 200 chars
	Cwd            string    `json:"cwd"`
	// Decision: "auto_allow" | "auto_deny" | "escalate" | "manual_allow" | "manual_deny"
	Decision    string `json:"decision"`
	RiskLevel   string `json:"risk_level"`
	RuleID      string `json:"rule_id,omitempty"`
	RuleName    string `json:"rule_name,omitempty"`
	Reason      string `json:"reason,omitempty"`
	Alternative string `json:"alternative,omitempty"`
	DurationMs  int64  `json:"duration_ms"`
	ApprovalID  string `json:"approval_id,omitempty"`

	// AST-derived command categorization (Bash tool only).
	// CommandProgram is the primary executable being called (e.g., "git", "npm").
	CommandProgram string `json:"command_program,omitempty"`
	// CommandCategory groups CommandProgram into a high-level category (e.g., "vcs", "node").
	CommandCategory string `json:"command_category,omitempty"`
	// CommandSubcategory is the first positional subcommand (e.g., "commit" for "git commit").
	CommandSubcategory string `json:"command_subcommand,omitempty"`
	// PythonImports lists top-level module names imported in inline Python (-c) invocations.
	PythonImports []string `json:"python_imports,omitempty"`
}

AnalyticsEntry records a single classification decision.

func ReclassifyGaps

func ReclassifyGaps(entries []AnalyticsEntry, c classifier.Classifier) []AnalyticsEntry

ReclassifyGaps re-runs the current classifier against entries that were previously escalated with no matching rule (coverage gaps). Any entry that the current rules would now auto-allow or auto-deny has its Decision and RuleID updated in the returned copy — the underlying JSONL file is unchanged.

Call this before ComputeSummary when you want coverage-gap metrics to reflect the CURRENT rule set rather than the rules that were active when the entry was recorded. This prevents historical gaps from artificially inflating the gap rate after new rules are added.

type AnalyticsStore

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

AnalyticsStore writes AnalyticsEntry records asynchronously to SQLite via session.Storage and provides aggregations.

func NewAnalyticsStore

func NewAnalyticsStore(storage *session.Storage) *AnalyticsStore

NewAnalyticsStore creates an AnalyticsStore backed by the given storage. Call Start() to begin the background flush goroutine.

func (*AnalyticsStore) DroppedCount

func (s *AnalyticsStore) DroppedCount() int64

DroppedCount returns the number of entries dropped due to buffer overflow.

func (*AnalyticsStore) LoadWindow

func (s *AnalyticsStore) LoadWindow(since time.Time) ([]AnalyticsEntry, error)

LoadWindow reads entries from DB with timestamps >= since. TODO: Add a timestamp-filtered query to the repository layer to avoid loading all rows into memory as the analytics table grows.

func (*AnalyticsStore) Record

func (s *AnalyticsStore) Record(entry AnalyticsEntry)

Record enqueues an analytics entry for async write. Non-blocking. If the buffer is full, the entry is dropped and the dropped counter incremented.

func (*AnalyticsStore) RecordFromResult

func (s *AnalyticsStore) RecordFromResult(payload classifier.PermissionRequestPayload, result classifier.ClassificationResult, sessionID, approvalID string, durationMs int64)

RecordFromResult builds and records an AnalyticsEntry from classification output.

func (*AnalyticsStore) RecordManualDecision

func (s *AnalyticsStore) RecordManualDecision(approvalID, sessionID, toolName, cwd, decision string)

RecordManualDecision records a manual approve/deny decision for an approval.

func (*AnalyticsStore) Start

func (s *AnalyticsStore) Start(ctx interface{ Done() <-chan struct{} })

Start launches the background goroutine that flushes entries to disk. It stops when ctx is canceled.

type AnalyticsSummary

type AnalyticsSummary struct {
	TotalDecisions    int            `json:"total_decisions"`
	DecisionCounts    map[string]int `json:"decision_counts"`
	TopTools          []ToolStat     `json:"top_tools"`
	TopDeniedCommands []CommandStat  `json:"top_denied_commands"`
	TopTriggeredRules []RuleStat     `json:"top_triggered_rules"`
	// TopCommandPrograms lists the most frequently invoked programs via the Bash tool.
	TopCommandPrograms []ProgramStat `json:"top_command_programs"`
	// TopPythonImports lists the most frequently imported Python modules from inline (-c) invocations.
	TopPythonImports []ImportStat `json:"top_python_imports"`
	AutoApproveRate  float64      `json:"auto_approve_rate"`
	ManualReviewRate float64      `json:"manual_review_rate"`
	WindowStart      time.Time    `json:"window_start"`
	WindowEnd        time.Time    `json:"window_end"`

	// Coverage gap: decisions that escaped all rules (escalated with no rule_id).
	// These are prime candidates for new rules to reduce manual review.
	CoverageGapCount     int           `json:"coverage_gap_count"`
	CoverageGapRate      float64       `json:"coverage_gap_rate"` // percentage 0–100
	TopUncoveredTools    []ToolStat    `json:"top_uncovered_tools"`
	TopUncoveredPrograms []ProgramStat `json:"top_uncovered_programs"`

	// CommandSubcommandStats is the complete (program, subcommand) distribution — not
	// truncated to top-N. Use this for drill-down analysis such as "which gh subcommands
	// does Claude use most?" or "what sed patterns need rules?".
	CommandSubcommandStats []SubcommandStat `json:"command_subcommand_stats"`
}

AnalyticsSummary aggregates decisions over a time window.

func ComputeSummary

func ComputeSummary(entries []AnalyticsEntry) AnalyticsSummary

ComputeSummary aggregates a slice of entries into an AnalyticsSummary. Pure function -- no I/O.

type ApprovalDecision

type ApprovalDecision struct {
	Behavior string // "allow" or "deny"
	Message  string // Optional reason shown to Claude on deny
}

ApprovalDecision is the user's response to a pending approval.

type ApprovalDetail

type ApprovalDetail struct {
	ID              string                 `json:"id"`
	SessionID       string                 `json:"session_id"`
	ClaudeSessionID string                 `json:"claude_session_id"`
	ToolName        string                 `json:"tool_name"`
	ToolInput       map[string]interface{} `json:"tool_input,omitempty"`
	Cwd             string                 `json:"cwd"`
	PermissionMode  string                 `json:"permission_mode"`
	CreatedAt       time.Time              `json:"created_at"`
	ExpiresAt       time.Time              `json:"expires_at"`
}

ApprovalDetail captures the fields of a single pending approval.

type ApprovalHandler

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

ApprovalHandler handles Claude Code HTTP hooks for PermissionRequest events. It blocks the HTTP connection open while waiting for the user's decision, then returns the decision in the hookSpecificOutput JSON format.

func NewApprovalHandler

func NewApprovalHandler(store *ApprovalStore, storage *session.Storage, eventBus *events.EventBus) *ApprovalHandler

NewApprovalHandler creates a new ApprovalHandler.

func (*ApprovalHandler) HandlePermissionRequest

func (h *ApprovalHandler) HandlePermissionRequest(w http.ResponseWriter, r *http.Request)

HandlePermissionRequest handles POST /api/hooks/permission-request. This endpoint is configured as an HTTP hook in Claude Code's settings. It blocks until the user approves/denies or the context is canceled.

func (*ApprovalHandler) SetAnalyticsStore

func (h *ApprovalHandler) SetAnalyticsStore(a *AnalyticsStore)

SetAnalyticsStore injects an AnalyticsStore for recording classification decisions.

func (*ApprovalHandler) SetClassifier

func (h *ApprovalHandler) SetClassifier(c classifier.Classifier)

SetClassifier injects a Classifier for auto-approving/denying tool use requests before they reach the manual review queue.

func (*ApprovalHandler) SetDomainChecker

func (h *ApprovalHandler) SetDomainChecker(d *DomainAgeChecker)

SetDomainChecker injects a DomainAgeChecker for escalating requests to newly-registered domains.

func (*ApprovalHandler) SetNotificationStamper

func (h *ApprovalHandler) SetNotificationStamper(s approvalNotificationStamper)

SetNotificationStamper injects a stamper for persisting approval outcomes on notification records. When set, resolved and timed-out approvals are stamped with approval_decision in their metadata so the notification panel can show a persistent badge after page refresh.

func (*ApprovalHandler) SetQueueChecker

func (h *ApprovalHandler) SetQueueChecker(checker ReviewQueueChecker)

SetQueueChecker injects a ReviewQueueChecker for triggering immediate review queue updates when a new approval is created. This provides <100ms feedback instead of waiting for the next 2-second poll cycle.

type ApprovalService

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

ApprovalService handles Claude Code hook approval RPCs.

func NewApprovalService

func NewApprovalService(store *ApprovalStore) *ApprovalService

NewApprovalService creates an ApprovalService with the given ApprovalStore.

func (*ApprovalService) ListPendingApprovals

ListPendingApprovals returns all pending approval requests, optionally filtered by session ID.

func (*ApprovalService) ResolveApproval

ResolveApproval sends the user's decision to the blocked HTTP hook handler.

func (*ApprovalService) SetNotificationStore

func (as *ApprovalService) SetNotificationStore(store notificationMetadataStore)

SetNotificationStore wires in the notification history store so that resolved approvals are stamped with their decision in the notification metadata.

type ApprovalSnapshot

type ApprovalSnapshot struct {
	PendingCount int              `json:"pending_count"`
	Pending      []ApprovalDetail `json:"pending,omitempty"`
}

ApprovalSnapshot captures the pending approvals state.

type ApprovalStore

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

ApprovalStore manages pending approval requests with thread-safe access.

func NewApprovalStore

func NewApprovalStore(filePath string) *ApprovalStore

NewApprovalStore creates a new ApprovalStore. If filePath is non-empty, persisted approvals are loaded from disk and marked as orphaned.

func (*ApprovalStore) CancelSession

func (s *ApprovalStore) CancelSession(sessionID string) []string

CancelSession denies all pending approvals for a session (e.g., on restart).

func (*ApprovalStore) CleanupExpired

func (s *ApprovalStore) CleanupExpired() []string

CleanupExpired removes approvals past their ExpiresAt and denies them with a timeout message. Also removes orphaned approvals older than orphanedCleanupThreshold (4 hours). Returns the IDs of cleaned-up approvals.

func (*ApprovalStore) Create

func (s *ApprovalStore) Create(a *PendingApproval) error

Create adds a new pending approval to the store and initializes its decision channel.

func (*ApprovalStore) Get

func (s *ApprovalStore) Get(id string) (*PendingApproval, bool)

Get retrieves a pending approval by ID.

func (*ApprovalStore) GetApprovalMetadataBySession

func (s *ApprovalStore) GetApprovalMetadataBySession(sessionID string) []session.ApprovalMetadata

GetApprovalMetadataBySession implements session.ApprovalMetadataProvider. Returns approval metadata for all pending approvals matching the given session ID.

func (*ApprovalStore) GetBySession

func (s *ApprovalStore) GetBySession(sessionID string) []*PendingApproval

GetBySession returns all pending approvals for a given session.

func (*ApprovalStore) GetFilePath

func (s *ApprovalStore) GetFilePath() string

GetFilePath returns the file path used for persistence (for testing/wiring).

func (*ApprovalStore) ListAll

func (s *ApprovalStore) ListAll() []*PendingApproval

ListAll returns all currently pending approvals.

func (*ApprovalStore) Remove

func (s *ApprovalStore) Remove(id string)

Remove removes an approval from the store without sending a decision. The pending HTTP handler will detect context cancellation or its own timeout.

func (*ApprovalStore) Resolve

func (s *ApprovalStore) Resolve(id string, decision ApprovalDecision) error

Resolve sends a decision to the pending approval and removes it from the store. Returns an error if the approval doesn't exist or was already resolved. For orphaned approvals (loaded from disk after restart), the record is simply removed since there is no live HTTP connection to send the decision to.

type CircuitBreakerHandler

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

CircuitBreakerHandler provides a debug endpoint to inspect circuit breaker state.

func NewCircuitBreakerHandler

func NewCircuitBreakerHandler() *CircuitBreakerHandler

NewCircuitBreakerHandler creates a new handler using the global registry.

func (*CircuitBreakerHandler) HandleCircuitBreakers

func (h *CircuitBreakerHandler) HandleCircuitBreakers(w http.ResponseWriter, r *http.Request)

HandleCircuitBreakers returns the current state of all circuit breakers. GET /api/debug/circuit-breakers

func (*CircuitBreakerHandler) RegisterRoutes

func (h *CircuitBreakerHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers the circuit breaker debug routes on the given mux.

type ClaudePermissions

type ClaudePermissions struct {
	Allow []string `json:"allow"` // tool patterns, e.g. "Bash(git log*)"
	Deny  []string `json:"deny,omitempty"`
}

ClaudePermissions mirrors the "permissions" key in ~/.claude/settings.json.

func ParseClaudeSettings

func ParseClaudeSettings(path string) (*ClaudePermissions, error)

ParseClaudeSettings reads a Claude settings.json file and extracts permissions. Returns nil permissions (no error) if the file does not exist or has no permissions key.

type CommandStat

type CommandStat struct {
	Preview  string `json:"preview"`
	ToolName string `json:"tool_name"`
	Count    int    `json:"count"`
}

CommandStat is a command preview with a count.

type ConfigService

type ConfigService struct{}

ConfigService handles Claude configuration file RPC methods.

It is dependency-light: each call creates a fresh ClaudeConfigManager so there is no shared state to synchronise.

func NewConfigService

func NewConfigService() *ConfigService

NewConfigService creates a ConfigService.

func (*ConfigService) GetClaudeConfig

GetClaudeConfig retrieves a Claude configuration file by name.

func (*ConfigService) ListClaudeConfigs

ListClaudeConfigs returns all configuration files in the ~/.claude directory.

func (*ConfigService) UpdateClaudeConfig

UpdateClaudeConfig updates a Claude configuration file with atomic write and backup.

type ConnectRPCWebSocketHandler

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

func NewConnectRPCWebSocketHandler

func NewConnectRPCWebSocketHandler(sessionService *SessionService, scrollbackManager *scrollback.ScrollbackManager, tmuxStreamerManager *session.ExternalTmuxStreamerManager, streamingMode string) *ConnectRPCWebSocketHandler

NewConnectRPCWebSocketHandler creates a new ConnectRPC WebSocket handler tmuxStreamerManager is required for ALL sessions (managed and external) since they all use tmux capture-pane polling

func (*ConnectRPCWebSocketHandler) HandleWebSocket

func (h *ConnectRPCWebSocketHandler) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket upgrades HTTP connection to WebSocket and handles ConnectRPC protocol

func (*ConnectRPCWebSocketHandler) SetExternalSessionSupport

func (h *ConnectRPCWebSocketHandler) SetExternalSessionSupport(
	discovery *session.ExternalSessionDiscovery,
)

SetExternalSessionSupport configures external session discovery support This enables the handler to discover and stream external sessions (via mux socket monitoring) Note: tmuxStreamerManager is already set in constructor since ALL sessions use it

type DailyBucket

type DailyBucket struct {
	Date        string `json:"date"` // "2006-01-02" in local time
	AutoAllow   int    `json:"auto_allow"`
	AutoDeny    int    `json:"auto_deny"`
	Escalate    int    `json:"escalate"`
	ManualAllow int    `json:"manual_allow"`
	ManualDeny  int    `json:"manual_deny"`
	Total       int    `json:"total"`
}

DailyBucket aggregates classification decisions for a single calendar day.

func ComputeDailyBuckets

func ComputeDailyBuckets(entries []AnalyticsEntry) []DailyBucket

ComputeDailyBuckets groups entries by calendar day (local time) sorted ascending. Pure function — no I/O.

func (DailyBucket) AutoApproveRate

func (b DailyBucket) AutoApproveRate() float64

AutoApproveRate returns the fraction of decisions that were auto-allowed.

type DatabaseService

type DatabaseService struct{}

DatabaseService implements the database/workspace switcher RPC methods. It is stateless: each call reads the filesystem directly.

func NewDatabaseService

func NewDatabaseService() *DatabaseService

NewDatabaseService creates a DatabaseService.

func (*DatabaseService) GetCurrentDatabase

GetCurrentDatabase returns metadata for the currently active workspace database.

func (*DatabaseService) ListDatabases

ListDatabases returns all discovered workspace databases with metadata.

func (*DatabaseService) MergeDatabase

MergeDatabase copies sessions from a source workspace into the current one. Uses INSERT OR IGNORE so existing sessions (matched by title) are never overwritten.

func (*DatabaseService) SwitchDatabase

SwitchDatabase writes a preference file and triggers an exec-based server self-restart. The client should poll until the server is back up, then reload the page.

type DebugSnapshot

type DebugSnapshot struct {
	Version    int                `json:"version"`
	Timestamp  time.Time          `json:"timestamp"`
	Note       string             `json:"note,omitempty"`
	Server     ServerInfo         `json:"server"`
	Sessions   []SessionSnapshot  `json:"sessions"`
	Tmux       TmuxSnapshot       `json:"tmux"`
	Approvals  ApprovalSnapshot   `json:"approvals"`
	RecentLogs RecentLogsSnapshot `json:"recent_logs"`
	Errors     []string           `json:"errors,omitempty"`
}

DebugSnapshot is the top-level JSON structure written to disk.

func CollectSnapshot

func CollectSnapshot(ctx context.Context, note string, instances []*session.Instance, approvalStore *ApprovalStore, logLines int) *DebugSnapshot

CollectSnapshot gathers all diagnostic data into a DebugSnapshot. Individual subsystem failures are recorded in Errors and do not abort the collection.

type DefaultsService added in v1.12.0

type DefaultsService struct{}

DefaultsService handles session defaults RPC methods.

func NewDefaultsService added in v1.12.0

func NewDefaultsService() *DefaultsService

NewDefaultsService creates a DefaultsService.

func (*DefaultsService) DeleteDirectoryRule added in v1.12.0

DeleteDirectoryRule removes a directory rule by path.

func (*DefaultsService) DeleteProfile added in v1.12.0

DeleteProfile removes a named profile by name.

func (*DefaultsService) GetSessionDefaults added in v1.12.0

GetSessionDefaults returns the full session defaults configuration.

func (*DefaultsService) ResolveDefaults added in v1.12.0

ResolveDefaults merges all default layers for the given working directory and profile.

func (*DefaultsService) UpdateGlobalDefaults added in v1.12.0

UpdateGlobalDefaults replaces the global default fields and persists them.

func (*DefaultsService) UpsertDirectoryRule added in v1.12.0

UpsertDirectoryRule creates or updates a directory rule (matched by path).

func (*DefaultsService) UpsertProfile added in v1.12.0

UpsertProfile creates or updates a named profile.

type DirCache added in v1.13.0

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

DirCache is a thread-safe, mtime+TTL-invalidated cache of os.DirEntry slices keyed by directory path. It is intended to reduce repeated os.ReadDir calls for the same directory within a short window (e.g., repeated Omnibar opens).

Invalidation policy:

  • An entry is stale if time.Since(cachedAt) > ttl.
  • An entry is stale if the directory's mtime has advanced since the entry was stored.
  • Eviction is LRU by insertion order: when len(entries) >= maxSize, the oldest entry (earliest cachedAt) is removed before storing a new one.

No background goroutines are used; all operations are on-demand.

func NewDirCache added in v1.13.0

func NewDirCache(maxSize int, ttl time.Duration) *DirCache

NewDirCache creates a DirCache with the given capacity and TTL.

func (*DirCache) Get added in v1.13.0

func (c *DirCache) Get(path string) ([]os.DirEntry, bool)

Get returns the cached DirEntry slice for path if the entry is still valid.

Validity requires both:

  1. time.Since(entry.cachedAt) <= c.ttl (TTL not expired)
  2. os.Stat(path).ModTime() == entry.dirMtime (directory unchanged)

Returns (nil, false) on any miss: entry absent, TTL expired, or mtime changed. A stale-mtime entry is removed from the cache under a write lock so the next Put does not exceed maxSize unnecessarily.

func (*DirCache) Put added in v1.13.0

func (c *DirCache) Put(path string, entries []os.DirEntry, dirMtime time.Time)

Put stores entries for path with the provided dirMtime. If the cache is at capacity, the entry with the oldest cachedAt is evicted first.

type DomainAgeChecker

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

DomainAgeChecker extracts domains from Bash commands and checks their registration age using RDAP (Registration Data Access Protocol). Results are cached for 24h.

A domain is considered "new" if its registration date is within the configured threshold (default 30 days). New domains from network-oriented commands are escalated for review.

func NewDomainAgeChecker

func NewDomainAgeChecker(enabled bool) *DomainAgeChecker

NewDomainAgeChecker creates a DomainAgeChecker with sensible defaults. Set enabled=false to disable RDAP lookups (no-op mode).

func (*DomainAgeChecker) IsNewlyRegistered

func (d *DomainAgeChecker) IsNewlyRegistered(ctx context.Context, domain string) (bool, error)

IsNewlyRegistered returns true if the domain was registered within the threshold and the check is enabled. Returns (false, nil) for any lookup failure, to avoid blocking legitimate operations on RDAP outages.

func (*DomainAgeChecker) NewDomainThreshold

func (d *DomainAgeChecker) NewDomainThreshold() time.Duration

NewDomainThreshold returns how old a domain must be to be considered "established".

type EscapeCodeHandler

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

EscapeCodeHandler provides REST endpoints for escape code analytics

func NewEscapeCodeHandler

func NewEscapeCodeHandler() *EscapeCodeHandler

NewEscapeCodeHandler creates a new handler using the global store

func (*EscapeCodeHandler) HandleClear

func (h *EscapeCodeHandler) HandleClear(w http.ResponseWriter, r *http.Request)

HandleClear clears all recorded escape codes DELETE /api/debug/escape-codes

func (*EscapeCodeHandler) HandleExport

func (h *EscapeCodeHandler) HandleExport(w http.ResponseWriter, r *http.Request)

HandleExport exports all data as JSON GET /api/debug/escape-codes/export

func (*EscapeCodeHandler) HandleGetAll

func (h *EscapeCodeHandler) HandleGetAll(w http.ResponseWriter, r *http.Request)

HandleGetAll returns all escape code entries GET /api/debug/escape-codes

func (*EscapeCodeHandler) HandleGetByCategory

func (h *EscapeCodeHandler) HandleGetByCategory(w http.ResponseWriter, r *http.Request)

HandleGetByCategory returns entries for a specific category GET /api/debug/escape-codes/category/{category}

func (*EscapeCodeHandler) HandleGetBySession

func (h *EscapeCodeHandler) HandleGetBySession(w http.ResponseWriter, r *http.Request)

HandleGetBySession returns entries for a specific session GET /api/debug/escape-codes/session/{sessionId}

func (*EscapeCodeHandler) HandleGetStats

func (h *EscapeCodeHandler) HandleGetStats(w http.ResponseWriter, r *http.Request)

HandleGetStats returns aggregated statistics GET /api/debug/escape-codes/stats

func (*EscapeCodeHandler) HandleStatus

func (h *EscapeCodeHandler) HandleStatus(w http.ResponseWriter, r *http.Request)

HandleStatus returns the current tracking status GET /api/debug/escape-codes/status

func (*EscapeCodeHandler) HandleToggle

func (h *EscapeCodeHandler) HandleToggle(w http.ResponseWriter, r *http.Request)

HandleToggle enables or disables escape code tracking POST /api/debug/escape-codes/toggle Body: {"enabled": true/false}

func (*EscapeCodeHandler) RegisterRoutes

func (h *EscapeCodeHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all escape code handler routes on the given mux

type ExternalWebSocketHandler

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

ExternalWebSocketHandler handles approval monitoring for external mux sessions. Terminal streaming has been migrated to the unified ConnectRPC WebSocket handler.

func NewExternalWebSocketHandler

func NewExternalWebSocketHandler(
	discovery *session.ExternalSessionDiscovery,
	tmuxStreamerManager *session.ExternalTmuxStreamerManager,
	approvalMonitor *session.ExternalApprovalMonitor,
	eventBus *events.EventBus,
) *ExternalWebSocketHandler

NewExternalWebSocketHandler creates a new handler for external session approval monitoring. Note: tmuxStreamerManager parameter is kept for backward compatibility but is no longer used since terminal streaming has been migrated to the unified ConnectRPC WebSocket handler.

func (*ExternalWebSocketHandler) HandleApprovalResponse

func (h *ExternalWebSocketHandler) HandleApprovalResponse(w http.ResponseWriter, r *http.Request)

HandleApprovalResponse handles user response to an approval request

func (*ExternalWebSocketHandler) HandleApprovals

func (h *ExternalWebSocketHandler) HandleApprovals(w http.ResponseWriter, r *http.Request)

HandleApprovals returns pending approvals for an external session

type FileService added in v1.11.0

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

FileService handles ListFiles and GetFileContent RPCs.

func NewFileService added in v1.11.0

func NewFileService(workspace WorkspaceProvider) *FileService

NewFileService creates a FileService with the given workspace provider.

func (*FileService) GetFileContent added in v1.11.0

GetFileContent retrieves the content of a file in the session's worktree.

func (*FileService) ListFiles added in v1.11.0

ListFiles returns the immediate children of the given directory in the session's worktree.

func (*FileService) SearchFiles added in v1.12.0

SearchFiles performs a recursive name-substring search in the session's worktree.

type GitHubService

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

GitHubService handles all GitHub PR RPC methods.

These methods shell out to the `gh` CLI and have no dependency on review queue, terminal streaming, or search. They only need to look up a session by ID and call PR operations on it.

func NewGitHubService

func NewGitHubService(storage *session.Storage) *GitHubService

NewGitHubService creates a GitHubService backed by the given storage.

func (*GitHubService) ClosePR

ClosePR closes the PR without merging for a session.

func (*GitHubService) GetPRComments

GetPRComments retrieves all comments on the PR for a session.

func (*GitHubService) GetPRInfo

GetPRInfo retrieves the latest PR information for a session.

func (*GitHubService) MergePR

MergePR merges the PR for a session using the specified merge method.

func (*GitHubService) PostPRComment

PostPRComment posts a new comment to the PR for a session.

type HookName added in v1.17.0

type HookName string

HookName is a typed constant for the built-in hooks that can be injected.

const (
	HookPermissionApproval HookName = "permission_approval" // maps to PermissionRequest event
	HookStopNotification   HookName = "stop_notification"   // maps to Stop event
	HookPreToolLogging     HookName = "pre_tool_logging"    // maps to PreToolUse event
	HookPostToolLogging    HookName = "post_tool_logging"   // maps to PostToolUse event
	HookPromptSubmit       HookName = "prompt_submit"       // maps to UserPromptSubmit event
)

type HookReceiver added in v1.17.0

type HookReceiver struct{}

HookReceiver handles inbound Claude Code hook callbacks for non-approval events. These are fire-and-forget: Claude does not block on the response.

func NewHookReceiver added in v1.17.0

func NewHookReceiver() *HookReceiver

NewHookReceiver creates a HookReceiver.

func (*HookReceiver) HandlePostToolUse added in v1.17.0

func (h *HookReceiver) HandlePostToolUse(w http.ResponseWriter, r *http.Request)

HandlePostToolUse receives the Claude Code PostToolUse hook.

func (*HookReceiver) HandlePreToolUse added in v1.17.0

func (h *HookReceiver) HandlePreToolUse(w http.ResponseWriter, r *http.Request)

HandlePreToolUse receives the Claude Code PreToolUse hook.

func (*HookReceiver) HandlePromptSubmit added in v1.17.0

func (h *HookReceiver) HandlePromptSubmit(w http.ResponseWriter, r *http.Request)

HandlePromptSubmit receives the Claude Code UserPromptSubmit hook.

func (*HookReceiver) HandleStop added in v1.17.0

func (h *HookReceiver) HandleStop(w http.ResponseWriter, r *http.Request)

HandleStop receives the Claude Code Stop hook.

func (*HookReceiver) RegisterRoutes added in v1.17.0

func (h *HookReceiver) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers the four non-approval hook endpoints on mux.

type ImageUploadHandler added in v1.17.0

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

ImageUploadHandler saves clipboard images to a temp directory and returns the absolute path so the terminal process can reference the file.

func NewImageUploadHandler added in v1.17.0

func NewImageUploadHandler(dir string) *ImageUploadHandler

func (*ImageUploadHandler) HandleUpload added in v1.17.0

func (h *ImageUploadHandler) HandleUpload(w http.ResponseWriter, r *http.Request)

type ImportStat

type ImportStat struct {
	Module string `json:"module"`
	Count  int    `json:"count"`
}

ImportStat is a Python module import with its usage count.

type NotificationRateLimiter

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

NotificationRateLimiter provides per-session rate limiting for notifications. Prevents notification flooding from individual sessions while allowing legitimate notification volumes across all sessions.

func NewNotificationRateLimiter

func NewNotificationRateLimiter(r float64, b int) *NotificationRateLimiter

NewNotificationRateLimiter creates a rate limiter. rate: notifications per second (e.g., 10) burst: max burst size (e.g., 20)

func (*NotificationRateLimiter) Allow

func (rl *NotificationRateLimiter) Allow(sessionID string) bool

Allow checks if a notification is allowed for the given session. Returns true if the notification should be processed, false if rate limited.

func (*NotificationRateLimiter) Cleanup

func (rl *NotificationRateLimiter) Cleanup(activeSessions []string)

Cleanup removes rate limiters for sessions that are no longer active. Should be called periodically to prevent memory leaks.

func (*NotificationRateLimiter) Count

func (rl *NotificationRateLimiter) Count() int

Count returns the number of active rate limiters (for monitoring).

func (*NotificationRateLimiter) Reset

func (rl *NotificationRateLimiter) Reset(sessionID string)

Reset removes the rate limiter for a specific session. Useful for testing or when a session is recreated.

type NotificationService

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

NotificationService handles notification sending and history RPCs.

Dependencies:

  • notificationStore: persists notification history
  • notificationRateLimiter: rate-limits per-session notification sends
  • eventBus: broadcasts notification events to connected clients
  • reviewQueuePoller: late-wired; used to resolve session names

func NewNotificationService

func NewNotificationService(
	rateLimiter *NotificationRateLimiter,
	eventBus *events.EventBus,
) *NotificationService

NewNotificationService creates a NotificationService with the given dependencies.

func (*NotificationService) ClearNotificationHistory

ClearNotificationHistory removes notifications from the history.

func (*NotificationService) GetNotificationHistory

GetNotificationHistory returns persisted notification history with optional filtering.

func (*NotificationService) GetNotificationStore

func (ns *NotificationService) GetNotificationStore() *notifications.NotificationHistoryStore

GetNotificationStore returns the notification history store.

func (*NotificationService) MarkNotificationRead

MarkNotificationRead marks specific notifications as read. If notification_ids is empty, marks all notifications as read.

func (*NotificationService) SendNotification

SendNotification allows tmux sessions and external Claude processes to send notifications. Enforces localhost-only restriction and rate limiting. Accepts both managed sessions and external sessions (e.g., Claude running in IntelliJ, VS Code, or other terminals).

func (*NotificationService) SetNotificationStore

func (ns *NotificationService) SetNotificationStore(store *notifications.NotificationHistoryStore)

SetNotificationStore sets the notification history store (late-wired).

func (*NotificationService) SetReviewQueuePoller

func (ns *NotificationService) SetReviewQueuePoller(poller *session.ReviewQueuePoller)

SetReviewQueuePoller sets the review queue poller for resolving session names.

type PathClassification added in v1.1.2

type PathClassification uint

PathClassification is a bitmask that categorises a resolved filesystem path. Multiple bits may be set simultaneously (e.g. a path can be both PathSystemDir and PathGitRepo if the repository lives under /usr/local/src).

const (
	// PathRoot matches a path that is exactly the filesystem root ("/").
	PathRoot PathClassification = 1 << iota
	// PathHome matches a path that is exactly the current user's home directory.
	PathHome
	// PathSystemDir matches a path that is, or is inside, one of the conventional
	// Unix system directories: /etc, /usr, /bin, /sbin, /lib, /lib64, /boot,
	// /dev, /sys, /proc, /run.
	PathSystemDir
	// PathTempDir matches a path that is, or is inside, a temporary directory
	// (/tmp, /var/tmp, or the value of $TMPDIR).
	PathTempDir
	// PathCwd matches a path that is, or is inside, the current working directory
	// as reported by classifier.ClassificationContext.Cwd.
	PathCwd
	// PathGitRepo matches a path that is, or is inside, the git repository root
	// as reported by classifier.ClassificationContext.RepoRoot.
	PathGitRepo
)

func ClassifyPath added in v1.1.2

ClassifyPath returns a PathClassification bitmask for path. path should already be expanded (via ExpandPath) before calling this function.

type PathCompletionService added in v1.10.0

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

PathCompletionService handles RPC methods for filesystem path completion. It caches directory listings in a DirCache to avoid repeated os.ReadDir calls.

func NewPathCompletionService added in v1.10.0

func NewPathCompletionService() *PathCompletionService

NewPathCompletionService creates a PathCompletionService with a DirCache.

func (*PathCompletionService) ListPathCompletions added in v1.10.0

ListPathCompletions returns filesystem entries matching the given path prefix.

func (*PathCompletionService) ListWorktrees added in v1.12.0

ListWorktrees returns the git worktrees for a given repository path.

type PathMatcher added in v1.1.2

type PathMatcher struct {
	// ArgIndex selects which non-flag argument to evaluate.
	// -1 (the default) means any non-flag argument may satisfy the match.
	// 0 means the first non-flag argument, 1 the second, and so on.
	ArgIndex int

	// MatchIf: at least one selected argument must match one of these
	// classifications for Matches to return true.
	// Zero means this check is skipped (always passes).
	MatchIf PathClassification

	// RejectIf: if any selected argument matches any of these classifications,
	// Matches returns false immediately regardless of MatchIf.
	// Zero means this check is skipped (never rejects).
	RejectIf PathClassification
}

PathMatcher provides structured path-based matching for Bash command arguments. It operates on the expanded (tilde/env-resolved) arguments of a parsed command and can be used alongside CommandPattern and Criteria on a Rule — all set fields must match (AND semantics).

Example — block rm on root or home:

PathMatcher: &PathMatcher{ArgIndex: -1, MatchIf: PathRoot | PathHome}

Example — reject if path is inside /tmp (allow-list inversion):

PathMatcher: &PathMatcher{ArgIndex: 0, RejectIf: PathTempDir}

func (*PathMatcher) Matches added in v1.1.2

func (pm *PathMatcher) Matches(expandedArgs []string, ctx classifier.ClassificationContext) bool

Matches returns true when the path arguments in expandedArgs satisfy the PathMatcher criteria against ctx.

type PendingApproval

type PendingApproval struct {
	ID              string
	SessionID       string // stapler-squad session title (mapped from hook)
	ClaudeSessionID string // Claude Code's internal session_id
	ToolName        string
	ToolInput       map[string]interface{}
	Cwd             string
	PermissionMode  string
	CreatedAt       time.Time
	ExpiresAt       time.Time

	// Orphaned is true for approvals loaded from disk after a server restart.
	// These have no live HTTP connection, so they cannot be resolved via the decision channel.
	Orphaned bool
	// contains filtered or unexported fields
}

PendingApproval represents an in-flight hook approval waiting for a user decision.

type PersistedApproval

type PersistedApproval struct {
	ID              string                 `json:"id"`
	SessionID       string                 `json:"session_id"`
	ClaudeSessionID string                 `json:"claude_session_id"`
	ToolName        string                 `json:"tool_name"`
	ToolInput       map[string]interface{} `json:"tool_input"`
	Cwd             string                 `json:"cwd"`
	PermissionMode  string                 `json:"permission_mode"`
	CreatedAt       time.Time              `json:"created_at"`
	ExpiresAt       time.Time              `json:"expires_at"`
	Orphaned        bool                   `json:"orphaned"`
}

PersistedApproval is the JSON-serializable representation of a PendingApproval for disk storage.

type ProgramStat

type ProgramStat struct {
	Program  string `json:"program"`
	Category string `json:"category"`
	Count    int    `json:"count"`
}

ProgramStat is a command program with its category and usage count.

type ProjectService added in v1.23.0

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

ProjectService handles Project CRUD RPCs.

func NewProjectService added in v1.23.0

func NewProjectService(storage *session.Storage) *ProjectService

NewProjectService creates a ProjectService backed by Storage. Returns nil if storage is nil (test environments).

func (*ProjectService) AssignSessionsToProject added in v1.23.0

AssignSessionsToProject links sessions to a project.

func (*ProjectService) CreateProject added in v1.23.0

CreateProject creates a new project.

func (*ProjectService) DeleteProject added in v1.23.0

DeleteProject removes a project; sessions are unassigned.

func (*ProjectService) ListProjects added in v1.23.0

ListProjects returns all projects.

func (*ProjectService) UpdateProject added in v1.23.0

UpdateProject modifies an existing project.

type PushHandler added in v1.12.0

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

PushHandler handles HTTP endpoints for push notifications

func NewPushHandler added in v1.12.0

func NewPushHandler(pushService *PushService) *PushHandler

NewPushHandler creates a new push notification handler

func (*PushHandler) RegisterRoutes added in v1.12.0

func (h *PushHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers the HTTP endpoints for push notifications

type PushNotification added in v1.12.0

type PushNotification struct {
	Title              string                 `json:"title"`
	Body               string                 `json:"body"`
	Icon               string                 `json:"icon,omitempty"`
	Tag                string                 `json:"tag,omitempty"`
	Data               map[string]interface{} `json:"data,omitempty"`
	RequireInteraction bool                   `json:"requireInteraction,omitempty"`
	Renotify           bool                   `json:"renotify,omitempty"`
}

type PushService added in v1.12.0

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

func NewPushService added in v1.12.0

func NewPushService(configDir string) *PushService

func (*PushService) GetSubscriptions added in v1.12.0

func (ps *PushService) GetSubscriptions() []PushSubscription

func (*PushService) GetVapidPublicKey added in v1.12.0

func (ps *PushService) GetVapidPublicKey() string

func (*PushService) SendNotification added in v1.12.0

func (ps *PushService) SendNotification(notif PushNotification) int

func (*PushService) Subscribe added in v1.12.0

func (ps *PushService) Subscribe(sub PushSubscription) string

func (*PushService) Unsubscribe added in v1.12.0

func (ps *PushService) Unsubscribe(endpoint string) bool

type PushSubscription added in v1.12.0

type PushSubscription struct {
	Endpoint string `json:"endpoint"`
	Keys     struct {
		P256dh string `json:"p256dh"`
		Auth   string `json:"auth"`
	} `json:"keys"`
}

type ReactiveQueueManager

type ReactiveQueueManager interface {
	AddStreamClient(ctx context.Context, filters interface{}) (<-chan *sessionv1.ReviewQueueEvent, string)
	RemoveStreamClient(clientID string)
}

ReactiveQueueManager is an interface to avoid circular dependencies. The actual implementation is in server/review_queue_manager.go

type RecentLogsSnapshot

type RecentLogsSnapshot struct {
	LogFilePath string   `json:"log_file_path"`
	LineCount   int      `json:"line_count"`
	Lines       []string `json:"lines"`
}

RecentLogsSnapshot contains the most recent log lines.

type ReviewQueueChecker

type ReviewQueueChecker interface {
	FindInstance(sessionID string) *session.Instance
	CheckSession(inst *session.Instance)
}

ReviewQueueChecker is an interface for triggering immediate review queue checks. This avoids importing the session package's concrete ReviewQueuePoller type directly.

type ReviewQueueService

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

ReviewQueueService handles all review-queue-related RPC methods, extracted from the monolithic SessionService for separation of concerns.

Dependencies it owns (moved out of SessionService):

  • reviewQueue: stateful queue managed by ReviewQueuePoller
  • reactiveQueueMgr: streams live review queue events to clients

Dependencies it borrows (still on SessionService, passed via setters):

  • storage: needed by AcknowledgeSession to persist ack timestamps
  • reviewQueuePoller: needed by AcknowledgeSession to refresh poller refs
  • eventBus: needed by AcknowledgeSession and LogUserInteraction

func NewReviewQueueService

func NewReviewQueueService(
	reviewQueue *session.ReviewQueue,
	storage *session.Storage,
	eventBus *events.EventBus,
) *ReviewQueueService

NewReviewQueueService creates a ReviewQueueService with the required state.

func (*ReviewQueueService) AcknowledgeSession

AcknowledgeSession marks a session as acknowledged in the review queue. The session won't reappear in the queue until it receives an update.

func (*ReviewQueueService) GetQueue

func (rqs *ReviewQueueService) GetQueue() *session.ReviewQueue

GetQueue returns the underlying ReviewQueue for wiring reactive components.

func (*ReviewQueueService) GetReviewQueue

GetReviewQueue returns sessions needing user attention with priority ordering. Uses the global stateful queue managed by ReviewQueuePoller, with optional filtering.

func (*ReviewQueueService) LogUserInteraction

LogUserInteraction logs a user interaction event for audit trail and analytics.

func (*ReviewQueueService) SetApprovalStore

func (rqs *ReviewQueueService) SetApprovalStore(store *ApprovalStore)

SetApprovalStore injects the ApprovalStore for enriching APPROVAL_PENDING items with their pending_approval_id metadata.

func (*ReviewQueueService) SetReactiveQueueManager

func (rqs *ReviewQueueService) SetReactiveQueueManager(mgr ReactiveQueueManager)

SetReactiveQueueManager injects the ReactiveQueueManager (dependency injection). Must be called before WatchReviewQueue is used.

func (*ReviewQueueService) SetReviewQueuePoller

func (rqs *ReviewQueueService) SetReviewQueuePoller(poller *session.ReviewQueuePoller)

SetReviewQueuePoller injects the ReviewQueuePoller used to refresh instance references after acknowledgement.

func (*ReviewQueueService) WatchReviewQueue

WatchReviewQueue streams real-time review queue events.

type RuleSpec

type RuleSpec struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	ToolName       string    `json:"tool_name,omitempty"`
	ToolPattern    string    `json:"tool_pattern,omitempty"`
	ToolCategory   string    `json:"tool_category,omitempty"`
	CommandPattern string    `json:"command_pattern,omitempty"`
	FilePattern    string    `json:"file_pattern,omitempty"`
	Decision       string    `json:"decision"`   // "auto_allow" | "auto_deny" | "escalate"
	RiskLevel      string    `json:"risk_level"` // "low" | "medium" | "high" | "critical"
	Reason         string    `json:"reason,omitempty"`
	Alternative    string    `json:"alternative,omitempty"`
	Priority       int       `json:"priority"`
	Enabled        bool      `json:"enabled"`
	Source         string    `json:"source"` // "user" | "seed" | "claude-settings"
	CreatedAt      time.Time `json:"created_at"`
}

RuleSpec is the JSON-serializable form of a Rule. CommandPattern and FilePattern are stored as strings (compiled on load).

type RuleStat

type RuleStat struct {
	RuleID   string `json:"rule_id"`
	RuleName string `json:"rule_name"`
	Count    int    `json:"count"`
}

RuleStat is a rule with its trigger count.

type RulesFile

type RulesFile struct {
	Version int        `json:"version"`
	Rules   []RuleSpec `json:"rules"`
}

RulesFile is the top-level structure of auto_approve_rules.json.

type RulesService

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

RulesService handles auto-approval rule management and analytics RPCs.

func NewRulesService

func NewRulesService(rulesStore *RulesStore, analyticsStore *AnalyticsStore, classifier *classifier.RuleBasedClassifier) *RulesService

NewRulesService creates a RulesService.

func (*RulesService) DeleteApprovalRule

DeleteApprovalRule removes a user rule by ID.

func (*RulesService) GetApprovalAnalytics

GetApprovalAnalytics returns aggregated analytics for the requested time window.

func (*RulesService) ListApprovalRules

ListApprovalRules returns all rules: user + seed + claude-settings.

func (*RulesService) UpsertApprovalRule

UpsertApprovalRule creates or updates a user rule.

type RulesStore

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

RulesStore manages user-defined rules persisted to SQLite. Thread-safe for concurrent reads.

func NewRulesStore

func NewRulesStore(storage *session.Storage) (*RulesStore, error)

NewRulesStore creates a RulesStore backed by the given storage.

func (*RulesStore) All

func (s *RulesStore) All() []RuleSpec

All returns user rules as compiled Rules (source="user" only).

func (*RulesStore) Delete

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

Delete removes a user rule by ID. Returns error if not found or not a user rule.

func (*RulesStore) ToRules

func (s *RulesStore) ToRules() []classifier.Rule

ToRules converts specs to compiled Rules, skipping specs with invalid regex.

func (*RulesStore) Upsert

func (s *RulesStore) Upsert(spec RuleSpec) (RuleSpec, error)

Upsert creates or updates a user rule. Source must be "user". Returns the upserted spec.

func (*RulesStore) WatchAndReload

func (s *RulesStore) WatchAndReload(ctx context.Context)

WatchAndReload is now a no-op as we use shared DB.

type SearchService

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

SearchService handles all Claude history and full-text search RPC methods.

It owns the history cache and search engine state that were previously scattered across SessionService.

Bug note: historyCacheMu protects the history cache fields from concurrent access. Without this, concurrent ListClaudeHistory calls would race on cache refresh (previously unprotected on SessionService).

func NewSearchService

func NewSearchService(
	searchEngine *search.SearchEngine,
	snippetGenerator *search.SnippetGenerator,
	historyCacheTTL time.Duration,
) *SearchService

NewSearchService creates a SearchService with the given search components.

func (*SearchService) GetClaudeHistoryDetail

GetClaudeHistoryDetail retrieves detailed information for a specific history entry, including lazily-fetched VCS status for the project directory.

VCS status reuses the same vc.VCSProvider + vcsStatusToProto path that GetVCSStatus uses for running sessions, so the logic is not duplicated.

func (*SearchService) GetClaudeHistoryMessages

GetClaudeHistoryMessages retrieves messages from a specific conversation.

func (*SearchService) ListClaudeHistory

ListClaudeHistory returns Claude session history entries with optional filtering and cursor-based pagination.

Pagination rules:

  • page_size controls how many entries are returned per page (default 100, max 500).
  • page_token, when set, resumes from the position after the last entry on the previous page. Leave it empty for the first page.
  • next_page_token in the response is non-empty when more pages exist; pass it as page_token in the next request.
  • The legacy limit field is honoured when page_size is zero.
  • Filters (project, search_query) must be identical across all pages of a paginated sequence.

func (*SearchService) SearchClaudeHistory

SearchClaudeHistory performs full-text search across Claude conversation history.

type SecretScanResult

type SecretScanResult struct {
	Found       bool
	PatternName string // name of the first matching pattern
}

SecretScanResult holds the result of scanning for secrets.

func ScanForSecrets

func ScanForSecrets(text string) SecretScanResult

ScanForSecrets checks text for known secret patterns. Returns the first match found, or an empty result if none. Only the first 4096 bytes are scanned to bound performance on very long commands.

type ServerInfo

type ServerInfo struct {
	PID           int    `json:"pid"`
	UptimeSeconds int64  `json:"uptime_seconds"`
	GoVersion     string `json:"go_version"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
}

ServerInfo contains runtime metadata for the server process.

type SessionService

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

SessionService implements the SessionServiceHandler interface for ConnectRPC.

func NewSessionService

func NewSessionService(storage session.InstanceStore, eventBus *events.EventBus) *SessionService

NewSessionService creates a new SessionService with the given storage and event bus. NOTE: Instances are NOT loaded here to prevent double-loading and initialization timing issues. Instances will be loaded in server.go after dependencies (statusManager, reviewQueue) are wired.

func NewSessionServiceFromConfig

func NewSessionServiceFromConfig() (*SessionService, error)

NewSessionServiceFromConfig creates a SessionService using EntRepository as storage backend. On first startup, if the legacy state.json exists and Ent DB is empty, sessions are auto-migrated from JSON to Ent.

func (*SessionService) AcknowledgeSession

AcknowledgeSession marks a session as acknowledged in the review queue. The session won't reappear in the queue until it receives an update.

func (*SessionService) AssignSessionsToProject added in v1.23.0

+api: project:assign-sessions AssignSessionsToProject assigns one or more sessions to a project.

func (*SessionService) BatchCreateSessions added in v1.23.0

+api: session:batch-create BatchCreateSessions creates multiple sessions with bounded concurrency (max 3) and per-repo serialization to prevent git worktree races.

func (*SessionService) ClearNotificationHistory

ClearNotificationHistory removes notifications from the history.

func (*SessionService) ClosePR

ClosePR closes the PR without merging for a session.

func (*SessionService) CreateCheckpoint

CreateCheckpoint captures the current state of a session as a named bookmark.

func (*SessionService) CreateDebugSnapshot

CreateDebugSnapshot captures diagnostic information and writes a JSON file to the log directory.

func (*SessionService) CreateProject added in v1.23.0

+api: project:create CreateProject creates a new project for grouping sessions.

func (*SessionService) CreateSession

CreateSession initializes a new AI agent session with tmux and git worktree. +api: session:create

func (*SessionService) DeleteApprovalRule

DeleteApprovalRule removes a user-defined auto-approval rule by ID.

func (*SessionService) DeleteDirectoryRule added in v1.12.0

DeleteDirectoryRule removes a directory rule by path.

func (*SessionService) DeleteProfile added in v1.12.0

DeleteProfile removes a named profile by name.

func (*SessionService) DeleteProject added in v1.23.0

+api: project:delete DeleteProject removes a project (sessions are unassigned, not deleted).

func (*SessionService) DeletePromptHistory added in v1.23.0

+api: session:delete-prompt-history DeletePromptHistory removes a saved prompt from history.

func (*SessionService) DeleteSession

DeleteSession stops and removes a session, cleaning up resources. +api: session:delete

func (*SessionService) FindLiveInstance added in v1.18.0

func (s *SessionService) FindLiveInstance(id string) *session.Instance

FindLiveInstance returns the live in-memory instance held by the ReviewQueuePoller, or nil if the poller is not wired or the session is not found. Use this instead of LoadInstances() for read-only and mutation operations that need the live instance (with its PTY handles and controller state).

func (*SessionService) FocusWindow

FocusWindow activates a window for the specified application.

func (*SessionService) ForkSession

ForkSession creates a new independent session branched from a checkpoint on an existing session.

func (*SessionService) GetAnalyticsStore

func (s *SessionService) GetAnalyticsStore() *AnalyticsStore

GetAnalyticsStore returns the analytics store for wiring up the ApprovalHandler.

func (*SessionService) GetApprovalAnalytics

GetApprovalAnalytics returns aggregated analytics for classification decisions.

func (*SessionService) GetApprovalStore

func (s *SessionService) GetApprovalStore() *ApprovalStore

GetApprovalStore returns the approval store for wiring up the HTTP hook handler.

func (*SessionService) GetClassifier

func (s *SessionService) GetClassifier() *classifier.RuleBasedClassifier

GetClassifier returns the rule-based classifier for wiring up the ApprovalHandler.

func (*SessionService) GetClaudeConfig

GetClaudeConfig retrieves a Claude configuration file by name.

func (*SessionService) GetClaudeHistoryDetail

GetClaudeHistoryDetail retrieves detailed information for a specific history entry.

func (*SessionService) GetClaudeHistoryMessages

GetClaudeHistoryMessages retrieves messages from a specific conversation.

func (*SessionService) GetCurrentDatabase

GetCurrentDatabase returns metadata for the currently active workspace database.

func (*SessionService) GetEventBus

func (s *SessionService) GetEventBus() *events.EventBus

GetEventBus returns the event bus instance for wiring up reactive components.

func (*SessionService) GetFileContent added in v1.11.0

GetFileContent retrieves the text content of a file in a session's worktree.

func (*SessionService) GetInstanceStore added in v1.1.0

func (s *SessionService) GetInstanceStore() session.InstanceStore

GetInstanceStore returns the InstanceStore interface, suitable for both production and test code.

func (*SessionService) GetLogs

GetLogs retrieves application logs with optional filtering and search.

func (*SessionService) GetNotificationHistory

GetNotificationHistory returns persisted notification history with optional filtering.

func (*SessionService) GetNotificationStore

func (s *SessionService) GetNotificationStore() *notifications.NotificationHistoryStore

GetNotificationStore returns the notification history store.

func (*SessionService) GetPRComments

GetPRComments retrieves all comments on the PR for a session.

func (*SessionService) GetPRInfo

GetPRInfo retrieves the latest PR information for a session.

func (*SessionService) GetReviewQueue

GetReviewQueue returns sessions needing user attention with priority ordering.

func (*SessionService) GetReviewQueueInstance

func (s *SessionService) GetReviewQueueInstance() *session.ReviewQueue

GetReviewQueueInstance returns the review queue instance for wiring up reactive components.

func (*SessionService) GetSession

GetSession retrieves a specific session by ID (Title).

func (*SessionService) GetSessionDefaults added in v1.12.0

GetSessionDefaults returns the full session defaults configuration.

func (*SessionService) GetSessionDiff

GetSessionDiff retrieves the current git diff for a session.

func (*SessionService) GetStorage

func (s *SessionService) GetStorage() *session.Storage

GetStorage returns the concrete *session.Storage for components that haven't migrated to InstanceStore yet. Returns nil when SessionService was constructed with a fake InstanceStore (e.g., in unit tests). Prefer using the session.InstanceStore interface via GetInstanceStore() for new code.

func (*SessionService) GetTerminalSnapshot added in v1.14.0

GetTerminalSnapshot returns the last N lines of terminal output for a session. Uses inst.Preview() for a read-only snapshot without requiring an active stream.

func (*SessionService) GetVCSStatus

GetVCSStatus retrieves the current version control status for a session.

func (*SessionService) GetWorkspaceInfo

GetWorkspaceInfo retrieves VCS and workspace information for a session.

func (*SessionService) ListApprovalRules

ListApprovalRules returns all auto-approval rules (user, seed, and claude-settings).

func (*SessionService) ListBranches added in v1.17.0

ListBranches returns the git branches for a given repository path. Results are cached per repo path with a 5-minute TTL. ADR-002.

func (*SessionService) ListCheckpoints

ListCheckpoints returns all checkpoints for the specified session.

func (*SessionService) ListClaudeConfigs

ListClaudeConfigs returns all configuration files in the ~/.claude directory.

func (*SessionService) ListClaudeHistory

ListClaudeHistory returns Claude session history entries with optional filtering.

func (*SessionService) ListDatabases

ListDatabases returns all discovered workspace databases with metadata.

func (*SessionService) ListFiles added in v1.11.0

ListFiles returns the immediate children of a directory in a session's worktree.

func (*SessionService) ListPathCompletions added in v1.10.0

ListPathCompletions returns filesystem entries matching the given path prefix.

func (*SessionService) ListPendingApprovals

ListPendingApprovals returns all pending Claude Code tool approval requests.

func (*SessionService) ListProjects added in v1.23.0

+api: project:list ListProjects returns all projects.

func (*SessionService) ListPromptHistory added in v1.23.0

+api: session:list-prompt-history ListPromptHistory returns saved prompt history entries.

func (*SessionService) ListSessions

ListSessions returns all sessions with optional filtering. This includes both managed sessions and external mux-enabled sessions. +api: session:list

func (*SessionService) ListWorkspaceTargets

ListWorkspaceTargets returns available switch targets for a session. +api: workspace:list-targets

func (*SessionService) ListWorktrees added in v1.12.0

ListWorktrees returns the git worktrees for a given repository path.

func (*SessionService) LogUserInteraction

LogUserInteraction logs a user interaction event for audit trail and analytics.

func (*SessionService) MarkNotificationRead

MarkNotificationRead marks specific notifications as read.

func (*SessionService) MergeDatabase

MergeDatabase copies sessions from a source workspace into the current database.

func (*SessionService) MergePR

MergePR merges the PR for a session using the specified merge method.

func (*SessionService) PostPRComment

PostPRComment posts a new comment to the PR for a session.

func (*SessionService) RemoveFromAllPollers added in v1.18.0

func (s *SessionService) RemoveFromAllPollers(id string)

RemoveFromAllPollers is the exported version for use by MCP tools and other callers outside the services package that need to clean up after deletion.

func (*SessionService) RenameSession

RenameSession changes the title of an existing session. Validates that the new title doesn't conflict with existing sessions.

func (*SessionService) ResolveApproval

ResolveApproval allows the web UI to approve or deny a pending Claude Code tool use request.

func (*SessionService) ResolveDefaults added in v1.12.0

ResolveDefaults merges all default layers for the given working directory and profile.

func (*SessionService) RestartSession

RestartSession restarts a session by killing and recreating the tmux session. Optionally preserves terminal output for debugging purposes.

func (*SessionService) RunOneShot added in v1.23.0

+api: session:run-one-shot RunOneShot executes `claude -p <prompt>` in the session's worktree and returns the combined output along with an extracted PR URL and branch divergence status.

func (*SessionService) SearchClaudeHistory

SearchClaudeHistory performs full-text search across Claude conversation history. +api: history:search

func (*SessionService) SearchFiles added in v1.12.0

SearchFiles performs a recursive name-substring search in a session's worktree.

func (*SessionService) SendNotification

SendNotification allows tmux sessions and external Claude processes to send notifications.

func (*SessionService) SetConfigService

func (s *SessionService) SetConfigService(svc *ConfigService)

SetConfigService wires the ConfigService for delegating config RPCs.

func (*SessionService) SetExternalDiscovery

func (s *SessionService) SetExternalDiscovery(discovery *session.ExternalSessionDiscovery)

SetExternalDiscovery sets the external session discovery for accessing mux-enabled sessions.

func (*SessionService) SetHistoryLinker added in v1.23.1

func (s *SessionService) SetHistoryLinker(hl *session.HistoryLinker)

SetHistoryLinker wires the HistoryLinker so deleted sessions are also removed from it and cannot be re-persisted by the shutdown hook.

func (*SessionService) SetMCPServerURL added in v1.17.0

func (s *SessionService) SetMCPServerURL(url string)

SetMCPServerURL configures the HTTP MCP endpoint URL passed to new sessions. Call this during server startup after the listen address is known.

func (*SessionService) SetNotificationStore

func (s *SessionService) SetNotificationStore(store *notifications.NotificationHistoryStore)

SetNotificationStore sets the notification history store for the notification history RPCs and wires it into the approval service so resolved approvals are stamped with their decision.

func (*SessionService) SetReactiveQueueManager

func (s *SessionService) SetReactiveQueueManager(mgr ReactiveQueueManager)

SetReactiveQueueManager sets the ReactiveQueueManager (dependency injection). This must be called before WatchReviewQueue is used.

func (*SessionService) SetReviewQueuePoller

func (s *SessionService) SetReviewQueuePoller(poller *session.ReviewQueuePoller)

SetReviewQueuePoller wires the ReviewQueuePoller so new/deleted sessions are added/removed from the poller and AcknowledgeSession updates poller references. Must be called during server startup before any session mutation RPCs are used.

func (*SessionService) SetScrollbackManager

func (s *SessionService) SetScrollbackManager(mgr scrollbackSequencer)

SetScrollbackManager wires a scrollback sequence provider for checkpoint creation.

func (*SessionService) SetStatusManager

func (s *SessionService) SetStatusManager(mgr *session.InstanceStatusManager)

SetStatusManager wires the InstanceStatusManager so that instances loaded via loadInstancesWithWiring (e.g., fallback path in ListSessions) receive status tracking. Must be called during server startup.

func (*SessionService) StreamTerminal

StreamTerminal provides bidirectional streaming for terminal I/O with delta compression. Implements bidirectional streaming where: - Client sends: terminal input and resize events - Server sends: terminal deltas (compressed output) or raw output (fallback)

func (*SessionService) SwitchDatabase

SwitchDatabase switches to a different workspace database and restarts the server.

func (*SessionService) SwitchWorkspace

SwitchWorkspace switches a session's workspace to a different branch, revision, or worktree. +api: workspace:switch

func (*SessionService) UpdateClaudeConfig

UpdateClaudeConfig updates a Claude configuration file with atomic write and backup.

func (*SessionService) UpdateGlobalDefaults added in v1.12.0

UpdateGlobalDefaults replaces the global default fields.

func (*SessionService) UpdateProject added in v1.23.0

+api: project:update UpdateProject updates an existing project's metadata.

func (*SessionService) UpdateSession

UpdateSession modifies session properties (pause/resume, category, title). +api: session:update

func (*SessionService) UpsertApprovalRule

UpsertApprovalRule creates or updates a user-defined auto-approval rule.

func (*SessionService) UpsertDirectoryRule added in v1.12.0

UpsertDirectoryRule creates or updates a directory rule.

func (*SessionService) UpsertProfile added in v1.12.0

UpsertProfile creates or updates a named profile.

func (*SessionService) WatchReviewQueue

WatchReviewQueue streams real-time review queue events.

func (*SessionService) WatchSessions

WatchSessions streams real-time session events (created/updated/deleted). Sends initial snapshot of all sessions, then subscribes to real-time updates. +api: session:watch

type SessionSnapshot

type SessionSnapshot struct {
	Title                string    `json:"title"`
	Status               string    `json:"status"`
	Program              string    `json:"program"`
	Path                 string    `json:"path"`
	Branch               string    `json:"branch"`
	SessionType          string    `json:"session_type"`
	Category             string    `json:"category"`
	Tags                 []string  `json:"tags"`
	CreatedAt            time.Time `json:"created_at"`
	UpdatedAt            time.Time `json:"updated_at"`
	LastTerminalUpdate   time.Time `json:"last_terminal_update,omitempty"`
	LastMeaningfulOutput time.Time `json:"last_meaningful_output,omitempty"`
	LastOutputSignature  string    `json:"last_output_signature,omitempty"`
	PaneContent          string    `json:"pane_content,omitempty"`
	PaneContentRaw       string    `json:"pane_content_raw,omitempty"`
	PaneContentTruncated bool      `json:"pane_content_truncated,omitempty"`
	InstanceType         string    `json:"instance_type"`
	GitHubPRNumber       int       `json:"github_pr_number,omitempty"`
}

SessionSnapshot captures the state of a single session at snapshot time.

type SessionStreamer added in v1.15.0

type SessionStreamer interface {
	StartControlMode() error
	StopControlMode() error
	SubscribeControlModeUpdates() (string, <-chan []byte)
	UnsubscribeControlModeUpdates(id string)
}

SessionStreamer is the interface the WebSocket streaming handler requires from a session. Defined in the consumer package (server/services) to prevent import cycles and to keep the interface minimal — only what this package legitimately needs for terminal streaming.

*session.Instance satisfies this interface via delegation methods.

type SubcommandStat

type SubcommandStat struct {
	Program    string `json:"program"`
	Subcommand string `json:"subcommand"`
	Category   string `json:"category"`
	Count      int    `json:"count"`
}

SubcommandStat is a (program, subcommand) pair with its usage count. Subcommand may contain a space for two-level CLIs (e.g., "pr create" for gh).

type TerminalWebSocketHandler

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

TerminalWebSocketHandler handles WebSocket connections for terminal streaming

func NewTerminalWebSocketHandler

func NewTerminalWebSocketHandler(storage session.Storage, eventBus *events.EventBus) *TerminalWebSocketHandler

NewTerminalWebSocketHandler creates a new WebSocket handler for terminal streaming

func (*TerminalWebSocketHandler) HandleWebSocket

func (h *TerminalWebSocketHandler) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket upgrades HTTP connection to WebSocket and handles terminal streaming

type TmuxSessionDetail

type TmuxSessionDetail struct {
	TmuxSessionName string `json:"tmux_session_name"`
	ListPanesOutput string `json:"list_panes_output,omitempty"`
	PaneContent     string `json:"pane_content,omitempty"`
}

TmuxSessionDetail captures per-tmux-session diagnostic info.

type TmuxSnapshot

type TmuxSnapshot struct {
	ListSessionsOutput string              `json:"list_sessions_output"`
	PerSession         []TmuxSessionDetail `json:"per_session"`
}

TmuxSnapshot captures global tmux state.

type ToolStat

type ToolStat struct {
	ToolName string `json:"tool_name"`
	Count    int    `json:"count"`
}

ToolStat is a tool name with a count.

type UnfinishedWorkService added in v1.22.0

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

UnfinishedWorkService implements the ConnectRPC UnfinishedWorkServiceHandler.

func NewUnfinishedWorkService added in v1.22.0

func NewUnfinishedWorkService(
	scanner *unfinished.Scanner,
	stateStore *unfinished.StateStore,
	eventBus *events.EventBus,
	storage *session.Storage,
) *UnfinishedWorkService

NewUnfinishedWorkService creates a new service instance.

func (*UnfinishedWorkService) DismissWorktree added in v1.22.0

DismissWorktree permanently hides a worktree from results.

func (*UnfinishedWorkService) GetUnfinishedWorkConfig added in v1.22.0

GetUnfinishedWorkConfig returns the current source configuration.

func (*UnfinishedWorkService) GetWorktreeAISummary added in v1.22.0

GetWorktreeAISummary generates or returns a cached AI summary.

func (*UnfinishedWorkService) ListUnfinishedWork added in v1.22.0

ListUnfinishedWork returns the current snapshot of all unfinished worktrees.

func (*UnfinishedWorkService) QuickCommitPush added in v1.22.0

QuickCommitPush stages all changes, commits, and pushes.

func (*UnfinishedWorkService) ScanUnfinishedWork added in v1.22.0

ScanUnfinishedWork triggers an immediate scan.

func (*UnfinishedWorkService) SnoozeWorktree added in v1.22.0

SnoozeWorktree hides a worktree until the next HEAD SHA change.

func (*UnfinishedWorkService) UndismissWorktree added in v1.22.0

UndismissWorktree removes the dismiss record.

func (*UnfinishedWorkService) UpdateUnfinishedWorkConfig added in v1.22.0

UpdateUnfinishedWorkConfig replaces the source configuration.

func (*UnfinishedWorkService) WatchUnfinishedWork added in v1.22.0

WatchUnfinishedWork streams real-time updates to connected clients. Pattern: send initial snapshot → subscribe to EventBus → forward events until disconnect.

type UtilityService

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

UtilityService handles miscellaneous utility RPCs: GetLogs, FocusWindow, and CreateDebugSnapshot.

Dependencies:

  • approvalStore: needed by CreateDebugSnapshot to capture pending approvals
  • reviewQueuePoller: late-wired; needed by CreateDebugSnapshot for live instances

func NewUtilityService

func NewUtilityService(approvalStore *ApprovalStore) *UtilityService

NewUtilityService creates a UtilityService with the given dependencies.

func (*UtilityService) CreateDebugSnapshot

CreateDebugSnapshot captures diagnostic information and writes a JSON file to the log directory.

func (*UtilityService) FocusWindow

FocusWindow activates a window for the specified application. Uses AppleScript on macOS to bring the application to front.

func (*UtilityService) GetLogs

GetLogs retrieves application logs with optional filtering and search.

func (*UtilityService) SetReviewQueuePoller

func (us *UtilityService) SetReviewQueuePoller(poller *session.ReviewQueuePoller)

SetReviewQueuePoller sets the review queue poller (late-wired).

type WatchReviewQueueFilters

type WatchReviewQueueFilters struct {
	PriorityFilter    []session.Priority
	ReasonFilter      []session.AttentionReason
	SessionIDs        []string
	IncludeStatistics bool
	InitialSnapshot   bool
}

WatchReviewQueueFilters contains filters for review queue event streaming.

func (*WatchReviewQueueFilters) GetIncludeStatistics

func (f *WatchReviewQueueFilters) GetIncludeStatistics() bool

func (*WatchReviewQueueFilters) GetInitialSnapshot

func (f *WatchReviewQueueFilters) GetInitialSnapshot() bool

func (*WatchReviewQueueFilters) GetPriorityFilter

func (f *WatchReviewQueueFilters) GetPriorityFilter() []session.Priority

Implement FilterProvider interface for type-safe conversion.

func (*WatchReviewQueueFilters) GetReasonFilter

func (f *WatchReviewQueueFilters) GetReasonFilter() []session.AttentionReason

func (*WatchReviewQueueFilters) GetSessionIDs

func (f *WatchReviewQueueFilters) GetSessionIDs() []string

type WorkspaceProvider added in v1.12.0

type WorkspaceProvider interface {
	GetWorkspace(sessionID string) (session.Workspace, error)
}

WorkspaceProvider resolves workspace path information for a session. Inject this interface into services that need path resolution instead of accessing session.Instance.Path directly.

type WorkspaceService

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

WorkspaceService handles all VCS/workspace RPC methods.

These methods operate on session workspace state (git/jj status, branch switching, worktrees) and may emit events after state-modifying operations.

func NewWorkspaceService

func NewWorkspaceService(storage *session.Storage, eventBus *events.EventBus) *WorkspaceService

NewWorkspaceService creates a WorkspaceService with the given dependencies.

func (*WorkspaceService) GetVCSStatus

GetVCSStatus retrieves the current version control status for a session.

func (*WorkspaceService) GetWorkspace added in v1.12.0

func (ws *WorkspaceService) GetWorkspace(sessionID string) (session.Workspace, error)

GetWorkspace implements WorkspaceProvider.

func (*WorkspaceService) GetWorkspaceInfo

GetWorkspaceInfo retrieves VCS and workspace information for a session.

func (*WorkspaceService) ListWorkspaceTargets

ListWorkspaceTargets returns available switch targets for a session.

func (*WorkspaceService) SwitchWorkspace

SwitchWorkspace switches a session's workspace to a different branch, revision, or worktree.

Jump to

Keyboard shortcuts

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