dashboard

package
v0.0.0-...-2b72fd0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgSessionsList          = "sessions_list"
	MsgSessionHistory        = "session_history"
	MsgContentDelta          = "content_delta"
	MsgToolStarted           = "tool_started"
	MsgToolCompleted         = "tool_completed"
	MsgIntentChanged         = "intent_changed"
	MsgTurnStart             = "turn_start"
	MsgTurnEnd               = "turn_end"
	MsgSessionError          = "error"
	MsgTunnelStatus          = "tunnel_status"
	MsgWorktreesList         = "worktrees_list"
	MsgReasoningDelta        = "reasoning_delta"
	MsgPersistedSessionsList = "persisted_sessions_list"
	MsgUserMessage           = "user_message"
	MsgDashboardConfig       = "dashboard_config"
	MsgWatchHistory          = "watch_history"
	MsgWatchEvent            = "watch_event"

	// Subagent lifecycle.
	MsgSubagentStarted    = "subagent_started"
	MsgSubagentCompleted  = "subagent_completed"
	MsgSubagentFailed     = "subagent_failed"
	MsgSubagentSelected   = "subagent_selected"
	MsgSubagentDeselected = "subagent_deselected"

	// Tool progress.
	MsgToolProgress      = "tool_progress"
	MsgToolPartialResult = "tool_partial_result"

	// Session lifecycle.
	MsgTitleChanged       = "title_changed"
	MsgCompactionStart    = "compaction_start"
	MsgCompactionComplete = "compaction_complete"
	MsgPlanChanged        = "plan_changed"
	MsgTaskComplete       = "task_complete"
	MsgContextChanged     = "context_changed"
	MsgModelChange        = "model_change"
	MsgModeChanged        = "mode_changed"
	MsgSessionWarning     = "session_warning"
	MsgSessionInfo        = "session_info"

	// User input / elicitation.
	MsgUserInputRequested   = "user_input_requested"
	MsgUserInputCompleted   = "user_input_completed"
	MsgElicitationRequested = "elicitation_requested"
	MsgElicitationCompleted = "elicitation_completed"

	// Permissions.
	MsgPermissionRequested = "permission_requested"
	MsgPermissionCompleted = "permission_completed"

	// Hooks & skills.
	MsgHookStart    = "hook_start"
	MsgHookEnd      = "hook_end"
	MsgSkillInvoked = "skill_invoked"
)

Server → Client message types.

View Source
const (
	MsgGetSessions          = "get_sessions"
	MsgGetHistory           = "get_history"
	MsgSendMessage          = "send_message"
	MsgCreateSession        = "create_session"
	MsgResumeSession        = "resume_session"
	MsgCloseSession         = "close_session"
	MsgListWorktrees        = "list_worktrees"
	MsgStartTunnel          = "start_tunnel"
	MsgStopTunnel           = "stop_tunnel"
	MsgGetPersistedSessions = "get_persisted_sessions"
	MsgSetTunnelConfig      = "set_tunnel_config"
	MsgAddAllowedUser       = "add_allowed_user"
	MsgRemoveAllowedUser    = "remove_allowed_user"
	MsgGetAllowedUsers      = "get_allowed_users"
	MsgRestartServer        = "restart_server"
	MsgUpgradeServer        = "upgrade_server"
	MsgWatchSession         = "watch_session"
	MsgForkSession          = "fork_session"
	MsgAbortSession         = "abort_session"
)

Client → Server message types.

View Source
const (
	MsgAllowedUsersList = "allowed_users_list"
)

Server → Client

Variables

This section is empty.

Functions

func ParsePayload

func ParsePayload[T any](msg BridgeMessage) (T, error)

ParsePayload unmarshals the raw payload of a BridgeMessage into T.

Types

type AllowedUserPayload

type AllowedUserPayload struct {
	Email string `json:"email"`
}

type AllowedUsersListPayload

type AllowedUsersListPayload struct {
	OwnerEmail string   `json:"owner_email"`
	Users      []string `json:"users"`
}

type Bridge

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

Bridge manages WebSocket connections and broadcasts session events to clients.

