tui

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicDevctlEvents = "devctl.events"
	TopicUIMessages   = "devctl.ui.msgs"
	TopicUIActions    = "devctl.ui.actions"
)
View Source
const (
	DomainTypeStateSnapshot = "state.snapshot"
	DomainTypeServiceExit   = "service.exit.observed"
	DomainTypeActionLog     = "action.log"

	DomainTypePipelineRunStarted     = "pipeline.run.started"
	DomainTypePipelineRunFinished    = "pipeline.run.finished"
	DomainTypePipelinePhaseStarted   = "pipeline.phase.started"
	DomainTypePipelinePhaseFinished  = "pipeline.phase.finished"
	DomainTypePipelineBuildResult    = "pipeline.build.result"
	DomainTypePipelinePrepareResult  = "pipeline.prepare.result"
	DomainTypePipelineValidateResult = "pipeline.validate.result"
	DomainTypePipelineLaunchPlan     = "pipeline.launch.plan"

	DomainTypeStreamStarted = "stream.started"
	DomainTypeStreamEvent   = "stream.event"
	DomainTypeStreamEnded   = "stream.ended"
)
View Source
const (
	UITypeStateSnapshot = "tui.state.snapshot"
	UITypeEventAppend   = "tui.event.append"
	UITypeActionRequest = "tui.action.request"

	UITypePipelineRunStarted     = "tui.pipeline.run.started"
	UITypePipelineRunFinished    = "tui.pipeline.run.finished"
	UITypePipelinePhaseStarted   = "tui.pipeline.phase.started"
	UITypePipelinePhaseFinished  = "tui.pipeline.phase.finished"
	UITypePipelineBuildResult    = "tui.pipeline.build.result"
	UITypePipelinePrepareResult  = "tui.pipeline.prepare.result"
	UITypePipelineValidateResult = "tui.pipeline.validate.result"
	UITypePipelineLaunchPlan     = "tui.pipeline.launch.plan"

	UITypeStreamStartRequest = "tui.stream.start"
	UITypeStreamStopRequest  = "tui.stream.stop"
	UITypeStreamStarted      = "tui.stream.started"
	UITypeStreamEvent        = "tui.stream.event"
	UITypeStreamEnded        = "tui.stream.ended"
)

Variables

This section is empty.

Functions

func PublishAction

func PublishAction(pub message.Publisher, req ActionRequest) error

func PublishStreamStart

func PublishStreamStart(pub message.Publisher, req StreamStartRequest) error

func PublishStreamStop

func PublishStreamStop(pub message.Publisher, req StreamStopRequest) error

func RegisterDomainToUITransformer

func RegisterDomainToUITransformer(bus *Bus)

func RegisterUIActionRunner

func RegisterUIActionRunner(tuiCtx context.Context, bus *Bus, opts RootOptions)

func RegisterUIForwarder

func RegisterUIForwarder(bus *Bus, p *tea.Program)

func RegisterUIStreamRunner

func RegisterUIStreamRunner(tuiCtx context.Context, bus *Bus, opts RootOptions)

Types

type ActionKind

type ActionKind string
const (
	ActionUp      ActionKind = "up"
	ActionDown    ActionKind = "down"
	ActionRestart ActionKind = "restart"
	ActionStop    ActionKind = "stop" // Stop a specific service
)

type ActionLog

type ActionLog struct {
	At   time.Time `json:"at"`
	Text string    `json:"text"`
}

type ActionRequest

type ActionRequest struct {
	Kind    ActionKind `json:"kind"`
	At      time.Time  `json:"at"`
	Service string     `json:"service,omitempty"` // Optional: target specific service
}

type ActionRequestMsg

type ActionRequestMsg struct {
	Request ActionRequest
}

type Bus

type Bus struct {
	Router     *message.Router
	Publisher  message.Publisher
	Subscriber message.Subscriber
	// contains filtered or unexported fields
}

func NewInMemoryBus

func NewInMemoryBus() (*Bus, error)

func (*Bus) AddHandler

func (b *Bus) AddHandler(name, topic string, handler func(*message.Message) error)

