Documentation
¶
Overview ¶
Package admin serves the core admin screens: dashboard widgets, users, roles, general and mail settings, system health and jobs, API keys, the audit viewer and the global admin search. It also publishes the mailer service (mailer.ServiceName) and the REST operations for those resources.
Index ¶
- Constants
- func AIConfig(provider, baseURL, model, apiKey string, keyStored bool, secretKey []byte) (map[string]any, map[string]string)
- func CompleteWorkAgent(ctx context.Context, d *kernel.Deps, connectionID, model, system, input string) (string, error)
- func FilterNavForWorkspace(mode string, items []kernel.NavItem) []kernel.NavItem
- func PostsPerPage(value string) (int, bool)
- func ValidateGeneralSetting(key, value string) (string, error)
- func ValidateSEOSetting(key, value string) (string, error)
- func WorkAgentProviderReady(ctx context.Context, d *kernel.Deps, connectionID, model string) bool
- func WorkspaceMode(ctx context.Context, s *settings.Store) string
- func WorkspaceShowsAdvanced(ctx context.Context, s *settings.Store) bool
- type HealthCheck
- type KeyCreateRequest
- type KeyDTO
- type KeyRotateRequest
- type KeySecretResponse
- type Module
- type SettingError
- type SettingsDTO
- type SettingsPatchDTO
Constants ¶
const ( SettingBackupScheduleHours = "backup.schedule_hours" SettingBackupRetain = "backup.retain" SettingBackupScheduleLast = "backup.schedule.last" SettingBackupScheduleState = "backup.schedule.state" SettingBackupLastSuccess = "backup.local.last_success" )
Local backup schedule / retention settings (System → Backups).
const ( CheckOK = "ok" CheckWarn = "warn" CheckFail = "fail" )
Health check statuses.
const ( SettingRetainDoneDays = "jobs.retain_done_days" SettingRetainDeadDays = "jobs.retain_dead_days" SettingRetainKeyedDays = "jobs.retain_keyed_days" )
Retention settings of the jobs.prune cron (whole days).
const ( PermUsers = "users.manage" PermSettings = "settings.manage" PermHealth = "system.health" PermAPIKeys = "api_keys.manage" PermBackup = "system.backup" )
Permissions used by the admin screens.
const ( AIProviderOpenAI = "openai" AIProviderAnthropic = "anthropic" )
AI writing providers (setting ai.provider; "" turns the helper off).
const ( SettingWorkspace = "site.workspace" WorkspaceSimple = "simple" WorkspaceFull = "full" )
Site workspace mode: progressive disclosure for operators who want a plain CMS versus Agents + Commerce. Empty means unset (full nav until chosen; first-run surfaces a chooser).
const HealthCheckFilter = "system.health.checks"
HealthCheckFilter is the hooks filter other modules use to contribute checks to System Health. The payload is *[]admin.HealthCheck; append to it and return it.
Variables ¶
This section is empty.
Functions ¶
func AIConfig ¶
func AIConfig(provider, baseURL, model, apiKey string, keyStored bool, secretKey []byte) (map[string]any, map[string]string)
AIConfig validates an AI writing configuration exactly as Settings → AI does and returns the settings to store (the API key encrypted with secretKey; omitted when apiKey is blank) and field errors as i18n keys. keyStored says whether a key is already stored. The CLI uses it too.
func CompleteWorkAgent ¶
func CompleteWorkAgent(ctx context.Context, d *kernel.Deps, connectionID, model, system, input string) (string, error)
CompleteWorkAgent reuses the configured server-side provider and encrypted connection registry. It executes a text-only turn, never tool calls.
func FilterNavForWorkspace ¶ added in v0.4.0
FilterNavForWorkspace drops Agents/Commerce surfaces in simple mode.
func PostsPerPage ¶
PostsPerPage parses a site.posts_per_page value (an integer 1–100).
func ValidateGeneralSetting ¶
ValidateGeneralSetting validates and normalises one Settings → General value exactly as the admin screen does, for the keys that need no other service: site.title, site.tagline (trimmed, max 500 runes), site.locale (a supported locale), site.timezone (an IANA name; "" and "Local" are rejected) and site.base_url (absolute http(s) origin, no trailing slash). It returns the value to store, or a *SettingError. Other keys (site.theme and site.front_page need the theme and content services, site.logo the media service) are rejected with code "admin.settings.error_key". contact.email must be empty or a plain address; site.posts_per_page an integer 1–100 (returned in canonical decimal form; store it as a number, see PostsPerPage).
func ValidateSEOSetting ¶
ValidateSEOSetting validates one Settings → SEO value. The rules belong to the seo module (seo.ValidateSetting); this alias keeps the admin settings validators in one place for callers such as mcp.
func WorkAgentProviderReady ¶
WorkAgentProviderReady verifies configuration and credential readability, without sending a request or claiming the provider is reachable.
func WorkspaceMode ¶ added in v0.4.0
WorkspaceMode returns simple, full, or "" when unset / unknown.
Types ¶
type HealthCheck ¶
type HealthCheck struct {
Name string `json:"name"`
Status string `json:"status"` // ok | warn | fail
Detail string `json:"detail"`
}
HealthCheck is one line of the System Health "Checks" list.
type KeyCreateRequest ¶
type KeyCreateRequest struct {
Name string `json:"name"`
Kind string `json:"kind" doc:"api (default) | agent"`
Scopes []string `json:"scopes" doc:"permission names, or [\"*\"]; never more than the caller holds (session callers only)"`
RatePerMin int `json:"rate_per_min" doc:"default 60"`
ExpiresAt string `json:"expires_at" doc:"RFC3339, empty for never"`
}
KeyCreateRequest is the POST /v1/keys body.
type KeyDTO ¶
type KeyDTO struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix" doc:"first characters after gp_, shown to identify the key"`
Kind string `json:"kind" doc:"api | agent"`
UserID string `json:"user_id"`
Scopes []string `json:"scopes"`
RatePerMin int `json:"rate_per_min"`
ExpiresAt string `json:"expires_at"`
LastUsedAt string `json:"last_used_at"`
UseCount int64 `json:"use_count" doc:"approximate; flushed at most once a minute"`
CreatedAt string `json:"created_at"`
RevokedAt string `json:"revoked_at"`
RotatedFrom string `json:"rotated_from"`
Status string `json:"status" doc:"active | expired | revoked"`
}
KeyDTO is an API key as the key console API returns it (never the secret).
type KeyRotateRequest ¶
type KeyRotateRequest struct {
GraceSeconds int `json:"grace_seconds" doc:"0 revokes the old key now; up to 604800 keeps it working that long"`
}
KeyRotateRequest is the POST /v1/keys/{id}/rotate body.
type KeySecretResponse ¶
KeySecretResponse is returned once by create and rotate: token is the plaintext key and is never shown again.
type Module ¶
type Module struct{}
Module is the admin kernel.Module.
type SettingError ¶
type SettingError struct{ Key, Code string }
SettingError is a rejected setting value; Code is an i18n key.
func (*SettingError) Error ¶
func (e *SettingError) Error() string
type SettingsDTO ¶
type SettingsDTO struct {
SiteTitle string `json:"site.title"`
SiteTagline string `json:"site.tagline"`
SiteLocale string `json:"site.locale"`
SiteTimezone string `json:"site.timezone"`
SiteBaseURL string `json:"site.base_url"`
SiteTheme string `json:"site.theme"`
SiteFrontPage string `json:"site.front_page"`
SiteLogo string `json:"site.logo"`
ContactEmail string `json:"contact.email"`
PostsPerPage int `json:"site.posts_per_page"`
MailProvider string `json:"mail.provider"`
MailResendAPIKeySet bool `json:"mail.resend_api_key_set"`
MailHost string `json:"mail.host"`
MailPort int `json:"mail.port"`
MailUsername string `json:"mail.username"`
MailFrom string `json:"mail.from"`
MailFromName string `json:"mail.from_name"`
MailTLS string `json:"mail.tls"`
MailPasswordSet bool `json:"mail.password_set"`
}
SettingsDTO is the GET /v1/settings response (and the PATCH response). mail.password is never returned; mail.password_set reports whether one is stored.
type SettingsPatchDTO ¶
type SettingsPatchDTO struct {
SiteTitle *string `json:"site.title,omitempty"`
SiteTagline *string `json:"site.tagline,omitempty"`
SiteLocale *string `json:"site.locale,omitempty"`
SiteTimezone *string `json:"site.timezone,omitempty"`
SiteBaseURL *string `json:"site.base_url,omitempty"`
SiteTheme *string `json:"site.theme,omitempty"`
SiteFrontPage *string `json:"site.front_page,omitempty"`
SiteLogo *string `json:"site.logo,omitempty"`
ContactEmail *string `json:"contact.email,omitempty"`
PostsPerPage *int `json:"site.posts_per_page,omitempty"`
MailProvider *string `json:"mail.provider,omitempty"`
MailResendAPIKey *string `json:"mail.resend_api_key,omitempty"`
MailHost *string `json:"mail.host,omitempty"`
MailPort *int `json:"mail.port,omitempty"`
MailUsername *string `json:"mail.username,omitempty"`
MailPassword *string `json:"mail.password,omitempty"`
MailFrom *string `json:"mail.from,omitempty"`
MailFromName *string `json:"mail.from_name,omitempty"`
MailTLS *string `json:"mail.tls,omitempty"`
}
SettingsPatchDTO documents the PATCH /v1/settings body: send only the keys to change. "mail.password": null clears the stored password, "" keeps it, any other string replaces it (stored encrypted). Unknown keys are rejected.
Source Files
¶
- agent_models.go
- agent_models_http.go
- agent_models_runtime.go
- aiclient.go
- aiwrite.go
- api.go
- apikeys.go
- audit.go
- backups.go
- backups_remote.go
- backups_restore.go
- backups_schedule.go
- canvas_delete.go
- canvas_gallery.go
- canvas_http.go
- canvas_operations_cancel.go
- canvas_operations_grants.go
- canvas_operations_http.go
- canvas_operations_mcp.go
- canvas_operations_media.go
- canvas_operations_model.go
- canvas_operations_runs.go
- canvas_operations_schedules.go
- canvas_references.go
- canvas_store.go
- canvas_validation.go
- canvas_widgets.go
- common.go
- connections_admin.go
- connections_mcp.go
- connections_model.go
- connections_models.go
- connections_models_http.go
- connections_probe.go
- connections_store.go
- dashboard.go
- dashboard_guide.go
- dashboard_layout.go
- dashboard_pin_views.go
- dashboard_pins_http.go
- dashboard_pins_store.go
- dashboard_setup.go
- dashboard_workspace.go
- disk_unix.go
- error_inventory.go
- error_inventory_sources.go
- health.go
- jobs.go
- keys_api.go
- metricool_admin.go
- metricool_client.go
- metricool_model.go
- metricool_store.go
- module.go
- page_assistant.go
- roles.go
- roles_api.go
- routes.go
- search.go
- settings.go
- settings_ai.go
- settings_ai_cas.go
- settings_cas.go
- settings_mail.go
- settings_mail_cas.go
- settingsvc.go
- sidebar_brand.go
- storage_admin.go
- studio_http.go
- studio_jobs.go
- studio_mcp.go
- studio_model.go
- studio_provider.go
- studio_settings.go
- studio_store.go
- userguard.go
- users.go
- usersvc.go
- validate.go
- workagents_bridge.go
- workspace.go