func NewBridge

func NewBridge(mgr *copilot.Manager, ownerNickname string, serverCtx context.Context) *Bridge

NewBridge creates a Bridge wired to the given copilot Manager. serverCtx should be the long-lived server context (not per-client).

func (*Bridge) BroadcastTunnelStatus

func (b *Bridge) BroadcastTunnelStatus(running bool, url string, keyedURL ...string)

BroadcastTunnelStatus sends tunnel status to all clients.

func (*Bridge) BroadcastWorktrees

func (b *Bridge) BroadcastWorktrees(worktrees []WorktreeSummary)

BroadcastWorktrees sends the worktrees list to all clients.

func (*Bridge) HandleSharedWS

func (b *Bridge) HandleSharedWS(w http.ResponseWriter, r *http.Request, sessionName string, mode string)

HandleSharedWS is the HTTP handler for /ws/shared/{token} — read-only, single session.

func (*Bridge) HandleWS

func (b *Bridge) HandleWS(w http.ResponseWriter, r *http.Request)

HandleWS is the HTTP handler for the /ws endpoint.

func (*Bridge) SendWorktreesTo

func (b *Bridge) SendWorktreesTo(client *wsClient, worktrees []WorktreeSummary)

SendWorktreesTo sends the worktrees list to a single client.

type BridgeMessage

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

BridgeMessage is the envelope for all WebSocket messages between the dashboard server and browser clients.

func NewMessage

func NewMessage[T any](msgType string, payload T) (BridgeMessage, error)

NewMessage constructs a BridgeMessage by marshaling the given payload.

type CloseSessionPayload

type CloseSessionPayload struct {
	SessionName string `json:"session_name"`
}

type CompactionCompletePayload

type CompactionCompletePayload struct {
	SessionName string `json:"session_name"`
	Success     bool   `json:"success"`
	Summary     string `json:"summary"`
}

type CompactionPayload

type CompactionPayload struct {
	SessionName string `json:"session_name"`
}

type ContentDeltaPayload

type ContentDeltaPayload struct {
	SessionName string `json:"session_name"`
	Content     string `json:"content"`
}

type CreateSessionPayload

type CreateSessionPayload struct {
	Name       string `json:"name"`
	Model      string `json:"model"`
	WorkingDir string `json:"working_dir"`
}

type DashboardConfigPayload

type DashboardConfigPayload struct {
	OwnerNickname string `json:"owner_nickname"`
}

type ElicitationCompletedPayload

type ElicitationCompletedPayload struct {
	SessionName string `json:"session_name"`
	RequestID   string `json:"request_id"`
}

type ElicitationRequestedPayload

type ElicitationRequestedPayload struct {
	SessionName string `json:"session_name"`
	RequestID   string `json:"request_id"`
	Message     string `json:"message"`
}

type ErrorPayload

type ErrorPayload struct {
	SessionName string `json:"session_name"`
	Message     string `json:"message"`
}

type ForkSessionPayload

type ForkSessionPayload struct {
	SessionID string `json:"session_id"`
	Model     string `json:"model"`
}

type GetHistoryPayload

type GetHistoryPayload struct {
	SessionName string `json:"session_name"`
}

type HookEndPayload

type HookEndPayload struct {
	SessionName string `json:"session_name"`
	HookID      string `json:"hook_id"`
	Success     bool   `json:"success"`
}

type HookStartPayload

type HookStartPayload struct {
	SessionName string `json:"session_name"`
	HookID      string `json:"hook_id"`
	HookType    string `json:"hook_type"`
}

type IntentChangedPayload

type IntentChangedPayload struct {
	SessionName string `json:"session_name"`
	Intent      string `json:"intent"`
}

type MessageSummary

type MessageSummary struct {
	Role      string    `json:"role"`
	Content   string    `json:"content"`
	Timestamp time.Time `json:"timestamp"`
}

type ModeChangedPayload

type ModeChangedPayload struct {
	SessionName  string `json:"session_name"`
	NewMode      string `json:"new_mode"`
	PreviousMode string `json:"previous_mode"`
}

