Documentation
¶
Overview ¶
Package admin serves the deployment-scoped routes.
It is a package rather than a file group because its boundary is real: every route here requires a system_admin grant and none is space-scoped. Keeping it beside the space-scoped routes meant one Handler could reach every store, so nothing but review stopped an admin route from growing a space's data or a space route from consulting a grant. This Config names what administration needs and nothing else.
Index ¶
- type AdminAuditEventsResponse
- type AdminCreateModelRequest
- type AdminCreateUserRequest
- type AdminExternalIdentitiesResponse
- type AdminExternalIdentity
- type AdminGrant
- type AdminGrantRequest
- type AdminGrantsResponse
- type AdminLoginCodeResponse
- type AdminMeResponse
- type AdminModel
- type AdminModelsResponse
- type AdminSession
- type AdminSessionsResponse
- type AdminSessionsRevokedResponse
- type AdminSpace
- type AdminSpaceDetail
- type AdminSpaceMember
- type AdminSpacesResponse
- type AdminSystemResponse
- type AdminUser
- type AdminUserDetail
- type AdminUserSpace
- type AdminUsersResponse
- type Config
- type DependencyProbe
- type DeploymentInfo
- type Handler
- type OIDCStatusFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminAuditEventsResponse ¶
type AdminAuditEventsResponse struct {
Events []coreaudit.Event `json:"events"`
Total int `json:"total"`
}
AdminAuditEventsResponse is a page of the deployment-wide trail.
type AdminCreateModelRequest ¶
type AdminCreateModelRequest struct {
Name string `json:"name"`
ProviderType string `json:"provider_type"`
APIURL string `json:"api_url"`
APIKey string `json:"api_key"`
Model string `json:"model"`
ContextWindow int `json:"context_window"`
CallTimeout int `json:"call_timeout"`
MaxTokens int `json:"max_tokens"`
Reasoning string `json:"reasoning"`
CacheMode string `json:"cache_mode"`
CacheTTL string `json:"cache_ttl"`
Currency string `json:"currency"`
InputPrice string `json:"input_price"`
CacheReadPrice string `json:"cache_read_price"`
CacheWritePrice string `json:"cache_write_price"`
OutputPrice string `json:"output_price"`
Vision bool `json:"vision"`
Capabilities []string `json:"capabilities"`
}
AdminCreateModelRequest is the body of POST /api/admin/llm/models. It mirrors the fields `buildmax-server model add` takes so a model added through either edge lands as the same row.
api_key is write-only: it is accepted here in the body (never a query or path parameter, which the request log would record), stored encrypted at rest, and returned by no read — the response carries coregw.Model, which has no credential field. Prices are strings in the model's currency, resolved the same way the shell command resolves its flags.
type AdminCreateUserRequest ¶
type AdminCreateUserRequest struct {
Email string `json:"email"`
}
AdminCreateUserRequest is the body for POST /api/admin/users.
type AdminExternalIdentitiesResponse ¶
type AdminExternalIdentitiesResponse struct {
Identities []AdminExternalIdentity `json:"identities"`
}
AdminExternalIdentitiesResponse is an account's SSO links.
type AdminExternalIdentity ¶
type AdminExternalIdentity struct {
ID string `json:"id"`
Issuer string `json:"issuer"`
Subject string `json:"subject"`
LastSeenEmail string `json:"last_seen_email,omitempty"`
LastSeenName string `json:"last_seen_name,omitempty"`
LastLoginAt *time.Time `json:"last_login_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AdminExternalIdentity is one of an account's SSO links as an administrator sees it. The subject and issuer are shown because reconciling a mismatch needs them; there is no secret here — the identity key is protocol metadata, not a credential.
type AdminGrant ¶
type AdminGrant struct {
coreidentity.SystemGrant
Email string `json:"email,omitempty"`
}
AdminGrant is one grant with the account it names resolved, so a list is readable without a second call per row.
type AdminGrantRequest ¶
type AdminGrantRequest struct {
UserID string `json:"user_id"`
// Role is optional and defaults to system_admin, which is the only role
// this build accepts. It is in the body so that adding a second role later
// is not a new route.
Role string `json:"role,omitempty"`
}
AdminGrantRequest is the body for POST /api/admin/grants.
type AdminGrantsResponse ¶
type AdminGrantsResponse struct {
Grants []AdminGrant `json:"grants"`
}
AdminGrantsResponse lists who can operate the deployment.
type AdminLoginCodeResponse ¶
type AdminLoginCodeResponse struct {
Code string `json:"code"`
ExpiresAt time.Time `json:"expires_at"`
}
AdminLoginCodeResponse carries a login code, which is shown once.
type AdminMeResponse ¶
type AdminMeResponse struct {
UserID string `json:"user_id"`
Roles []string `json:"roles"`
// Grants are the caller's own active grants, so the area can show when the
// authority was given and by whom. Other people's grants are not here;
// that is GET /api/admin/grants.
Grants []coreidentity.SystemGrant `json:"grants"`
}
AdminMeResponse describes the caller's deployment-scoped authority.
It is what Portal asks before deciding whether an administration area exists for this person. A 403 is the expected answer for almost everyone and is not an error — hiding the navigation is presentation, and this route is the server's half of the same question.
type AdminModel ¶
AdminModel is one catalog entry as an administrator sees it.
coregw.Model carries no credential by construction — the key lives in the same table but leaves the store only through LLMModelCredential — so this embeds it rather than copying field by field.
Nothing is added: every enabled model is callable by every user, so a row's name and enabled state are the whole answer to "can this be used".
type AdminModelsResponse ¶
type AdminModelsResponse struct {
Models []AdminModel `json:"models"`
// DefaultModel is the model name a caller gets when it names none. Empty
// means llm.default_model was not configured and the first enabled model
// serves as the default.
DefaultModel string `json:"default_model,omitempty"`
}
AdminModelsResponse is the managed catalog.
type AdminSession ¶
type AdminSession struct {
SessionID string `json:"session_id"`
Platform string `json:"platform,omitempty"`
AuthMethod string `json:"auth_method,omitempty"`
CreatedAt time.Time `json:"created_at"`
LastSeenAt time.Time `json:"last_seen_at"`
ExpiresAt time.Time `json:"expires_at"`
}
AdminSession is one live login chain as an administrator sees it. It is a response struct, not the store's row: it carries safe metadata to recognise a device by, and never a token or its hash.
type AdminSessionsResponse ¶
type AdminSessionsResponse struct {
Sessions []AdminSession `json:"sessions"`
}
AdminSessionsResponse is the list of an account's live sessions.
type AdminSessionsRevokedResponse ¶
type AdminSessionsRevokedResponse struct {
Revoked int64 `json:"revoked"`
}
AdminSessionsRevokedResponse reports how many tokens a revocation retired.
type AdminSpace ¶
type AdminSpace struct {
ID string `json:"id"`
Name string `json:"name"`
// Personal marks a user's own space rather than a collaborative space.
Personal bool `json:"personal"`
QuotaTier string `json:"quota_tier,omitempty"`
MemberCount int `json:"member_count"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AdminSpace is one space as an administrator sees it: metadata only.
There is deliberately no field here that a space member wrote or an agent produced. The rule the design states — if a member wrote it or an agent produced it, it is content — is what keeps this struct from growing an "issue count" that turns into an issue list that turns into issue titles.
type AdminSpaceDetail ¶
type AdminSpaceDetail struct {
AdminSpace
Members []AdminSpaceMember `json:"members"`
// Usage is nil when the deployment reports no quota, so a reader can tell
// "no limits configured" from "using nothing".
Usage *spaceUsage `json:"usage,omitempty"`
}
AdminSpaceDetail adds the membership and the capacity the space is using.
type AdminSpaceMember ¶
type AdminSpaceMember struct {
UserID string `json:"user_id"`
Email string `json:"email,omitempty"`
Role string `json:"role"`
}
AdminSpaceMember names one member and their role.
type AdminSpacesResponse ¶
type AdminSpacesResponse struct {
Spaces []AdminSpace `json:"spaces"`
Total int `json:"total"`
}
AdminSpacesResponse is a page of spaces.
type AdminSystemResponse ¶
type AdminSystemResponse struct {
Version string `json:"version"`
// SchemaMigrations are the steps applied beyond the row structs'
// additive DDL. It is not a schema version — see the store method.
SchemaMigrations []adminSchemaMigration `json:"schema_migrations"`
Dependencies []adminDependency `json:"dependencies"`
// Ready mirrors what /readyz would answer right now.
Ready bool `json:"ready"`
WorkerRunMode string `json:"worker_run_mode,omitempty"`
WorkerLLMTransport string `json:"worker_llm_transport,omitempty"`
SandboxSurface string `json:"sandbox_surface,omitempty"`
AllowSignup bool `json:"allow_signup"`
TaskRuns map[string]int `json:"task_runs"`
SystemAdmins int `json:"system_admins"`
ServerTime time.Time `json:"server_time"`
// OIDC is the live SSO provider health. Nil when SSO is not configured. It
// is separate from Dependencies because a degraded IdP does not make the
// deployment not-ready — the fetch is retryable.
OIDC *adminOIDCStatus `json:"oidc,omitempty"`
}
AdminSystemResponse is what an operator opens first: is this deployment all right, and is it the version they think it is.
type AdminUser ¶
type AdminUser struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
QuotaTier string `json:"quota_tier,omitempty"`
HasPassword bool `json:"has_password"`
DisabledAt *time.Time `json:"disabled_at,omitempty"`
LastLoginAt *time.Time `json:"last_login_at,omitempty"`
LastLoginPlatform *string `json:"last_login_platform,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AdminUser is one account as an administrator sees it.
It is a response struct rather than coreidentity.User on purpose. A row struct serialized straight out is how a password hash reaches a client, and this is the surface where that would matter most — see the secret assertion in system_authz_matrix_test.go.
type AdminUserDetail ¶
type AdminUserDetail struct {
AdminUser
Spaces []AdminUserSpace `json:"spaces"`
// SessionCount counts live login chains, not tokens. It is what "signed in
// on two machines" means.
SessionCount int `json:"session_count"`
// SystemRoles are the deployment-scoped roles this account holds.
SystemRoles []string `json:"system_roles"`
}
AdminUserDetail adds what an operator needs when acting on one account: which spaces it can reach, and how many live sessions it has.
type AdminUserSpace ¶
type AdminUserSpace struct {
SpaceID string `json:"space_id"`
Name string `json:"name"`
Role string `json:"role"`
}
AdminUserSpace names a space the account belongs to and its role there. It carries no space content — see docs/design/system-administration.md section 7.
type AdminUsersResponse ¶
AdminUsersResponse is a page of accounts.
type Config ¶
type Config struct {
JWTSecret string
DefaultQuotaTier string
Users coreidentity.UserStore
LoginCodes coreidentity.LoginCodeStore
RefreshTokens coreidentity.RefreshTokenStore
Sessions coreidentity.AuthSessionStore
ExternalIdentities coreidentity.ExternalIdentityStore
Spaces corespace.Store
Grants coreidentity.SystemGrantStore
Audits coreaudit.Store
Models coregw.ModelStore
Schema coreschema.Store
TaskRuns coretask.RunStore
Quota *quota.Service
// Lifecycle sequences an account disable/enable and its cleanup, and computes
// the deactivation-impact projection. Nil falls back to setting the gate and
// revoking sessions inline, which is what a deployment without the wired
// service has.
Lifecycle *accountlifecycle.Service
// SpaceRecovery performs disabled-owner-only ownership recovery. Nil answers
// the recovery route as not configured.
SpaceRecovery *spacerecovery.Service
// Plugins publishes releases and manages catalog entries. Nil is a
// deployment with no Marketplace, which every route here reports rather
// than pretending an empty catalog.
Plugins *pluginsvc.Service
// Audit records who did what. Nil discards it, which is what a deployment
// without a database has.
Audit *audit.Recorder
Deployment DeploymentInfo
DependencyProbes []DependencyProbe
// RedactedConfig is the operator-facing view of server.yaml, built by
// internal/config so the decision about which fields may be shown lives
// next to the struct.
RedactedConfig any
// OIDCStatus reports the live SSO provider health for the system view. Nil
// means SSO is not configured. It is a closure so this package needs no
// import of the OIDC provider; bootstrap adapts the provider into it. Unlike
// a dependency probe, a degraded provider does not make the deployment
// not-ready: an IdP fetch is retryable and must not fail /readyz.
OIDCStatus OIDCStatusFunc
}
type DependencyProbe ¶
type DependencyProbe struct {
// Name must be safe to show: "database", not a DSN.
Name string
Probe func(ctx context.Context) error
}
DependencyProbe is one dependency the deployment needs, as the admin API reports it. It is the same shape the readiness endpoint uses; the server converts its checks into these so that handlers do not import the package that imports them.
type DeploymentInfo ¶
type DeploymentInfo struct {
// Version is the running binary's version string. It arrives from
// bootstrap rather than being read here: internal/server must not import
// internal/config, and a version the handler resolved itself would be a
// second answer to a question the process already has one for.
Version string
// WorkerRunMode is "k8s_job" or the local-process path.
WorkerRunMode string
// WorkerLLMTransport is "direct" or "buildmax".
WorkerLLMTransport string
AllowSignup bool
// SandboxSurface is the execution boundary worker runs resolve to. Empty
// means this deployment did not report one, which is every deployment
// today — not that runs are unconfined. See deploymentInfoFor in
// internal/bootstrap for why the server does not answer for the worker.
SandboxSurface string
// DefaultModel is the catalog model a caller gets when it names none.
// Empty means the first enabled model in the catalog, so the admin view
// reports what was configured rather than what it resolves to.
DefaultModel string
}
DeploymentInfo are the facts about a deployment that do not change while it runs. Bootstrap knows them; the handler only reports them.