func (*Bus) Run

func (b *Bus) Run(ctx context.Context) error

type ConfigPatch

type ConfigPatch struct {
	Plugin string `json:"plugin"`
	Key    string `json:"key"`   // dotted path, e.g., "services.backend.port"
	Value  string `json:"value"` // string representation of the value
}

ConfigPatch represents a configuration mutation applied by a plugin.

type Envelope

type Envelope struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

func NewEnvelope

func NewEnvelope(typ string, payload any) (Envelope, error)

func (Envelope) MarshalJSONBytes

func (e Envelope) MarshalJSONBytes() ([]byte, error)

type EventLogAppendMsg

type EventLogAppendMsg struct {
	Entry EventLogEntry
}

type EventLogEntry

type EventLogEntry struct {
	At     time.Time `json:"at"`
	Source string    `json:"source,omitempty"`
	Level  LogLevel  `json:"level,omitempty"`
	Text   string    `json:"text"`
}

type HealthCheckResult

type HealthCheckResult struct {
	ServiceName string       `json:"service_name"`
	Status      HealthStatus `json:"status"`
	LastCheck   time.Time    `json:"last_check"`
	CheckType   string       `json:"check_type,omitempty"` // "tcp", "http", "exec"
	Endpoint    string       `json:"endpoint,omitempty"`   // e.g., "http://localhost:8080/health"
	Error       string       `json:"error,omitempty"`
	ResponseMs  int64        `json:"response_ms,omitempty"`
}

HealthCheckResult contains the result of a service health check.

type HealthStatus

type HealthStatus string

HealthStatus represents the health check status of a service.

const (
	HealthUnknown   HealthStatus = "unknown"
	HealthHealthy   HealthStatus = "healthy"
	HealthUnhealthy HealthStatus = "unhealthy"
)

type LogLevel

type LogLevel string
const (
	LogLevelDebug LogLevel = "DEBUG"
	LogLevelInfo  LogLevel = "INFO"
	LogLevelWarn  LogLevel = "WARN"
	LogLevelError LogLevel = "ERROR"
)
type NavigateBackMsg struct{}
type NavigateToServiceMsg struct {
	Name string
}

type PipelineBuildResult

type PipelineBuildResult struct {
	RunID     string               `json:"run_id"`
	At        time.Time            `json:"at"`
	Steps     []PipelineStepResult `json:"steps,omitempty"`
	Artifacts map[string]string    `json:"artifacts,omitempty"`
}

type PipelineBuildResultMsg

type PipelineBuildResultMsg struct {
	Result PipelineBuildResult
}

type PipelineConfigPatches

type PipelineConfigPatches struct {
	RunID   string        `json:"run_id"`
	Patches []ConfigPatch `json:"patches"`
}

PipelineConfigPatches represents config patches applied during a pipeline run.

type PipelineConfigPatchesMsg

type PipelineConfigPatchesMsg struct {
	Patches PipelineConfigPatches
}

PipelineConfigPatchesMsg carries config patches applied during a pipeline run.

type PipelineLaunchPlan

type PipelineLaunchPlan struct {
	RunID    string    `json:"run_id"`
	At       time.Time `json:"at"`
	Services []string  `json:"services,omitempty"`
}

type PipelineLaunchPlanMsg

type PipelineLaunchPlanMsg struct {
	Plan PipelineLaunchPlan
}

type PipelineLiveOutput

type PipelineLiveOutput struct {
	RunID  string `json:"run_id"`
	Source string `json:"source"` // step name
	Line   string `json:"line"`
	Stream string `json:"stream"` // "stdout" or "stderr"
}

PipelineLiveOutput represents a line of live output from a build step.

type PipelineLiveOutputMsg

type PipelineLiveOutputMsg struct {
	Output PipelineLiveOutput
}

PipelineLiveOutputMsg carries a line of live output from a build step.

type PipelinePhase

