admin

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLastAdmin = errors.New("cannot demote the last admin")

ErrLastAdmin is returned when trying to demote the only remaining admin.

View Source
var ErrOwnerTagImmutable = errors.New("owner tags are managed automatically and cannot be modified")
View Source
var ErrSystemEntityImmutable = errors.New("entity is system-tagged and cannot be modified from the admin UI")

ErrSystemEntityImmutable is returned when an admin tries to mutate (disable/hide/retag) a tool/job/connector that carries any System tag. System-tagged entities are owned by code — see entity.Tag godoc.

View Source
var ErrSystemTagAssignment = errors.New("system tags cannot be assigned to users")

ErrSystemTagAssignment is returned when an admin tries to attach a tag flagged IsSystem to a user. System tags are code-owned and exist solely to gate built-in maintenance items behind a tag no end user can carry — see entity.Tag godoc.

View Source
var ErrSystemTagImmutable = errors.New("system tags are read-only and cannot be modified")

ErrSystemTagImmutable is returned when an admin tries to edit, delete, or otherwise mutate a Tag whose IsSystem flag is true. System tags are owned by code (seeded via tool/job DefaultTags) and changing them from the UI would desync the seed catalog from the DB.

View Source
var ErrTagNameTaken = errors.New("a tag with that name already exists")

ErrTagNameTaken is returned when creating or renaming a tag to an existing name.

View Source
var ErrUserNotApproved = errors.New("user must be approved before assigning tags")

ErrUserNotApproved is returned when trying to assign tags to an unapproved user.

View Source
var StaticFS embed.FS

Functions

func IsImpersonating added in v1.0.0

func IsImpersonating(r *http.Request) bool

IsImpersonating reports whether the current request runs inside a switch, so the UI can show a banner with a way back. Without that, an admin can forget they are someone else and misread everything they see.

func SetAgentsLayout added in v1.2.9

func SetAgentsLayout(l agentconfig.Layout)

SetAgentsLayout wires the session store for the analytics page.

Types

type AccessDetail added in v1.2.9

type AccessDetail struct {
	Path string `json:"path"`
	Kind string `json:"kind"`
	// KindOne is Kind in the singular, for the modal's sentence.
	KindOne string `json:"kind_one"`
	// Public: the item carries no filter tag, so every approved user reaches
	// it and Users lists all of them.
	Public bool     `json:"public"`
	Tags   []string `json:"tags"`
	// OwnerScoped: untagged here means owner-only, not everyone.
	OwnerScoped bool `json:"owner_scoped"`
	// TagsInert: the tags below are never read by this surface's visibility
	// check, so they grant nobody anything.
	TagsInert bool        `json:"tags_inert"`
	Users     []adminUser `json:"users"`
}

AccessDetail answers "who reaches this one item, and how".

type AccessItem added in v1.2.9

type AccessItem struct {
	Path  string `json:"path"`
	Kind  string `json:"kind"`
	Label string `json:"label"`
}

AccessItem is one thing a tag grants access to.

type AccessItemGroup added in v1.2.9

type AccessItemGroup struct {
	Kind  string       `json:"kind"`
	Items []AccessItem `json:"items"`
}

AccessItemGroup buckets a tag's granted items by surface.

type DataTableLister added in v0.30.1

type DataTableLister interface {
	ListTables() []string
	LoadSchema(slug string) (datatable.Schema, error)
}

DataTableLister lists data tables + their schema for the admin grant page. Satisfied directly by datatable.Service (wfMgr.DataTables).

type Handler

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

func NewHandler

func NewHandler(
	db *gorm.DB,
	tools []tool.Tool,
	configsSvc *configs.Service,
	ssoSvc *sso.Service,
	svc JobListProvider,
	connectorsSvc *connectors.Service,
	tokensSvc *accesstoken.Service,
	oauthSvc *oauth.Service,
	authSvc *login.Service,
	projects ProjectLister,
	workflows WorkflowLister,
	skillsDB SkillLister,
	sys SystemConfig,
) *Handler

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux, sessionMidd *login.Middleware)

func (*Handler) SetDataTables added in v0.30.1

func (h *Handler) SetDataTables(l DataTableLister)

SetDataTables wires the data-tables lister for the /admin/data-tables grant page. Optional — when unset the page returns 503. Kept as a post-construction setter so NewHandler's positional signature doesn't grow another param.

func (*Handler) SetOnUserApproved added in v1.0.0

func (h *Handler) SetOnUserApproved(fn func(ctx context.Context, userID string))

SetOnUserApproved wires the post-approval notice hook. Called once at boot.

func (*Handler) SetProjectWriter added in v1.2.9

func (h *Handler) SetProjectWriter(w ProjectWriter)

SetProjectWriter wires the writer behind the projects Owner picker. Optional, like SetDataTables and SetSchedules: nil leaves the page rendering and the endpoint refusing, rather than panicking.

func (*Handler) SetSchedules added in v1.2.9

func (h *Handler) SetSchedules(l ScheduleLister, p ProjectNamer)

SetSchedules wires the schedules page post-construction, matching how the other optional dependencies are attached. Nil simply leaves the page reporting that scheduling is not configured on this instance.

func (*Handler) SetTeamAgents added in v1.2.9

func (h *Handler) SetTeamAgents(l TeamAgentLister)

