Documentation
¶
Index ¶
- func ConnectOptions() []connect.HandlerOption
- func LoadTLSConfig(certFile, keyFile string) (*tls.Config, error)
- type CoreDeps
- type FilterProvider
- type ReactiveQueueManager
- func (rqm *ReactiveQueueManager) AddStreamClient(ctx context.Context, filtersInterface interface{}) (<-chan *sessionv1.ReviewQueueEvent, string)
- func (rqm *ReactiveQueueManager) OnItemAdded(item *session.ReviewItem)
- func (rqm *ReactiveQueueManager) OnItemRemoved(sessionID string)
- func (rqm *ReactiveQueueManager) OnQueueUpdated(items []*session.ReviewItem)
- func (rqm *ReactiveQueueManager) RemoveStreamClient(clientID string)
- func (rqm *ReactiveQueueManager) Start(ctx context.Context)
- func (rqm *ReactiveQueueManager) Stop()
- type RuntimeDeps
- type Server
- func (s *Server) GetAddr() string
- func (s *Server) GetHostnames() []string
- func (s *Server) GetOrigins() []string
- func (s *Server) Mux() *http.ServeMux
- func (s *Server) RegisterConnectHandler(path string, handler http.Handler)
- func (s *Server) RegisterHTTPHandler(pattern string, handler http.Handler)
- func (s *Server) SetHTTPSURL(url string)
- func (s *Server) SetHostnames(hostnames []string)
- func (s *Server) SetOrigins(origins []string)
- func (s *Server) SetupAuth(authMiddleware func(http.Handler) http.Handler)
- func (s *Server) SetupTLS(cfg *tls.Config)
- func (s *Server) Shutdown() error
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) StartRemote(ctx context.Context, remoteAddr string, tlsCfg *tls.Config, ...) error
- type ServerDependencies
- type ServiceDeps
- type TLSPaths
- type WatchReviewQueueFilters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectOptions ¶
func ConnectOptions() []connect.HandlerOption
ConnectOptions returns standard ConnectRPC options with OpenTelemetry instrumentation.
Types ¶
type CoreDeps ¶
type CoreDeps struct {
SessionService *services.SessionService
Storage *session.Storage
EventBus *events.EventBus
ReviewQueue *session.ReviewQueue
ApprovalStore *services.ApprovalStore
}
CoreDeps holds the foundational dependencies created during Phase 1. These have no external prerequisites and form the base for all other components.
func BuildCoreDeps ¶
BuildCoreDeps constructs Phase 1 dependencies: SessionService and its internal components (Storage, EventBus, ReviewQueue, ApprovalStore).
type FilterProvider ¶
type FilterProvider interface {
GetPriorityFilter() []session.Priority
GetReasonFilter() []session.AttentionReason
GetSessionIDs() []string
GetIncludeStatistics() bool
GetInitialSnapshot() bool
}
FilterProvider is an interface that provides filter values for type-safe conversion
type ReactiveQueueManager ¶
type ReactiveQueueManager struct {
// contains filtered or unexported fields
}
ReactiveQueueManager manages the review queue with immediate reactivity to user interactions. It listens to interaction events and immediately re-evaluates the queue instead of waiting for the next poll cycle, providing <100ms feedback to users.
func NewReactiveQueueManager ¶
func NewReactiveQueueManager( queue *session.ReviewQueue, poller *session.ReviewQueuePoller, eventBus *events.EventBus, statusManager *session.InstanceStatusManager, storage *session.Storage, ) *ReactiveQueueManager
NewReactiveQueueManager creates a new reactive queue manager.
func (*ReactiveQueueManager) AddStreamClient ¶
func (rqm *ReactiveQueueManager) AddStreamClient(ctx context.Context, filtersInterface interface{}) (<-chan *sessionv1.ReviewQueueEvent, string)
AddStreamClient adds a new streaming client for WatchReviewQueue.
func (*ReactiveQueueManager) OnItemAdded ¶
func (rqm *ReactiveQueueManager) OnItemAdded(item *session.ReviewItem)
OnItemAdded is called when an item is added to the queue.
func (*ReactiveQueueManager) OnItemRemoved ¶
func (rqm *ReactiveQueueManager) OnItemRemoved(sessionID string)
OnItemRemoved is called when an item is removed from the queue.
func (*ReactiveQueueManager) OnQueueUpdated ¶
func (rqm *ReactiveQueueManager) OnQueueUpdated(items []*session.ReviewItem)
OnQueueUpdated is called when the queue is updated.
func (*ReactiveQueueManager) RemoveStreamClient ¶
func (rqm *ReactiveQueueManager) RemoveStreamClient(clientID string)
RemoveStreamClient removes a streaming client.
func (*ReactiveQueueManager) Start ¶
func (rqm *ReactiveQueueManager) Start(ctx context.Context)
Start initializes the reactive queue manager and subscribes to events.
func (*ReactiveQueueManager) Stop ¶
func (rqm *ReactiveQueueManager) Stop()
Stop stops the reactive queue manager.
type RuntimeDeps ¶
type RuntimeDeps struct {
*ServiceDeps
Instances []*session.Instance
ReactiveQueueMgr *ReactiveQueueManager
ScrollbackManager *scrollback.ScrollbackManager
TmuxStreamerManager *session.ExternalTmuxStreamerManager
ExternalDiscovery *session.ExternalSessionDiscovery
ExternalApprovalMonitor *session.ExternalApprovalMonitor
PRStatusPoller *session.PRStatusPoller
HistoryLinker *session.HistoryLinker
// Unfinished work scanning.
UnfinishedScanner *unfinished.Scanner
UnfinishedStateStore *unfinished.StateStore
UnfinishedWorkService *services.UnfinishedWorkService
}
RuntimeDeps holds Phase 3 dependencies: runtime components that involve process creation, filesystem I/O, and callback wiring.
func BuildRuntimeDeps ¶
func BuildRuntimeDeps(svc *ServiceDeps) (*RuntimeDeps, error)
BuildRuntimeDeps constructs Phase 3 dependencies using Phase 2 outputs. This implements steps 5-12 from the original BuildDependencies:
- Step 5: LoadInstances + wire ReviewQueue/StatusManager on each instance
- Step 6: Start tmux sessions for loaded instances (non-fatal failures)
- Step 6.5: Persist auto-detected worktree info
- Step 7: Start controllers for running instances
- Step 7.5: Startup scan + orphaned approval sync
- Step 8: ReactiveQueueManager + wire into SessionService
- Step 9: ScrollbackManager (independent)
- Step 10: TmuxStreamerManager (independent)
- Step 11: ExternalDiscovery with session-added/removed callbacks
- Step 12: ExternalApprovalMonitor with approval-to-review-queue bridge
- SetExternalDiscovery on SessionService (moved from server.go)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server manages the HTTP server with ConnectRPC handlers.
func NewServer ¶
NewServer creates a new HTTP server instance with SessionService registered.
Initialization Order (dependencies flow downward):
- SessionService — creates Storage (Ent-backed), EventBus, ReviewQueue
- StatusManager — depends on nothing; created before instances load
- ReviewQueuePoller — depends on ReviewQueue, StatusManager, Storage
- Instance wiring — LoadInstances, SetReviewQueue + SetStatusManager on each
- Instance.Start() — starts tmux sessions; requires wired dependencies
- Controller startup — requires started instances and StatusManager
- ReactiveQueueMgr — depends on ReviewQueue, Poller, EventBus, StatusManager, Storage
- ScrollbackManager — independent; depends only on filesystem paths
- TmuxStreamerManager — independent
11. ExternalDiscovery — depends on Storage, ReviewQueue, StatusManager, Poller (via callbacks) 12. ExternalApprovalMonitor — depends on ExternalDiscovery
Violating this order causes nil pointer panics or silent failures. Dependency construction is encapsulated in BuildDependencies (server/dependencies.go). See docs/tasks/architecture-refactor.md for the ongoing simplification plan.
func (*Server) GetHostnames ¶
GetHostnames returns the detected LAN hostnames.
func (*Server) GetOrigins ¶
GetOrigins returns the allowed CORS origins.
func (*Server) Mux ¶
Mux returns the HTTP request multiplexer so callers can register additional routes before calling Start().
func (*Server) RegisterConnectHandler ¶
RegisterConnectHandler registers a ConnectRPC service handler. This should be called before Start().
func (*Server) RegisterHTTPHandler ¶
RegisterHTTPHandler registers a standard HTTP handler. Useful for health checks, static files, etc.
func (*Server) SetHTTPSURL ¶
SetHTTPSURL records the public HTTPS URL for this server (used by /api/server-info). Call this after remote access is configured in main.go.
func (*Server) SetHostnames ¶
SetHostnames records the detected LAN hostnames for this server.
func (*Server) SetOrigins ¶
SetOrigins records the allowed CORS origins.
func (*Server) SetupAuth ¶
SetupAuth installs authentication middleware. Must be called before Start(). authMiddleware is a function that wraps an http.Handler; pass nil to disable.
func (*Server) SetupTLS ¶
SetupTLS configures the server to use TLS with the provided tls.Config. Must be called before Start().
func (*Server) Start ¶
Start starts the HTTP server with middleware chain. This is a blocking call. Use Start() in a goroutine for concurrent operation.
func (*Server) StartRemote ¶
func (s *Server) StartRemote(ctx context.Context, remoteAddr string, tlsCfg *tls.Config, authMW func(http.Handler) http.Handler) error
StartRemote starts a second HTTPS server on remoteAddr, sharing the same route mux as the local server but protected by TLS and auth middleware. It binds eagerly (returns a bind error immediately if the port is in use), then runs the server in a background goroutine until ctx is cancelled.
type ServerDependencies ¶
type ServerDependencies struct {
SessionService *services.SessionService
Storage *session.Storage
Instances []*session.Instance
EventBus *events.EventBus
StatusManager *session.InstanceStatusManager
ReviewQueue *session.ReviewQueue
ReviewQueuePoller *session.ReviewQueuePoller
PRStatusPoller *session.PRStatusPoller
ReactiveQueueMgr *ReactiveQueueManager
ScrollbackManager *scrollback.ScrollbackManager
TmuxStreamerManager *session.ExternalTmuxStreamerManager
ExternalDiscovery *session.ExternalSessionDiscovery
ExternalApprovalMonitor *session.ExternalApprovalMonitor
HistoryLinker *session.HistoryLinker
// Unfinished work scanning.
UnfinishedScanner *unfinished.Scanner
UnfinishedStateStore *unfinished.StateStore
UnfinishedWorkService *services.UnfinishedWorkService
}
ServerDependencies holds all wired service components for the HTTP server. Use BuildDependencies to construct and wire them in the correct order. See the initialization order comment on NewServer for dependency constraints.
func BuildDependencies ¶
func BuildDependencies() (*ServerDependencies, error)
BuildDependencies constructs and wires all server dependencies in the correct order. Returns an error only for unrecoverable failures (SessionService init, Storage start). Non-fatal failures (individual instance start) are logged and skipped.
Delegates to the three-phase constructors: BuildCoreDeps -> BuildServiceDeps -> BuildRuntimeDeps.
type ServiceDeps ¶
type ServiceDeps struct {
*CoreDeps
StatusManager *session.InstanceStatusManager
ReviewQueuePoller *session.ReviewQueuePoller
PRStatusPoller *session.PRStatusPoller
}
ServiceDeps holds Phase 2 dependencies: management components that depend on CoreDeps.
func BuildServiceDeps ¶
func BuildServiceDeps(core *CoreDeps) (*ServiceDeps, error)
BuildServiceDeps constructs Phase 2 dependencies using Phase 1 outputs. Compile-time guarantee: cannot be called without a *CoreDeps.
type TLSPaths ¶
TLSPaths holds the file paths for the generated TLS certificate set.
func EnsureTLSCerts ¶
EnsureTLSCerts generates a self-signed CA and server certificate when the stored SAN hash doesn't match the current hostname list or the cert is nearing expiry. Returns paths to the cert files.
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
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analytics provides terminal escape code extraction and analysis
|
Package analytics provides terminal escape code extraction and analysis |
|
Package mcp implements the MCP (Model Context Protocol) server for Stapler Squad.
|
Package mcp implements the MCP (Model Context Protocol) server for Stapler Squad. |
|
Package services provides the server-side service implementations.
|
Package services provides the server-side service implementations. |
|
Package ssp implements the State Synchronization Protocol (SSP) for efficient terminal streaming.
|
Package ssp implements the State Synchronization Protocol (SSP) for efficient terminal streaming. |