type PipelinePhase string
const (
	PipelinePhaseMutateConfig PipelinePhase = "mutate_config"
	PipelinePhaseBuild        PipelinePhase = "build"
	PipelinePhasePrepare      PipelinePhase = "prepare"
	PipelinePhaseValidate     PipelinePhase = "validate"
	PipelinePhaseLaunchPlan   PipelinePhase = "launch_plan"
	PipelinePhaseSupervise    PipelinePhase = "supervise"
	PipelinePhaseStateSave    PipelinePhase = "state_save"

	PipelinePhaseStopSupervise PipelinePhase = "stop_supervise"
	PipelinePhaseRemoveState   PipelinePhase = "remove_state"
)

type PipelinePhaseFinished

type PipelinePhaseFinished struct {
	RunID      string        `json:"run_id"`
	Phase      PipelinePhase `json:"phase"`
	At         time.Time     `json:"at"`
	Ok         bool          `json:"ok"`
	DurationMs int64         `json:"duration_ms,omitempty"`
	Error      string        `json:"error,omitempty"`
}

type PipelinePhaseFinishedMsg

type PipelinePhaseFinishedMsg struct {
	Event PipelinePhaseFinished
}

type PipelinePhaseStarted

type PipelinePhaseStarted struct {
	RunID string        `json:"run_id"`
	Phase PipelinePhase `json:"phase"`
	At    time.Time     `json:"at"`
}

type PipelinePhaseStartedMsg

type PipelinePhaseStartedMsg struct {
	Event PipelinePhaseStarted
}

type PipelinePrepareResult

type PipelinePrepareResult struct {
	RunID     string               `json:"run_id"`
	At        time.Time            `json:"at"`
	Steps     []PipelineStepResult `json:"steps,omitempty"`
	Artifacts map[string]string    `json:"artifacts,omitempty"`
}

type PipelinePrepareResultMsg

type PipelinePrepareResultMsg struct {
	Result PipelinePrepareResult
}

type PipelineRunFinished

type PipelineRunFinished struct {
	RunID      string     `json:"run_id"`
	Kind       ActionKind `json:"kind"`
	RepoRoot   string     `json:"repo_root"`
	At         time.Time  `json:"at"`
	Ok         bool       `json:"ok"`
	DurationMs int64      `json:"duration_ms,omitempty"`
	Error      string     `json:"error,omitempty"`
}

type PipelineRunFinishedMsg

type PipelineRunFinishedMsg struct {
	Run PipelineRunFinished
}

type PipelineRunStarted

type PipelineRunStarted struct {
	RunID    string          `json:"run_id"`
	Kind     ActionKind      `json:"kind"`
	RepoRoot string          `json:"repo_root"`
	At       time.Time       `json:"at"`
	Phases   []PipelinePhase `json:"phases,omitempty"`
}

type PipelineRunStartedMsg

type PipelineRunStartedMsg struct {
	Run PipelineRunStarted
}

type PipelineStepProgressMsg

type PipelineStepProgressMsg struct {
	RunID   string `json:"run_id"`
	Step    string `json:"step"`
	Percent int    `json:"percent"` // 0-100
}

PipelineStepProgressMsg carries progress updates for a running step.

type PipelineStepResult

type PipelineStepResult struct {
	Name            string `json:"name"`
	Ok              bool   `json:"ok"`
	DurationMs      int64  `json:"duration_ms,omitempty"`
	ProgressPercent int    `json:"progress_percent,omitempty"` // 0-100, for in-progress steps
}

type PipelineValidateResult

type PipelineValidateResult struct {
	RunID    string           `json:"run_id"`
	At       time.Time        `json:"at"`
	Valid    bool             `json:"valid"`
	Errors   []protocol.Error `json:"errors,omitempty"`
	Warnings []protocol.Error `json:"warnings,omitempty"`
}

type PipelineValidateResultMsg

type PipelineValidateResultMsg struct {
	Result PipelineValidateResult
}

type PluginIntrospectionRefreshMsg

type PluginIntrospectionRefreshMsg struct{}

type PluginSummary

