web

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound     = errors.New("task not found")
	ErrTaskNotCompleted = errors.New("task is not completed")
)

Functions

This section is empty.

Types

type AgentAuthOption

type AgentAuthOption struct {
	Value       string `json:"value,omitempty"`
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`
}

type AgentAuthState

type AgentAuthState struct {
	Harness              string            `json:"harness,omitempty"`
	Required             bool              `json:"required"`
	Ready                bool              `json:"ready"`
	State                string            `json:"state,omitempty"`
	Message              string            `json:"message,omitempty"`
	AuthURL              string            `json:"auth_url,omitempty"`
	DeviceCode           string            `json:"device_code,omitempty"`
	AcceptsBrowserCode   bool              `json:"accepts_browser_code,omitempty"`
	ConfigureCommand     string            `json:"configure_command,omitempty"`
	ConfigurePlaceholder string            `json:"configure_placeholder,omitempty"`
	ConfigureOptions     []AgentAuthOption `json:"configure_options,omitempty"`
	UpdatedAt            string            `json:"updated_at,omitempty"`
}

AgentAuthState describes current runtime agent-auth readiness and device flow hints.

type Broker

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

Broker collects daemon logs and exposes monitor state snapshots.

func NewBroker

func NewBroker() *Broker

NewBroker returns a monitor state broker with safe defaults.

func (*Broker) CloseTask

func (b *Broker) CloseTask(requestID string) error

CloseTask removes a terminal task from the live task list while retaining its rerun config.

func (*Broker) DropTaskRunConfig

func (b *Broker) DropTaskRunConfig(requestID string)

DropTaskRunConfig removes stored rerun config for tasks that no longer need task-level reruns.

func (*Broker) IngestLog

func (b *Broker) IngestLog(line string)

IngestLog consumes one daemon log line and updates monitor state.

func (*Broker) RecordRejectedPromptSubmission

func (b *Broker) RecordRejectedPromptSubmission(runConfigJSON []byte, status string, err error) string

RecordRejectedPromptSubmission stores a failed prompt submission so it remains visible in the task list.

func (*Broker) RecordRejectedPromptSubmissionWithSource

func (b *Broker) RecordRejectedPromptSubmissionWithSource(runConfigJSON []byte, status string, err error, source string) string

RecordRejectedPromptSubmissionWithSource stores a failed prompt submission with its start source.

func (*Broker) RecordReleaseFromTask

func (b *Broker) RecordReleaseFromTask(task Task, mergedAt string)

RecordReleaseFromTask stores a release entry for a merged pull request before the originating task is removed from the live task list.

func (*Broker) RecordTaskRerunAttempt

func (b *Broker) RecordTaskRerunAttempt(rerunOf, requestID string)

RecordTaskRerunAttempt links a newly queued rerun to the original task attempt chain.

func (*Broker) RecordTaskRunConfig

func (b *Broker) RecordTaskRunConfig(requestID string, runConfigJSON []byte)

RecordTaskRunConfig stores a parsed task run config payload for future reruns.

func (*Broker) RecordTaskRunConfigWithSource

func (b *Broker) RecordTaskRunConfigWithSource(requestID string, runConfigJSON []byte, source string)

RecordTaskRunConfigWithSource stores a parsed task run config payload and task start source.

func (*Broker) RecordTaskSource

func (b *Broker) RecordTaskSource(requestID string, source string)

RecordTaskSource updates the start source for an already visible task.

func (*Broker) SetGitHubRepositories

func (b *Broker) SetGitHubRepositories(repos []GitHubRepo)

func (*Broker) Snapshot

func (b *Broker) Snapshot() Snapshot

Snapshot returns a deep copy of current monitor state.

func (*Broker) Subscribe

func (b *Broker) Subscribe() (<-chan struct{}, func())

Subscribe returns a change notification channel and cancel function.

func (*Broker) Task

func (b *Broker) Task(requestID string) (Task, bool)

Task returns a copy of the current task snapshot for one request id.

func (*Broker) TaskAttempts

func (b *Broker) TaskAttempts(requestID string) []TaskAttempt

TaskAttempts returns a copy of internal attempt records for requestID's root task.

func (*Broker) TaskRunConfig

func (b *Broker) TaskRunConfig(requestID string) ([]byte, bool)

TaskRunConfig returns a copy of the stored run config payload for requestID.

type Connection

type Connection struct {
	HubConnected bool   `json:"hub_connected"`
	HubTransport string `json:"hub_transport,omitempty"`
	HubDomain    string `json:"hub_domain,omitempty"`
	HubBaseURL   string `json:"hub_base_url,omitempty"`
	HubDetail    string `json:"hub_detail,omitempty"`
}

Connection captures current monitor connectivity state.

type CountStatsGroup

type CountStatsGroup struct {
	Name           string `json:"name"`
	Tasks          int    `json:"tasks"`
	ActiveTasks    int    `json:"active_tasks"`
	CompletedTasks int    `json:"completed_tasks"`
	FailedTasks    int    `json:"failed_tasks"`
}

CountStatsGroup captures task counts for dashboard mix charts.

type DashboardStats

type DashboardStats struct {
	TotalTasks             int               `json:"total_tasks"`
	ActiveTasks            int               `json:"active_tasks"`
	CompletedTasks         int               `json:"completed_tasks"`
	FailedTasks            int               `json:"failed_tasks"`
	MaxConcurrentTasks     int               `json:"max_concurrent_tasks"`
	SessionRuntimeSeconds  float64           `json:"session_runtime_seconds"`
	TotalSavedSeconds      float64           `json:"total_saved_seconds"`
	SuccessRate            float64           `json:"success_rate"`
	AverageDurationSeconds float64           `json:"average_duration_seconds"`
	VelocityPerHour        float64           `json:"velocity_per_hour"`
	ThroughputPerHour      float64           `json:"throughput_per_hour"`
	UpdatedAt              string            `json:"updated_at,omitempty"`
	WorkflowTimes          []TimeStatsGroup  `json:"workflow_times,omitempty"`
	AgentTimes             []TimeStatsGroup  `json:"agent_times,omitempty"`
	SourceMix              []CountStatsGroup `json:"source_mix,omitempty"`
}

DashboardStats captures in-memory run stats for the monitor dashboard.

type Event

type Event struct {
	ID        int64  `json:"id"`
	Time      string `json:"time"`
	Kind      string `json:"kind"`
	RequestID string `json:"request_id,omitempty"`
	Line      string `json:"line"`
}

Event is one monitor timeline entry.

type GitHubRepo

type GitHubRepo struct {
	Name           string `json:"name"`
	FullName       string `json:"full_name"`
	Description    string `json:"description,omitempty"`
	HTMLURL        string `json:"html_url"`
	OwnerType      string `json:"owner_type,omitempty"`
	OwnerKind      string `json:"owner_kind,omitempty"`
	OwnerAvatarURL string `json:"owner_avatar_url,omitempty"`
	DefaultBranch  string `json:"default_branch,omitempty"`
	Private        bool   `json:"private"`
	Public         bool   `json:"public"`
	Personal       bool   `json:"personal,omitempty"`
	Organization   bool   `json:"organization,omitempty"`
	Visibility     string `json:"visibility,omitempty"`
	Language       string `json:"language,omitempty"`
	UpdatedAt      string `json:"updated_at,omitempty"`
	PushedAt       string `json:"pushed_at,omitempty"`
}

GitHubRepo captures the repository fields shown in the chat view.

type HubSetupRequest

type HubSetupRequest struct {
	AgentMode string `json:"agent_mode"`
	TokenType string `json:"token_type"`
	Region    string `json:"region"`
	Token     string `json:"token"`
	Handle    string `json:"handle"`
	Profile   struct {
		ProfileText string `json:"profile"`
		DisplayName string `json:"display_name"`
		Emoji       string `json:"emoji"`
	} `json:"profile"`
}

HubSetupRequest captures the late-stage Hub connect modal payload.

type HubSetupState

type HubSetupState struct {
	Configured bool   `json:"configured"`
	AgentMode  string `json:"agent_mode,omitempty"`
	TokenType  string `json:"token_type,omitempty"`
	Region     string `json:"region,omitempty"`
	Handle     string `json:"handle,omitempty"`
	Profile    struct {
		ProfileText string `json:"profile"`
		DisplayName string `json:"display_name"`
		Emoji       string `json:"emoji"`
	} `json:"profile"`
	ConnectURL       string         `json:"connect_url,omitempty"`
	DashboardURL     string         `json:"dashboard_url,omitempty"`
	Message          string         `json:"message,omitempty"`
	NeedsRestart     bool           `json:"needs_restart,omitempty"`
	Onboarding       []HubSetupStep `json:"onboarding,omitempty"`
	OnboardingActive bool           `json:"onboarding_active,omitempty"`
	OnboardingStage  string         `json:"onboarding_stage,omitempty"`
	ActivationReady  bool           `json:"activation_ready,omitempty"`
}

HubSetupState describes whether Molten Hub is configured locally and what profile details should be reflected in config.json.

type HubSetupStep

type HubSetupStep struct {
	ID     string `json:"id,omitempty"`
	Label  string `json:"label,omitempty"`
	Status string `json:"status,omitempty"`
	Detail string `json:"detail,omitempty"`
}

func DefaultHubSetupOnboarding

func DefaultHubSetupOnboarding(agentMode string) []HubSetupStep

type PRMergeMonitor

type PRMergeMonitor struct {
	Runner       execx.Runner
	Broker       *Broker
	Logf         func(string, ...any)
	CleanupTask  func(context.Context, string) error
	PollInterval time.Duration
	// contains filtered or unexported fields
}

PRMergeMonitor watches task pull requests and closes merged tasks so they disappear from queue/UI automatically.

func (*PRMergeMonitor) Run

func (m *PRMergeMonitor) Run(ctx context.Context) error

Run polls tracked PRs until ctx is canceled.

type PromptImage added in v1.0.9

type PromptImage struct {
	Name       string `json:"name,omitempty"`
	MediaType  string `json:"mediaType,omitempty"`
	DataBase64 string `json:"dataBase64,omitempty"`
}

PromptImage captures one prompt image attachment shown in task views.

type Release

type Release struct {
	RequestID         string   `json:"request_id"`
	Prompt            string   `json:"prompt,omitempty"`
	PromptIsUserInput bool     `json:"prompt_is_user_input"`
	Skill             string   `json:"skill,omitempty"`
	Workflow          string   `json:"workflow,omitempty"`
	AgentHarness      string   `json:"agent_harness,omitempty"`
	Repo              string   `json:"repo,omitempty"`
	Repos             []string `json:"repos,omitempty"`
	BaseBranch        string   `json:"base_branch,omitempty"`
	Branch            string   `json:"branch,omitempty"`
	PRURL             string   `json:"pr_url,omitempty"`
	StartedAt         string   `json:"started_at,omitempty"`
	CompletedAt       string   `json:"completed_at,omitempty"`
	MergedAt          string   `json:"merged_at,omitempty"`
	ReleasedAt        string   `json:"released_at"`
	DurationSeconds   float64  `json:"duration_seconds,omitempty"`
}

Release represents a merged pull request that shipped from one originating prompt.

type Repository

type Repository struct {
	Key            string               `json:"key"`
	Name           string               `json:"name,omitempty"`
	FullName       string               `json:"full_name,omitempty"`
	Description    string               `json:"description,omitempty"`
	HTMLURL        string               `json:"html_url,omitempty"`
	OwnerAvatarURL string               `json:"owner_avatar_url,omitempty"`
	DefaultBranch  string               `json:"default_branch,omitempty"`
	Language       string               `json:"language,omitempty"`
	UpdatedAt      string               `json:"updated_at,omitempty"`
	PushedAt       string               `json:"pushed_at,omitempty"`
	Visibility     RepositoryVisibility `json:"visibility"`
	OwnerKind      RepositoryOwnerKind  `json:"owner_kind"`
	Private        bool                 `json:"private"`
	Public         bool                 `json:"public"`
	Personal       bool                 `json:"personal"`
	Organization   bool                 `json:"organization"`
	Stats          RepositoryStats      `json:"stats"`
	PullRequests   []string             `json:"pull_requests,omitempty"`
}

Repository is the in-memory view of one repository and the work observed for it.

type RepositoryOwnerKind

type RepositoryOwnerKind string
const (
	RepositoryOwnerUnknown      RepositoryOwnerKind = "unknown"
	RepositoryOwnerPersonal     RepositoryOwnerKind = "personal"
	RepositoryOwnerOrganization RepositoryOwnerKind = "organization"
)

type RepositoryStats

type RepositoryStats struct {
	TotalTasks             int     `json:"total_tasks"`
	ActiveTasks            int     `json:"active_tasks"`
	CompletedTasks         int     `json:"completed_tasks"`
	FailedTasks            int     `json:"failed_tasks"`
	TotalDurationSeconds   float64 `json:"total_duration_seconds"`
	TotalSavedSeconds      float64 `json:"total_saved_seconds"`
	AverageDurationSeconds float64 `json:"average_duration_seconds"`
}

type RepositoryVisibility

type RepositoryVisibility string
const (
	RepositoryVisibilityUnknown RepositoryVisibility = "unknown"
	RepositoryVisibilityPublic  RepositoryVisibility = "public"
	RepositoryVisibilityPrivate RepositoryVisibility = "private"
)

type ResourceMetrics

type ResourceMetrics struct {
	CPUPercent    float64 `json:"cpu_percent,omitempty"`
	MemoryPercent float64 `json:"memory_percent,omitempty"`
	DiskIOMBs     float64 `json:"disk_io_mb_s,omitempty"`
	UpdatedAt     string  `json:"updated_at,omitempty"`
}

ResourceMetrics captures the current dispatcher sample window values.

type Server

type Server struct {
	Addr                    string
	Broker                  *Broker
	AutomaticMode           bool
	ConfiguredHarness       string
	Logf                    func(string, ...any)
	SubmitLocalPrompt       func(context.Context, []byte) (string, error)
	SubmitTaskRerun         func(context.Context, string, []byte, bool) (string, error)
	CloseTask               func(context.Context, string) error
	PauseTask               func(context.Context, string) error
	RunTask                 func(context.Context, string) error
	ForceRunTask            func(context.Context, string) error
	StopTask                func(context.Context, string) error
	ResolveTaskControls     func(string) TaskControls
	LoadLibraryTasks        func() ([]library.TaskSummary, error)
	AgentAuthStatus         func(context.Context) (AgentAuthState, error)
	StartAgentAuth          func(context.Context) (AgentAuthState, error)
	VerifyAgentAuth         func(context.Context) (AgentAuthState, error)
	ConfigureAgentAuth      func(context.Context, string) (AgentAuthState, error)
	HubSetupStatus          func(context.Context) (HubSetupState, error)
	ConfigureHubSetup       func(context.Context, HubSetupRequest) (HubSetupState, error)
	ConnectHubSetup         func(context.Context) (HubSetupState, error)
	DisconnectHubSetup      func(context.Context) (HubSetupState, error)
	RenderHubSetupStatus    func(context.Context) (HubSetupState, error)
	ResolveGitHubProfileURL func(context.Context) (string, error)
	ResolveGitHubRepos      func(context.Context) ([]GitHubRepo, error)

	Ready chan<- error
	// contains filtered or unexported fields
}

Server provides an HTTP UI for live hub/task monitoring.

func NewServer

func NewServer(addr string, broker *Broker) Server

NewServer returns a monitor HTTP server.

func (Server) Handler

func (s Server) Handler() http.Handler

Handler returns the HTTP handler for the monitor UI/API.

func (Server) Run

func (s Server) Run(ctx context.Context) error

Run serves the monitor UI until ctx is canceled.

type Snapshot

type Snapshot struct {
	GeneratedAt   string          `json:"generated_at"`
	Connection    Connection      `json:"connection"`
	Resources     ResourceMetrics `json:"resources"`
	Stats         DashboardStats  `json:"stats"`
	Repositories  []Repository    `json:"repositories,omitempty"`
	Releases      []Release       `json:"releases"`
	Events        []Event         `json:"events"`
	Tasks         []Task          `json:"tasks"`
	PromptedRepos []string        `json:"prompted_repos,omitempty"`
}

Snapshot is the complete monitor payload for the web UI.

type Task

type Task struct {
	RequestID         string        `json:"request_id"`
	Source            string        `json:"source,omitempty"`
	Prompt            string        `json:"prompt,omitempty"`
	PromptIsUserInput bool          `json:"prompt_is_user_input"`
	Images            []PromptImage `json:"images,omitempty"`
	Skill             string        `json:"skill,omitempty"`
	Workflow          string        `json:"workflow,omitempty"`
	AgentHarness      string        `json:"agent_harness,omitempty"`
	Repo              string        `json:"repo,omitempty"`
	Repos             []string      `json:"repos,omitempty"`
	BaseBranch        string        `json:"base_branch,omitempty"`
	Status            string        `json:"status"`
	Stage             string        `json:"stage,omitempty"`
	StageStatus       string        `json:"stage_status,omitempty"`
	ExitCode          int           `json:"exit_code,omitempty"`
	WorkspaceDir      string        `json:"workspace_dir,omitempty"`
	Branch            string        `json:"branch,omitempty"`
	PRURL             string        `json:"pr_url,omitempty"`
	Error             string        `json:"error,omitempty"`
	StartedAt         string        `json:"started_at"`
	UpdatedAt         string        `json:"updated_at"`
	DurationSeconds   float64       `json:"duration_seconds,omitempty"`
	CanRerun          bool          `json:"can_rerun,omitempty"`
	Controls          TaskControls  `json:"controls,omitempty"`
	Logs              []TaskLog     `json:"logs"`
}

Task represents one hub dispatch execution state.

type TaskAttempt

type TaskAttempt struct {
	RequestID string
	RerunOf   string
	Status    string
	Error     string
	StartedAt string
	UpdatedAt string
}

TaskAttempt is an internal record of queued/running terminal attempts for one original task. It is intentionally not included in Snapshot responses.

type TaskControls

type TaskControls struct {
	Pause    bool `json:"pause,omitempty"`
	Run      bool `json:"run,omitempty"`
	ForceRun bool `json:"force_run,omitempty"`
	Stop     bool `json:"stop,omitempty"`
}

TaskControls describes which runtime controls are currently supported.

type TaskLog

type TaskLog struct {
	Time   string `json:"time"`
	Stream string `json:"stream"`
	Text   string `json:"text"`
}

TaskLog is one terminal/log line associated with a request.

type TimeStatsGroup

type TimeStatsGroup struct {
	Name                   string  `json:"name"`
	Tasks                  int     `json:"tasks"`
	ActiveTasks            int     `json:"active_tasks"`
	CompletedTasks         int     `json:"completed_tasks"`
	TotalDurationSeconds   float64 `json:"total_duration_seconds"`
	TotalSavedSeconds      float64 `json:"total_saved_seconds"`
	AverageDurationSeconds float64 `json:"average_duration_seconds"`
}

TimeStatsGroup captures observed runtime and saved time for one workflow or agent.

Jump to

Keyboard shortcuts

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