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 CanvasDocument
- type CanvasReader
- type CanvasSummary
- type CapabilityCheck
- type CapabilityReport
- type CapabilityState
- type HealthCheck
- type KeyCreateRequest
- type KeyDTO
- type KeyRotateRequest
- type KeySecretResponse
- type LatestRelease
- type Module
- type ModuleRequirement
- type SettingError
- type SettingsDTO
- type SettingsPatchDTO
- type TestHelper
- type UpdateStatus
Constants ¶
const ( SettingBackupScheduleHours = "backup.schedule_hours" SettingBackupRetain = "backup.retain" SettingBackupScheduleLast = "backup.schedule.last" SettingBackupScheduleState = "backup.schedule.state" SettingBackupLastSuccess = "backup.local.last_success" SettingBackupRemoteSchedule = "backup.schedule.remote_destination" )
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" PermUpdate = "system.update" )
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.
const ModuleRequirementFilter = "system.capabilities.modules"
ModuleRequirementFilter is the hooks filter modules use to report their configuration state to GET /site/capabilities. The payload is *[]admin.ModuleRequirement; append one entry per module.
const (
PermCapabilityTest = "system.capability_test"
)
Capability evidence levels. A connectivity check (list models, discover tools, probe a bucket) proves reachability only. An operation test exercises the real operation with an isolated sample under an explicit permission: send one mail to the requesting operator, write/read/delete one probe object, request one tiny completion. MCP tool invocation would execute remote actions, so MCP has no operation test. Nothing here runs during a page load or a GET.
const ServiceCanvasRead = "admin.canvases"
ServiceCanvasRead is the kernel service name for grant-scoped canvas reads.
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 (required, trimmed, max 500 runes), 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 CanvasDocument ¶ added in v0.11.0
type CanvasDocument struct {
ID string `json:"id"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
Version int64 `json:"version"`
Cards []canvasCard `json:"cards"`
Edges []canvasEdge `json:"edges"`
}
CanvasDocument is get_canvas / GET /api/v1/canvases/{id} (no secrets).
type CanvasReader ¶ added in v0.11.0
type CanvasReader interface {
List(ctx context.Context, page, perPage int) ([]CanvasSummary, int, error)
Get(ctx context.Context, id string) (*CanvasDocument, error)
}
CanvasReader is the grant-scoped list/get surface for MCP and REST.
type CanvasSummary ¶ added in v0.11.0
type CanvasSummary struct {
ID string `json:"id"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
Version int64 `json:"version"`
}
CanvasSummary is one board in list_canvases / GET /api/v1/canvases.
type CapabilityCheck ¶ added in v0.14.0
type CapabilityCheck struct {
Kind string `json:"kind" enum:"connectivity,operation"`
Scope string `json:"scope" doc:"What exactly ran, e.g. connectivity, operation:send, operation:write_read_delete, operation:complete"`
Status string `json:"status" enum:"passed,failed,unknown,stale,expired,waiting,running"`
Result string `` /* 131-byte string literal not displayed */
CheckedAt *string `json:"checked_at" doc:"Persisted RFC3339 time of the saved result; null if missing or invalid"`
ExpiresAt *string `json:"expires_at" doc:"When the evidence stops counting (checked_at + 7 days); null when unknown"`
ConfigurationMatch *bool `json:"configuration_match" doc:"Null for legacy checks not bound to a configuration revision"`
Reason string `json:"reason"`
Remediation string `json:"remediation"`
}
CapabilityCheck describes evidence, not a promise that a future operation will succeed. Kind says what ran: a connectivity/discovery check or an explicit operation test.
type CapabilityReport ¶ added in v0.14.0
type CapabilityReport struct {
ObservedAt string `json:"observed_at" doc:"When this local snapshot was read, not a health-check timestamp"`
Modules []CapabilityState `json:"modules"`
Services []CapabilityState `json:"services" doc:"Core services that are not modules (mail)"`
Connections []CapabilityState `json:"connections"`
Coverage string `json:"coverage"`
}
CapabilityReport is GET /site/capabilities.
type CapabilityState ¶ added in v0.14.0
type CapabilityState struct {
ID string `json:"id"`
Kind string `json:"kind" enum:"module,service,ai,mcp,s3,unknown"`
Available bool `json:"available"`
Enabled *bool `` /* 133-byte string literal not displayed */
Configured *bool `` /* 139-byte string literal not displayed */
Connected *bool `json:"connected" doc:"True only for a current, unexpired, passed connectivity check; null when never checked"`
Tested bool `json:"tested" doc:"True only for a current, unexpired, passed operation test; connectivity never sets this flag"`
OperationSupported bool `json:"operation_supported" doc:"Whether a safe operation test exists for this kind"`
Source string `json:"source"`
ConfigurationStatus string `json:"configuration_status" enum:"configured,incomplete,unknown"`
Reason string `json:"reason"`
Remediation string `json:"remediation"`
LastCheck *CapabilityCheck `json:"last_check" doc:"Last saved connectivity check, or null; GET never runs one"`
Operation *CapabilityCheck `json:"operation" doc:"Last saved operation test, or null; GET never runs one"`
}
CapabilityState separates facts we can observe from facts not yet reported. Null configured/enabled values must not be interpreted as false or success.
type HealthCheck ¶
type HealthCheck struct {
Name string `json:"name"`
Status string `json:"status"` // ok | warn | fail
Detail string `json:"detail"`
OptionalOff bool `json:"-"`
}
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 LatestRelease ¶ added in v0.15.0
type LatestRelease struct {
Status string `json:"status" enum:"fresh,stale,failed,waiting,running,unknown" doc:"unknown: no source configured or never observed"`
Version *string `json:"version" doc:"Null when unknown"`
Artifact *string `json:"artifact"`
ObservedAt *string `json:"observed_at" doc:"When the saved value was read from the source"`
AgeSeconds *int64 `json:"age_seconds"`
Source string `json:"source"`
Error string `json:"error" doc:"Sanitized reason of the newest failed attempt"`
}
LatestRelease is the saved background observation of the trusted source.
type Module ¶
type Module struct{}
Module is the admin kernel.Module.
type ModuleRequirement ¶ added in v0.15.0
type ModuleRequirement struct {
Module string `json:"module"`
Configured bool `json:"configured"`
Reason string `json:"reason"`
Remediation string `json:"remediation"`
}
ModuleRequirement is a module's own configuration verdict: whether its required settings are present, why not, and the practical repair step.
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"`
SiteLogoDark string `json:"site.logo_dark" doc:"Media id shown on dark backgrounds; empty falls back to site.logo"`
SiteLogoLight string `json:"site.logo_light" doc:"Media id shown on light backgrounds; empty falls back to site.logo"`
SiteIcon string `json:"site.icon" doc:"Media id for the favicon / app icon"`
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"`
MailReplyTo string `json:"mail.reply_to"`
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"`
SiteLogoDark *string `json:"site.logo_dark,omitempty"`
SiteLogoLight *string `json:"site.logo_light,omitempty"`
SiteIcon *string `json:"site.icon,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"`
MailReplyTo *string `json:"mail.reply_to,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.
type TestHelper ¶ added in v0.15.0
TestHelper exposes test-only encoding helpers to external test packages. It is compiled into the package but only useful from tests.
func (*TestHelper) EncryptSecrets ¶ added in v0.15.0
func (h *TestHelper) EncryptSecrets(t *testing.T, token, access, secret string) string
EncryptSecrets encrypts a connection secret bundle with the app's secret key.
type UpdateStatus ¶ added in v0.15.0
type UpdateStatus struct {
RunningVersion string `json:"running_version" doc:"Serving process identity (build string)"`
IsRelease bool `json:"is_release" doc:"False for development builds, which cannot be compared"`
AcceptedVersion *string `json:"accepted_version" doc:"Last target durably accepted by a completed operation; null if none"`
Latest LatestRelease `json:"latest"`
UpdateAvailable *bool `json:"update_available" doc:"Null when latest or the running identity is unknown"`
Configured bool `json:"configured" doc:"A trusted release source is configured"`
Source string `json:"source"`
Adapter string `json:"adapter" enum:"manual,coolify"`
Active *update.Operation `json:"active" doc:"Pending or running operation; null when idle"`
Last *update.Operation `json:"last" doc:"Most recent operation; null when none"`
}
UpdateStatus is GET /system/update. Latest, accepted, activated and requested versions are reported separately and never conflated.
Source Files
¶
- agent_bundles.go
- agent_bundles_http.go
- agent_models.go
- agent_models_http.go
- agent_models_runtime.go
- agent_recipes.go
- agent_roles.go
- agents_dock.go
- aiclient.go
- aiwrite.go
- api.go
- apikeys.go
- audit.go
- backups.go
- backups_remote.go
- backups_remote_schedule.go
- backups_restore.go
- backups_schedule.go
- backups_schedule_api.go
- canvas_activity.go
- canvas_ai.go
- canvas_delete.go
- canvas_gallery.go
- canvas_http.go
- canvas_inbound.go
- canvas_lifecycle.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_read.go
- canvas_read_api.go
- canvas_read_mcp.go
- canvas_references.go
- canvas_store.go
- canvas_validation.go
- canvas_widgets.go
- capabilities.go
- capability_tests.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_review_queue.go
- dashboard_setup.go
- dashboard_workspace.go
- disk_unix.go
- error_inventory.go
- error_inventory_sources.go
- export_test_helper.go
- health.go
- integrations_api.go
- integrations_cloudflare.go
- integrations_mail.go
- integrations_page.go
- integrations_storage.go
- jobs.go
- keys_api.go
- managed_tools_editor.go
- managed_tools_http.go
- managed_tools_policy.go
- managed_tools_runtime.go
- managed_tools_source.go
- metricool_admin.go
- metricool_client.go
- metricool_model.go
- metricool_store.go
- module.go
- observations.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_edge.go
- settings_mail.go
- settings_mail_cas.go
- settingsvc.go
- sidebar_brand.go
- sidebar_quick_access.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
- updates.go
- userguard.go
- users.go
- usersvc.go
- validate.go
- website_overview.go
- workagents_bridge.go
- workspace.go