type PluginSummary struct {
	ID        string    `json:"id"`
	Path      string    `json:"path"`
	Priority  int       `json:"priority"`
	Status    string    `json:"status"` // "active" | "disabled" | "error"
	Protocol  string    `json:"protocol,omitempty"`
	Ops       []string  `json:"ops,omitempty"`
	Streams   []string  `json:"streams,omitempty"`
	Commands  []string  `json:"commands,omitempty"`
	CapStatus string    `json:"cap_status,omitempty"` // "unknown" | "introspecting" | "ok" | "error"
	CapError  string    `json:"cap_error,omitempty"`
	CapStart  time.Time `json:"cap_start,omitempty"`
	CapEnd    time.Time `json:"cap_end,omitempty"`
}

PluginSummary contains summary information about a plugin.

type RootOptions

type RootOptions struct {
	RepoRoot string
	Config   string
	Strict   bool
	DryRun   bool
	Timeout  time.Duration
}

type ServiceExitObserved

type ServiceExitObserved struct {
	Name   string    `json:"name"`
	PID    int       `json:"pid"`
	When   time.Time `json:"when"`
	Reason string    `json:"reason,omitempty"`
}

type StateSnapshot

type StateSnapshot struct {
	RepoRoot     string                        `json:"repo_root"`
	At           time.Time                     `json:"at"`
	Exists       bool                          `json:"exists"`
	State        *state.State                  `json:"state,omitempty"`
	Alive        map[string]bool               `json:"alive,omitempty"`
	Error        string                        `json:"error,omitempty"`
	ProcessStats map[int]*proc.Stats           `json:"process_stats,omitempty"` // PID -> stats
	Health       map[string]*HealthCheckResult `json:"health,omitempty"`        // service name -> health
	Plugins      []PluginSummary               `json:"plugins,omitempty"`       // Plugin summaries
}

type StateSnapshotMsg

type StateSnapshotMsg struct {
	Snapshot StateSnapshot
}

type StateWatcher

type StateWatcher struct {
	RepoRoot string
	Interval time.Duration
	Pub      message.Publisher
	// contains filtered or unexported fields
}

func (*StateWatcher) RequestIntrospection

func (w *StateWatcher) RequestIntrospection()

func (*StateWatcher) Run

func (w *StateWatcher) Run(ctx context.Context) error

type StreamEnded

type StreamEnded struct {
	StreamKey string    `json:"stream_key"`
	PluginID  string    `json:"plugin_id"`
	Op        string    `json:"op"`
	StreamID  string    `json:"stream_id"`
	At        time.Time `json:"at"`
	Ok        bool      `json:"ok"`
	Error     string    `json:"error,omitempty"`
}

type StreamEndedMsg

type StreamEndedMsg struct {
	End StreamEnded
}

type StreamEvent

type StreamEvent struct {
	StreamKey string         `json:"stream_key"`
	PluginID  string         `json:"plugin_id"`
	Op        string         `json:"op"`
	StreamID  string         `json:"stream_id"`
	At        time.Time      `json:"at"`
	Event     protocol.Event `json:"event"`
}

type StreamEventMsg

type StreamEventMsg struct {
	Event StreamEvent
}

type StreamStartRequest

type StreamStartRequest struct {
	PluginID string         `json:"plugin_id,omitempty"` // optional; may be resolved by op
	Op       string         `json:"op"`
	Input    map[string]any `json:"input,omitempty"`
	Label    string         `json:"label,omitempty"` // optional display name
}

type StreamStartRequestMsg

type StreamStartRequestMsg struct {
	Request StreamStartRequest
}

type StreamStarted

type StreamStarted struct {
	StreamKey string    `json:"stream_key"`
	PluginID  string    `json:"plugin_id"`
	Op        string    `json:"op"`
	StreamID  string    `json:"stream_id"` // protocol stream_id
	At        time.Time `json:"at"`
}

StreamKey is a local identifier ("plugin/op/hash(input)") and is NOT the protocol stream_id.

type StreamStartedMsg

type StreamStartedMsg struct {
	Stream StreamStarted
}

type StreamStopRequest

type StreamStopRequest struct {
	StreamKey string `json:"stream_key"`
}

type StreamStopRequestMsg

type StreamStopRequestMsg struct {
	Request StreamStopRequest
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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