SetTeamAgents wires /admin/team-agents. Optional — unset, the page is 503.

func (*Handler) SetWorkflowOwnerWriter added in v1.2.9

func (h *Handler) SetWorkflowOwnerWriter(w WorkflowOwnerWriter)

SetWorkflowOwnerWriter wires the writer behind the workflows Owner picker.

type JobListProvider

type JobListProvider interface {
	ListJobs(ctx context.Context) ([]entity.Job, error)
}

JobListProvider is the subset of manager.Service that the admin panel needs.

type LoginStat added in v1.2.9

type LoginStat struct {
	Last  time.Time
	Count int
	Live  int
}

LoginStat is what the sessions table can say about one person: when they last signed in, how many times, and whether a session of theirs is still valid right now. A login IS a row here, so no new bookkeeping is needed to answer "who still uses this".

type ProjectLister added in v0.17.0

type ProjectLister interface {
	Projects() map[string]agentproject.Project
}

ProjectLister lists all projects from the in-memory registry.

type ProjectNamer added in v1.2.9

type ProjectNamer interface {
	ProjectName(id string) string
}

ProjectNamer resolves a project id to its display name, so the page can show "Ygsw Bot" instead of a uuid.

type ProjectWriter added in v1.2.9

type ProjectWriter interface {
	UpdateProject(ctx context.Context, id string, meta agentproject.Meta) (agentproject.Project, error)
}

ProjectWriter persists a project's metadata. Satisfied by registry.Manager — kept as an interface so package admin keeps depending on the registry only through the shapes it actually uses.

type ScheduleLister added in v1.2.9

type ScheduleLister interface {
	ListAll(ctx context.Context, limit int) ([]entity.ScheduledMessage, error)
	Reschedule(ctx context.Context, id string, patch schedule.SchedulePatch) error
}

ScheduleLister is the slice of the schedule store this page needs, kept as an interface so package admin does not depend on the store's concrete type.

type SkillLister added in v0.17.0

type SkillLister interface {
	List(ctx context.Context) ([]entity.Skill, error)
}

SkillLister lists all skills from the DB.

type SystemConfig added in v0.23.3

type SystemConfig struct {
	Coordinator *updater.Coordinator
	// VersionCache is the background-refreshed version + update snapshot.
	// The System page reads the wick-framework version, update status, and
	// cached changelog from it instead of doing a live request on load.
	VersionCache *updater.VersionCache
	AppName      string
	// DataDir is wick's data directory — where a draining predecessor leaves
	// the record of what it is still finishing.
	DataDir string
	// AppVersion is the version THIS process is running — compared against
	// the binary on disk to spot a build that is installed but not yet
	// swapped in.
	AppVersion  string
	WickVersion string
	Commit      string
	BuildTime   string
}

SystemConfig carries the System-page dependencies into the admin Handler. Grouped so NewHandler doesn't grow a long tail of positional params each time the page needs another build field.

type TagUsage added in v1.2.9

type TagUsage struct {
	TagID     string            `json:"tag_id"`
	TagName   string            `json:"tag_name"`
	UserCount int               `json:"user_count"`
	ItemCount int               `json:"item_count"`
	Users     []adminUser       `json:"users,omitempty"`
	Items     []AccessItem      `json:"items,omitempty"`
	Groups    []AccessItemGroup `json:"groups,omitempty"`
}

TagUsage is the counters shown on the Tags page plus the detail behind them.

type TeamAgent added in v1.2.9

type TeamAgent struct {
	ID, Name, Handle, OwnerUserID, Block string
	Disabled                             bool
}

TeamAgent is one Team agent as /admin/team-agents lists it. Block is non-empty when the agent can never be shared (the Captain, a remote set to "Only me"); the page lists it locked and its tags are refused.

type TeamAgentChangeTracker added in v1.2.9

type TeamAgentChangeTracker interface {
	TrackTeamAgentChange(ctx context.Context, id string) func()
}

TeamAgentChangeTracker is an optional extra of a TeamAgentLister: it tells the agents tool that an agent's share tags are about to change, so the rosters that gain or lose it refresh. Call the result once the change is saved.

type TeamAgentLister added in v1.2.9

type TeamAgentLister interface {
	TeamAgents(ctx context.Context) ([]TeamAgent, error)
}

TeamAgentLister lists every owner's Team agents.

type ToolPerm

type ToolPerm struct {
	Path       string
	Visibility entity.ToolVisibility
	Disabled   bool
	TagIDs     []string
}

type WorkflowInfo added in v0.17.0

type WorkflowInfo struct {
	Name      string
	CreatedBy string
}

WorkflowInfo carries the fields the admin page needs for a workflow row.

type WorkflowLister added in v0.17.0

type WorkflowLister interface {
	List() ([]string, error)
	LoadInfo(id string) (WorkflowInfo, error)
}

WorkflowLister lists workflow IDs and loads individual workflow metadata.

type WorkflowOwnerWriter added in v1.2.9

type WorkflowOwnerWriter interface {
	SetOwner(id, userID string) error
}

WorkflowOwnerWriter re-stamps a workflow's owner. Optional, like ProjectWriter: nil leaves the Owner column a label instead of a picker, which is the right answer for a file-backed install where there is no row to re-stamp.

Directories

Path Synopsis
templ: version: v0.3.1020
templ: version: v0.3.1020

Jump to

Keyboard shortcuts

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