type ModelChangePayload

type ModelChangePayload struct {
	SessionName   string `json:"session_name"`
	NewModel      string `json:"new_model"`
	PreviousModel string `json:"previous_model"`
}

type PermissionCompletedPayload

type PermissionCompletedPayload struct {
	SessionName string `json:"session_name"`
	RequestID   string `json:"request_id"`
}

type PermissionRequestedPayload

type PermissionRequestedPayload struct {
	SessionName    string `json:"session_name"`
	RequestID      string `json:"request_id"`
	PermissionKind string `json:"permission_kind"`
	ToolName       string `json:"tool_name"`
}

type PersistedSessionSummary

type PersistedSessionSummary struct {
	SessionID    string `json:"session_id"`
	Summary      string `json:"summary"`
	LastModified string `json:"last_modified"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
	IsActive     bool   `json:"is_active,omitempty"`
}

type PersistedSessionsListPayload

type PersistedSessionsListPayload struct {
	Sessions []PersistedSessionSummary `json:"sessions"`
}

type PlanChangedPayload

type PlanChangedPayload struct {
	SessionName string `json:"session_name"`
	Summary     string `json:"summary"`
}

type ReasoningDeltaPayload

type ReasoningDeltaPayload struct {
	SessionName string `json:"session_name"`
	ReasoningID string `json:"reasoning_id"`
	Content     string `json:"content"`
}

type ResumeSessionPayload

type ResumeSessionPayload struct {
	SessionID   string `json:"session_id"`
	DisplayName string `json:"display_name"`
}

type SendMessagePayload

type SendMessagePayload struct {
	SessionName string `json:"session_name"`
	Prompt      string `json:"prompt"`
}

type Server

type Server struct {
	ListPRsFn  func() (any, error)
	GetPRFn    func(id string) (any, error)
	AddPRFn    func(ctx context.Context, url string) (any, error)
	RemovePRFn func(id string) error
	// contains filtered or unexported fields
}

Server is the dashboard HTTP server that serves the web UI, REST API, and WebSocket bridge.

func NewServer

func NewServer(cfg *config.Config) *Server

NewServer creates a dashboard server with all subsystems.

func (*Server) SetRestartHandler

func (s *Server) SetRestartHandler(fn func() error)

SetRestartHandler sets the callback for restarting the server from the dashboard.

func (*Server) SetUpgradeHandler

func (s *Server) SetUpgradeHandler(fn func() error)

SetUpgradeHandler sets the callback for upgrading the server from the dashboard.

func (*Server) Start

func (s *Server) Start(ctx context.Context, port int) error

Start initializes the copilot manager and starts the HTTP server.

type SessionHistoryPayload

type SessionHistoryPayload struct {
	SessionName string           `json:"session_name"`
	Messages    []MessageSummary `json:"messages"`
}

type SessionInfoPayload

type SessionInfoPayload struct {
	SessionName string `json:"session_name"`
	InfoType    string `json:"info_type"`
	Message     string `json:"message"`
}

type SessionSummary

type SessionSummary struct {
	Name         string    `json:"name"`
	Model        string    `json:"model"`
	SessionID    string    `json:"session_id"`
	WorkingDir   string    `json:"working_dir"`
	CreatedAt    time.Time `json:"created_at"`
	MessageCount int       `json:"message_count"`
	IsProcessing bool      `json:"is_processing"`
	Intent       string    `json:"intent"`
	State        string    `json:"state"`
}

type SessionWarningPayload

type SessionWarningPayload struct {
	SessionName string `json:"session_name"`
	WarningType string `json:"warning_type"`
	Message     string `json:"message"`
}

type SessionsListPayload

type SessionsListPayload struct {
	Sessions      []SessionSummary `json:"sessions"`
	ActiveSession string           `json:"active_session"`
}

type SetTunnelConfigPayload

type SetTunnelConfigPayload struct {
	TunnelID string `json:"tunnel_id"`
	Access   string `json:"access"`
	AllowOrg string `json:"allow_org"`
}

type ShareToken

type ShareToken struct {
	Token       string    `json:"token"`
	SessionName string    `json:"session_name"`
	SessionID   string    `json:"session_id"`
	ExpiresAt   time.Time `json:"expires_at"`
	CreatedAt   time.Time `json:"created_at"`
	Mode        string    `json:"mode"` // "readonly" or "readwrite"
}

ShareToken represents a time-limited share link for a single session.

type SkillInvokedPayload

type SkillInvokedPayload struct {
	SessionName string `json:"session_name"`
	SkillName   string `json:"skill_name"`
}

type SubagentCompletedPayload

type SubagentCompletedPayload struct {
	SessionName string `json:"session_name"`
	ToolCallID  string `json:"tool_call_id"`
	Summary     string `json:"summary"`
}

type SubagentDeselectedPayload

type SubagentDeselectedPayload struct {
	SessionName string `json:"session_name"`
}

type SubagentFailedPayload

type SubagentFailedPayload struct {
	SessionName string `json:"session_name"`
	ToolCallID  string `json:"tool_call_id"`
	Error       string `json:"error"`
}

type SubagentSelectedPayload

type SubagentSelectedPayload struct {
	SessionName      string `json:"session_name"`
	AgentName        string `json:"agent_name"`
	AgentDisplayName string `json:"agent_display_name"`
}

type SubagentStartedPayload

type SubagentStartedPayload struct {
	SessionName      string `json:"session_name"`
	AgentName        string `json:"agent_name"`
	AgentDisplayName string `json:"agent_display_name"`
	AgentDescription string `json:"agent_description"`
	ToolCallID       string `json:"tool_call_id"`
}

type TaskCompletePayload

type TaskCompletePayload struct {
	SessionName string `json:"session_name"`
	Summary     string `json:"summary"`
}

type TitleChangedPayload

type TitleChangedPayload struct {
	SessionName string `json:"session_name"`
	Title       string `json:"title"`
}

type ToolCompletedPayload

type ToolCompletedPayload struct {
	SessionName string `json:"session_name"`
	CallID      string `json:"call_id"`
	Result      string `json:"result"`
	Success     bool   `json:"success"`
}

type ToolPartialResultPayload

type ToolPartialResultPayload struct {
	SessionName   string `json:"session_name"`
	CallID        string `json:"call_id"`
	PartialOutput string `json:"partial_output"`
}

type ToolProgressPayload

type ToolProgressPayload struct {
	SessionName     string `json:"session_name"`
	CallID          string `json:"call_id"`
	ProgressMessage string `json:"progress_message"`
}

type ToolStartedPayload

type ToolStartedPayload struct {
	SessionName string `json:"session_name"`
	ToolName    string `json:"tool_name"`
	CallID      string `json:"call_id"`
	ToolInput   string `json:"tool_input"`
}

type TunnelStatusPayload

type TunnelStatusPayload struct {
	Running  bool   `json:"running"`
	URL      string `json:"url"`
	KeyedURL string `json:"keyed_url,omitempty"`
	Hint     string `json:"hint,omitempty"`
}

type TurnPayload

type TurnPayload struct {
	SessionName string `json:"session_name"`
}

type UserInputCompletedPayload

type UserInputCompletedPayload struct {
	SessionName string `json:"session_name"`
	RequestID   string `json:"request_id"`
}

type UserInputRequestedPayload

type UserInputRequestedPayload struct {
	SessionName   string   `json:"session_name"`
	RequestID     string   `json:"request_id"`
	Question      string   `json:"question"`
	Choices       []string `json:"choices,omitempty"`
	AllowFreeform bool     `json:"allow_freeform"`
}

type WatchSessionPayload

type WatchSessionPayload struct {
	SessionID string `json:"session_id"`
}

type WorktreeSummary

type WorktreeSummary struct {
	Name     string `json:"name"`
	Path     string `json:"path"`
	Branch   string `json:"branch"`
	RepoName string `json:"repo_name"`
}

type WorktreesListPayload

type WorktreesListPayload struct {
	Worktrees []WorktreeSummary `json:"worktrees"`
}

Jump to

Keyboard shortcuts

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