Documentation
¶
Index ¶
- Constants
- Variables
- func BucketStartForKind(bucketStart time.Time, bucketKind string) time.Time
- func DeleteRoleFromCache(roleId string)
- func FilterVars(variables []*TemplateVar) map[string]interface{}
- func GetUserPermissions(user *User) []uint16
- func IsKnownTokenScope(s string) bool
- func NormalizeSpaceUsageBucketKind(bucketKind string) string
- func RenderEventTemplate(bodyTemplate string, data *EventRenderData) ([]byte, error)
- func RequestProperties(r *http.Request, properties *map[string]interface{}) *map[string]interface{}
- func ResolveVariables(srcString string, t *Template, space *Space, user *User, ...) (string, error)
- func RoleExists(roleId string) bool
- func RoleName(roleId string) string
- func RoleNames(roleIds []string) []string
- func SaveRoleToCache(role *Role)
- func SetRoleCache(roles []*Role)
- func SetStackResolver(f func(space *Space, variables map[string]interface{}) map[string]interface{})
- func SpaceUsageRetentionForKind(bucketKind string) time.Duration
- func SpaceUsageSampleIdForKind(spaceId, bucketKind string, bucketStart time.Time) string
- type AltNameEntry
- type AuditLogEntry
- type AuditLogFilter
- type CSIVolume
- type CSIVolumeCapability
- type CSIVolumeMountOptions
- type CSIVolumes
- type CfgValue
- type Command
- type Conversation
- type EventRenderData
- type EventSink
- type ExternalProvider
- type Group
- type LocalStorageSpec
- type LocalVolumeEntry
- type MCPServer
- type ManagedPathsSpec
- type NavPage
- type PathList
- type PermissionName
- type PoolDefinition
- type PortForwardEntry
- type Quota
- type Response
- type ResponseStatus
- type Role
- type Script
- type Session
- type Skill
- type Space
- type SpaceCustomField
- type SpaceJob
- type SpaceUsageSample
- type SpaceVolume
- type StackComponent
- type StackCustomField
- type StackDefinition
- type StackPortForward
- type Template
- func (template *Template) AllowedBySchedule() bool
- func (template *Template) GetVolumes(space *Space, user *User, variables map[string]interface{}) (*CSIVolumes, error)
- func (template *Template) IsLocalContainer() bool
- func (template *Template) IsManual() bool
- func (template *Template) IsValidForZone(zone string) bool
- func (template *Template) UpdateHash()
- type TemplateCustomField
- type TemplatePort
- type TemplateScheduleDays
- type TemplateVar
- type Token
- type Usage
- type User
- func (u *User) CheckPassword(password string) bool
- func (u *User) ClearOAuthTokens(providerID string)
- func (u *User) GetNavStarred() []string
- func (u *User) GetOAuthRefreshToken(providerID, encryptionKey string) string
- func (u *User) GetOAuthToken(providerID, encryptionKey string) string
- func (u *User) GetSSHPrivateKeyDecrypted(encryptionKey string) string
- func (u *User) HasAnyGroup(groups *[]string) bool
- func (u *User) HasPermission(permission uint16) bool
- func (u *User) IsAdmin() bool
- func (u *User) SetNavStarred(order []string)
- func (u *User) SetOAuthTokens(providerID, token, refreshToken, encryptionKey string)
- func (u *User) SetPassword(password string) error
- func (u *User) SetSSHPrivateKeyEncrypted(privateKey string, encryptionKey string)
- type Volume
- type VolumeDataMap
- type WebhookConfig
Constants ¶
const ( AuditActorSystem = "System" AuditActorTypeUser = "User" AuditActorTypeSystem = "System" AuditActorTypeMCP = "MCP" )
Define actor types
const ( AuditEventSystemStart = "System Start" // Auth AuditEventAuthFailed = "Login Failed" AuditEventAuthOk = "Login Success" AuditEventAuthBlocked = "Login Blocked" // Anomaly detection (Knot Pro) — emitted when a detection rule fires over // the audit event stream AuditEventAnomalyDetected = "Anomaly Detected" // Groups AuditEventGroupCreate = "Group Create" AuditEventGroupUpdate = "Group Update" AuditEventGroupDelete = "Group Delete" // Roles AuditEventRoleCreate = "Role Create" AuditEventRoleUpdate = "Role Update" AuditEventRoleDelete = "Role Delete" // Tunnels AuditEventTunnelCreate = "Tunnel Create" AuditEventTunnelDelete = "Tunnel Close" // Spaces AuditEventSpaceCreate = "Space Create" AuditEventSpaceUpdate = "Space Update" AuditEventSpaceDelete = "Space Delete" AuditEventSpaceStart = "Space Start" AuditEventSpaceStop = "Space Stop" AuditEventSpaceRestart = "Space Restart" AuditEventSpaceTransfer = "Space Transfer" // Templates AuditEventTemplateCreate = "Template Create" AuditEventTemplateUpdate = "Template Update" AuditEventTemplateDelete = "Template Delete" // Variables AuditEventVarCreate = "Variable Create" AuditEventVarUpdate = "Variable Update" AuditEventVarDelete = "Variable Delete" // Users AuditEventUserCreate = "User Create" AuditEventUserUpdate = "User Update" AuditEventUserDelete = "User Delete" // Volumes AuditEventVolumeCreate = "Volume Create" AuditEventVolumeUpdate = "Volume Update" AuditEventVolumeDelete = "Volume Delete" // Scripts AuditEventScriptCreate = "Script Create" AuditEventScriptUpdate = "Script Update" AuditEventScriptDelete = "Script Delete" AuditEventScriptExecute = "Script Execute" // Skills AuditEventSkillCreate = "Skill Create" AuditEventSkillUpdate = "Skill Update" AuditEventSkillDelete = "Skill Delete" // Slash Commands AuditEventSlashCommandCreate = "Slash Command Create" AuditEventSlashCommandUpdate = "Slash Command Update" AuditEventSlashCommandDelete = "Slash Command Delete" // MCP Servers AuditEventMCPServerCreate = "MCP Server Create" AuditEventMCPServerUpdate = "MCP Server Update" AuditEventMCPServerDelete = "MCP Server Delete" // Stack Definitions AuditEventStackDefCreate = "Stack Definition Create" AuditEventStackDefUpdate = "Stack Definition Update" AuditEventStackDefDelete = "Stack Definition Delete" // Stacks AuditEventStackStart = "Stack Start" AuditEventStackStop = "Stack Stop" AuditEventStackRestart = "Stack Restart" AuditEventStackDelete = "Stack Delete" // Event Sinks AuditEventEventSinkCreate = "Event Sink Create" AuditEventEventSinkUpdate = "Event Sink Update" AuditEventEventSinkDelete = "Event Sink Delete" AuditEventEventSinkDeliveryFailed = "Event Sink Delivery Failed" AuditEventEventSinkScriptFailed = "Event Sink Script Failed" AuditEventEventSinkDropped = "Event Sink Dropped" // Log sinks (Knot Pro) — a space registered to receive the logs of the // owner's other spaces AuditEventLogSinkRegister = "Log Sink Register" AuditEventLogSinkDeregister = "Log Sink Deregister" // Space data access — gated by server.audit.file_operations. Paths and // byte counts only; file contents never enter the audit trail. AuditEventSpaceFileOp = "Space File Op" // Interactive access to a running space — gated by // server.audit.space_sessions. AuditEventSpaceSessionOpen = "Space Session Open" // API tokens (user-managed; OAuth flow tokens are not audited) AuditEventTokenCreate = "Token Create" AuditEventTokenUpdate = "Token Update" AuditEventTokenDelete = "Token Delete" // Runtime configuration changes AuditEventConfigUpdate = "Config Update" )
Define events
const ( PermissionManageUsers = iota // Can Manage Users PermissionManageTemplates // Can Manage Templates PermissionManageSpaces // Can Manage Spaces PermissionManageVolumes // Can Manage Volumes PermissionManageGroups // Can Manage Groups PermissionManageRoles // Can Manage Roles PermissionManageVariables // Can Manage Variables PermissionUseSpaces // Can Use Spaces PermissionUseTunnels // Can Use Tunnels PermissionViewAuditLogs // Can View Audit Logs PermissionTransferSpaces // Can Transfer Spaces PermissionClusterInfo // Can View Cluster Info PermissionUseVNC // Can use VNC PermissionUseWebTerminal // Can use the web terminal PermissionUseSSH // Can use ssh connections PermissionUseCodeServer // Can use code-server PermissionUseVSCodeTunnel // Can use VSCode Tunnel PermissionUseLogs // Can use the log window PermissionRunCommands // Can run commands in spaces PermissionCopyFiles // Can copy files to/from spaces PermissionUseMCPServer // Can use MCP server PermissionUseWebAssistant // Can use web-based AI assistant PermissionManageScripts // Can Manage System/Global Scripts PermissionExecuteScripts // Can Execute System/Global Scripts PermissionManageOwnScripts // Can Manage Own Scripts PermissionExecuteOwnScripts // Can Execute Own Scripts PermissionManageGlobalSkills // Can Manage Global Skills PermissionManageOwnSkills // Can Manage Own Skills PermissionSetSpaceDependencies // Can configure space dependencies in the UI PermissionUseSpaceStartupScript // Can configure user startup script in the space form UI PermissionDownloadAuditLogs // Can Download Audit Logs PermissionManageStackDefinitions // Can create/edit/delete global (system) stack definitions PermissionManageOwnStackDefinitions // Can create/edit/delete personal stack definitions PermissionUseStackDefinitions // Can create instances from stack definitions PermissionUseMethods // Can use shared space methods PermissionUsePools // Can use space pools PermissionManageEvents // Can Manage Own Event Sinks PermissionManageGlobalEvents // Can Manage Global Event Sinks PermissionManageGlobalSlashCommands // Can Manage Global Slash Commands PermissionManageOwnSlashCommands // Can Manage Own Slash Commands PermissionManageMCPServers // Can Manage MCP Servers // PermissionUseLogSinks is enforced only by Knot Pro (spaces registering // as log sinks); the constant exists in both editions so the permission // ids stay aligned, but Core never grants or checks it. PermissionUseLogSinks // Can register a space as a log sink receiving own space logs // PermissionEditSpaceJobs gates editing job definitions (and the runner // toggle) on the user's own spaces; viewing them is always allowed. PermissionEditSpaceJobs // Can edit the scheduled jobs of own spaces )
Permissions
const ( WebSessionCookie = "__KNOT_WEBUI_SESSION" SessionExpiryDuration = 2 * time.Hour )
const ( SpaceUsageBucketMinute = "minute" SpaceUsageBucketDay = "day" SpaceUsageMinuteRetention = 1 * time.Hour SpaceUsageDayRetention = 7 * 24 * time.Hour )
const ( PlatformManual = "manual" PlatformDocker = "docker" PlatformPodman = "podman" PlatformNomad = "nomad" PlatformApple = "apple" PlatformContainer = "container" LeafNodeZone = "<leaf-node>" HealthCheckNone = "none" HealthCheckAgent = "agent" HealthCheckTCP = "tcp" HealthCheckHTTP = "http" HealthCheckProgram = "program" HealthCheckCustom = "custom" )
const ( MaxTokenAge = 14 * 24 * time.Hour // 2 weeks // ScopeMethods allows a token to reach /api/methods* endpoints. // Scopes are narrowing: an empty/nil Scopes slice means unrestricted // (the token inherits the user's full authenticated surface, matching // pre-scopes behaviour). A non-empty slice restricts the token to only // the endpoint groups named by the listed scopes. ScopeMethods = "methods" ScopeMCP = "mcp" )
const DefaultWebhookBodyTemplate = `` /* 147-byte string literal not displayed */
Preference keys stored under User.Preferences.
const (
RoleAdminUUID = "00000000-0000-0000-0000-000000000000"
)
Roles
Variables ¶
var AuditHook func(entry *AuditLogEntry)
AuditHook, when set, is invoked synchronously for every audit event — once on the server that emits it and, via cluster gossip, once on every peer that receives it — before the entry is routed or stored. It lives here (rather than in util/audit) so the service and cluster packages can tap the stream without an import cycle. Implementations must be fast, and must skip the events they generate themselves (e.g. AuditEventAnomalyDetected) or they will recurse. Used by Knot Pro to run anomaly detection over the cluster-wide audit stream.
var KnownTokenScopes = []string{ScopeMethods, ScopeMCP}
KnownTokenScopes is the authoritative list of valid scope strings.
var PermissionNames = []PermissionName{ {PermissionViewAuditLogs, "Audit", "View Audit Logs", "View the audit log of system activity."}, {PermissionDownloadAuditLogs, "Audit", "Download Audit Logs", "Export audit log entries to a file."}, {PermissionClusterInfo, "System", "View Cluster Info", "View cluster node and topology information."}, {PermissionManageGroups, "User Management", "Manage Groups", "Create, edit, and delete user groups."}, {PermissionManageRoles, "User Management", "Manage Roles", "Create, edit, and delete roles and their permissions."}, {PermissionManageUsers, "User Management", "Manage Users", "Create, edit, and delete user accounts."}, {PermissionManageSpaces, "Resource Management", "Manage Spaces", "Manage any space, including those owned by other users."}, {PermissionManageTemplates, "Resource Management", "Manage Templates", "Create, edit, and delete space templates."}, {PermissionManageVariables, "Resource Management", "Manage Variables", "Create, edit, and delete system variables."}, {PermissionManageVolumes, "Resource Management", "Manage Volumes", "Create, edit, and delete volumes."}, {PermissionUseMCPServer, "AI Tools", "Use MCP Server", "Connect to the knot MCP server."}, {PermissionUseWebAssistant, "AI Tools", "Use Web Assistant", "Use the built-in web AI assistant."}, {PermissionManageScripts, "Scripting", "Manage System Scripts", "Create and edit system (global) scripts."}, {PermissionExecuteScripts, "Scripting", "Execute System Scripts", "Run system (global) scripts."}, {PermissionManageOwnScripts, "Scripting", "Manage Own Scripts", "Create and edit your own scripts."}, {PermissionExecuteOwnScripts, "Scripting", "Execute Own Scripts", "Run your own scripts."}, {PermissionManageEvents, "Events", "Manage Own Event Sinks", "Create and manage your own event sinks."}, {PermissionManageGlobalEvents, "Events", "Manage Global Event Sinks", "Create and manage global event sinks."}, {PermissionManageGlobalSkills, "Skills", "Manage Global Skills", "Create and edit global skills."}, {PermissionManageOwnSkills, "Skills", "Manage Own Skills", "Create and edit your own skills."}, {PermissionManageGlobalSlashCommands, "Slash Commands", "Manage Global Slash Commands", "Create and edit global slash commands."}, {PermissionManageOwnSlashCommands, "Slash Commands", "Manage Own Slash Commands", "Create and edit your own slash commands."}, {PermissionManageMCPServers, "AI Tools", "Manage MCP Servers", "Register and configure MCP servers."}, {PermissionManageStackDefinitions, "Stacks", "Manage Global Stack Definitions", "Create, edit, and delete global (system) stack definitions."}, {PermissionManageOwnStackDefinitions, "Stacks", "Manage Own Stack Definitions", "Create, edit, and delete personal stack definitions."}, {PermissionUseStackDefinitions, "Stacks", "Use Stack Definitions", "Create spaces from stack definitions."}, {PermissionUseMethods, "Methods", "Use Space Methods Shared by Others", "Call space methods shared by other users."}, {PermissionUseTunnels, "Public Tunnels", "Use Tunnels", "Expose a local or space port as a public URL via a knot tunnel."}, {PermissionUseSpaces, "Space Operations", "Use Spaces", "Create and run spaces."}, {PermissionUsePools, "Space Operations", "Use Space Pools", "Create and run space pools."}, {PermissionSetSpaceDependencies, "Space Operations", "Set Space Dependencies", "Configure dependencies between spaces."}, {PermissionEditSpaceJobs, "Space Operations", "Edit Space Jobs", "Edit the scheduled jobs of your own spaces."}, {PermissionUseSpaceStartupScript, "Space Operations", "Use User Startup Script", "Set a user startup script that runs when a space starts."}, {PermissionShareSpaces, "Space Operations", "Share Spaces", "Share your spaces with other users."}, {PermissionTransferSpaces, "Space Operations", "Transfer Spaces", "Transfer ownership of your spaces to another user."}, {PermissionUseCodeServer, "Space Operations", "Use Code Server", "Open code-server in a space."}, {PermissionUseLogs, "Space Operations", "View Logs", "View the log window for a space."}, {PermissionUseSSH, "Space Operations", "Use SSH", "Connect to spaces over SSH."}, {PermissionUseVNC, "Space Operations", "Use VNC", "Use the VNC graphical desktop in a space."}, {PermissionUseVSCodeTunnel, "Space Operations", "Use VSCode Tunnel", "Connect to a space via a VS Code tunnel."}, {PermissionUseWebTerminal, "Space Operations", "Use Web Terminal", "Use the web terminal in a space."}, {PermissionRunCommands, "Space Operations", "Run Commands", "Execute commands inside a space."}, {PermissionCopyFiles, "Space Operations", "Copy Files", "Copy files to and from a space."}, }
Functions ¶
func BucketStartForKind ¶ added in v0.24.0
func DeleteRoleFromCache ¶
func DeleteRoleFromCache(roleId string)
func FilterVars ¶
func FilterVars(variables []*TemplateVar) map[string]interface{}
func GetUserPermissions ¶ added in v0.23.0
GetUserPermissions returns all permission integers for a user (resolves from roles)
func IsKnownTokenScope ¶ added in v0.28.0
IsKnownTokenScope reports whether s is a valid scope string.
func NormalizeSpaceUsageBucketKind ¶ added in v0.24.0
func RenderEventTemplate ¶ added in v0.28.0
func RenderEventTemplate(bodyTemplate string, data *EventRenderData) ([]byte, error)
func RequestProperties ¶ added in v0.24.0
RequestProperties extracts source_ip and user_agent from an HTTP request and merges them into an existing properties map, or creates a new one.
func ResolveVariables ¶
func ResolveVariables(srcString string, t *Template, space *Space, user *User, variables map[string]interface{}) (string, error)
Parse an input string and resolve knot variables
func RoleExists ¶
func RoleName ¶ added in v0.33.0
RoleName resolves a role id to its cached name, falling back to the id for unknown roles (e.g. audit entries emitted before the cache was warm).
func SaveRoleToCache ¶
func SaveRoleToCache(role *Role)
func SetRoleCache ¶
func SetRoleCache(roles []*Role)
func SetStackResolver ¶ added in v0.30.1
func SetStackResolver(f func(space *Space, variables map[string]interface{}) map[string]interface{})
SetStackResolver registers the function used to resolve .stack.* template variables. Intended to be called once at server startup.
func SpaceUsageRetentionForKind ¶ added in v0.24.0
Types ¶
type AltNameEntry ¶ added in v0.25.0
func (*AltNameEntry) Scan ¶ added in v0.25.0
func (a *AltNameEntry) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type AuditLogEntry ¶
type AuditLogEntry struct {
Id int64 `json:"audit_log_id" db:"audit_log_id,pk"`
Zone string `json:"zone" db:"zone"`
Actor string `json:"actor" db:"actor"`
ActorType string `json:"actor_type" db:"actor_type"`
Event string `json:"event" db:"event"`
When time.Time `json:"created_at" db:"created_at"`
Details string `json:"details" db:"details"`
Properties map[string]interface{} `json:"properties" db:"properties,json"`
}
func NewAuditLogEntry ¶
func NewAuditLogEntry(actor, actorType, event, details string, properties *map[string]interface{}) *AuditLogEntry
func (*AuditLogEntry) MatchesFilter ¶ added in v0.24.0
func (e *AuditLogEntry) MatchesFilter(filter *AuditLogFilter) bool
MatchesFilter returns true if the entry matches the given filter criteria.
type AuditLogFilter ¶ added in v0.24.0
type CSIVolume ¶
type CSIVolume struct {
Id string `yaml:"id" json:"ID"`
Name string `yaml:"name" json:"Name"`
Namespace string `yaml:"namespace" json:"Namespace"`
PuluginId string `yaml:"plugin_id" json:"PluginID"`
Type string `yaml:"type" json:"Type"`
MountOptions CSIVolumeMountOptions `yaml:"mount_options" json:"MountOptions"`
CapacityMin interface{} `yaml:"capacity_min,omitempty" json:"RequestedCapacityMin,omitempty"`
CapacityMax interface{} `yaml:"capacity_max,omitempty" json:"RequestedCapacityMax,omitempty"`
Capabilities []CSIVolumeCapability `yaml:"capabilities,omitempty" json:"RequestedCapabilities,omitempty"`
Secrets map[string]string `yaml:"secrets,omitempty" json:"Secrets,omitempty"`
Parameters map[string]string `yaml:"parameters,omitempty" json:"Parameters,omitempty"`
}
type CSIVolumeCapability ¶
type CSIVolumeMountOptions ¶
type CSIVolumes ¶
type CSIVolumes struct {
Volumes []CSIVolume `yaml:"volumes" json:"Volumes"`
}
func LoadVolumesFromYaml ¶
type CfgValue ¶
type CfgValue struct {
Name string `json:"name" db:"name,pk" msgpack:"name"`
Value string `json:"value" db:"value" msgpack:"value"`
}
CfgValue object
type Command ¶ added in v0.29.0
type Command struct {
Id string `json:"command_id" db:"command_id,pk"`
UserId string `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
ArgumentHint string `json:"argument_hint" db:"argument_hint"`
AllowedTools []string `json:"allowed_tools" db:"allowed_tools,json"`
Body string `json:"body" db:"body"`
Groups []string `json:"groups" db:"groups,json"`
Zones []string `json:"zones" db:"zones,json"`
Active bool `json:"active" db:"active"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
Command is a user-invokable slash command stored in the database. Mirrors the shape of a lmchatkit slash-command markdown file (name, description, argument-hint, allowed-tools, body) plus the ownership/ACL fields used by knot (UserId for user/global, Groups, Zones, Active). The Body is the raw markdown with an optional $ARGUMENTS placeholder substituted at render time.
func NewCommand ¶ added in v0.29.0
func (*Command) IsGlobalCommand ¶ added in v0.29.0
func (*Command) IsUserCommand ¶ added in v0.29.0
func (*Command) IsValidForZone ¶ added in v0.29.0
type Conversation ¶ added in v0.29.0
type Conversation struct {
Id string `json:"conversation_id" db:"conversation_id,pk" msgpack:"conversation_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
Title string `json:"title" db:"title" msgpack:"title"`
Data string `json:"data" db:"data" msgpack:"data"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
}
Conversation is a stored chat conversation (server-side chat history).
It is owned by a single user (UserId) and holds the full lmchatkit StoredConversation (summary + messages) as an opaque JSON blob in Data — the HistoryStore implementation (internal/lmchatkit) owns the encoding, so this package stays free of any lmchatkit dependency.
UpdatedAt is a hybrid-logical-clock timestamp used for gossip conflict resolution between cluster servers (the newest copy wins). IsDeleted is a soft-delete tombstone that is itself gossiped, so a late-arriving save can never resurrect a conversation the user deleted.
type EventRenderData ¶ added in v0.28.0
type EventSink ¶ added in v0.28.0
type EventSink struct {
Id string `json:"event_sink_id" db:"event_sink_id,pk" msgpack:"event_sink_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
Name string `json:"name" db:"name" msgpack:"name"`
Description string `json:"description" db:"description" msgpack:"description"`
Events []string `json:"events" db:"events,json" msgpack:"events"`
SinkType string `json:"sink_type" db:"sink_type" msgpack:"sink_type"`
Webhook *WebhookConfig `json:"webhook,omitempty" db:"webhook,json" msgpack:"webhook,omitempty"`
ScriptId string `json:"script_id,omitempty" db:"script_id" msgpack:"script_id,omitempty"`
Active bool `json:"active" db:"active" msgpack:"active"`
CreatedUserId string `json:"created_user_id" db:"created_user_id" msgpack:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id" msgpack:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
}
func NewEventSink ¶ added in v0.28.0
func (*EventSink) IsGlobalSink ¶ added in v0.28.0
func (*EventSink) MatchEventType ¶ added in v0.28.0
MatchEventType tests if an event type matches any of the sink's patterns.
type ExternalProvider ¶ added in v0.23.7
type ExternalProvider struct {
ProviderUID string `json:"provider_uid"` // provider's own stable user ID (e.g. GitHub integer ID)
Username string `json:"username"` // human-readable handle, may change
Token string `json:"token"` // encrypted access token
RefreshToken string `json:"refresh_token,omitempty"` // encrypted refresh token
}
ExternalProvider holds the identity and token for a linked OAuth provider.
type Group ¶
type Group struct {
Id string `json:"group_id" db:"group_id,pk" msgpack:"group_id"`
Name string `json:"name" db:"name" msgpack:"name"`
MaxSpaces uint32 `json:"max_spaces" db:"max_spaces" msgpack:"max_spaces"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units" msgpack:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units" msgpack:"storage_units"`
MaxTunnels uint32 `json:"max_tunnels" db:"max_tunnels" msgpack:"max_tunnels"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id" msgpack:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id" msgpack:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
Group object
type LocalStorageSpec ¶ added in v0.25.0
type LocalStorageSpec struct {
Volumes map[string]LocalVolumeEntry `yaml:"volumes"`
Paths PathList `yaml:"paths"`
}
func LoadLocalStorageFromYaml ¶ added in v0.25.0
type LocalVolumeEntry ¶ added in v0.25.0
type LocalVolumeEntry struct {
Size string `yaml:"size,omitempty"`
}
type MCPServer ¶ added in v0.29.0
type MCPServer struct {
Id string `json:"mcp_server_id" db:"mcp_server_id,pk" msgpack:"mcp_server_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
Namespace string `json:"namespace" db:"namespace" msgpack:"namespace"`
URL string `json:"url" db:"url" msgpack:"url"`
Command string `json:"command" db:"command" msgpack:"command"`
Args []string `json:"args" db:"args,json" msgpack:"args"`
Env []string `json:"env" db:"env,json" msgpack:"env"`
AuthType string `json:"auth_type" db:"auth_type" msgpack:"auth_type"`
Token string `json:"token" db:"token" msgpack:"token"`
OAuthClientID string `json:"oauth_client_id" db:"oauth_client_id" msgpack:"oauth_client_id"`
OAuthTokenURL string `json:"oauth_token_url" db:"oauth_token_url" msgpack:"oauth_token_url"`
OAuthAccessToken string `json:"oauth_access_token" db:"oauth_access_token" msgpack:"oauth_access_token"`
OAuthRefreshToken string `json:"oauth_refresh_token" db:"oauth_refresh_token" msgpack:"oauth_refresh_token"`
Enabled bool `json:"enabled" db:"enabled" msgpack:"enabled"`
ToolVisibility string `json:"tool_visibility" db:"tool_visibility" msgpack:"tool_visibility"`
DisabledTools []string `json:"disabled_tools" db:"disabled_tools,json" msgpack:"disabled_tools"`
RemoteSearch bool `json:"remote_search" db:"remote_search" msgpack:"remote_search"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id" msgpack:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id" msgpack:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
func NewMCPServer ¶ added in v0.29.0
func (*MCPServer) IsToolEnabled ¶ added in v0.29.0
IsToolEnabled checks if a specific tool is enabled for this server. A tool is enabled unless it appears in the DisabledTools list.
func (*MCPServer) IsUserServer ¶ added in v0.29.0
type ManagedPathsSpec ¶ added in v0.25.0
type ManagedPathsSpec struct {
Paths PathList `yaml:"paths"`
}
func LoadManagedPathsFromYaml ¶ added in v0.25.0
type NavPage ¶ added in v0.32.0
type NavPage struct {
}
NavPage is a sidebar navigation destination (a page), without any icon or top/More grouping — just enough for the global-search "pages" group.
func VisibleNavPages ¶ added in v0.32.0
func VisibleNavPages(user *User, cfg *config.ServerConfig, auditAvailable bool) []NavPage
VisibleNavPages returns the sidebar pages the given user may see, in sidebar order. The visibility gates mirror web/nav.go buildNav exactly (combined across the top and "More" sections), so a page appears here iff it appears in the user's menu. auditAvailable is whether the audit-log feature is usable in this deployment (storage present + not routed externally) — passed in so this function stays pure and testable.
type PermissionName ¶
type PoolDefinition ¶ added in v0.28.0
type PoolDefinition struct {
Id string `json:"pool_id" db:"pool_id,pk" msgpack:"pool_id"`
Name string `json:"name" db:"name" msgpack:"name"`
TemplateId string `json:"template_id" db:"template_id" msgpack:"template_id"`
StartupScriptId string `json:"startup_script_id" db:"startup_script_id" msgpack:"startup_script_id"`
DesiredCount int `json:"desired_count" db:"desired_count" msgpack:"desired_count"`
Active bool `json:"active" db:"active" msgpack:"active"`
Zone string `json:"zone" db:"zone" msgpack:"zone"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id" msgpack:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id" msgpack:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
func NewPoolDefinition ¶ added in v0.28.0
func NewPoolDefinition(name, templateId, startupScriptId string, desiredCount int, userId string) *PoolDefinition
type PortForwardEntry ¶ added in v0.24.0
type PortForwardEntry struct {
LocalPort uint16 `json:"local_port"`
Space string `json:"space"`
RemotePort uint16 `json:"remote_port"`
}
func (*PortForwardEntry) Scan ¶ added in v0.24.0
func (pf *PortForwardEntry) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type Response ¶ added in v0.23.0
type Response struct {
Id string `json:"response_id" db:"response_id,pk" msgpack:"response_id"`
Status ResponseStatus `json:"status" db:"status" msgpack:"status"`
Request map[string]interface{} `json:"request" db:"request,json" msgpack:"request"`
Response map[string]interface{} `json:"response" db:"response,json" msgpack:"response"`
Error string `json:"error,omitempty" db:"error_text" msgpack:"error"`
PreviousResponseId string `json:"previous_response_id,omitempty" db:"previous_response_id" msgpack:"previous_response_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
SpaceId string `json:"space_id,omitempty" db:"space_id" msgpack:"space_id"`
ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at" msgpack:"expires_at"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
Response object for OpenAI Responses API
func NewResponse ¶ added in v0.23.0
NewResponse creates a new Response object
func (*Response) GetRequest ¶ added in v0.23.0
GetRequest populates the request data into a structure
func (*Response) GetResponse ¶ added in v0.23.0
GetResponse populates the response data into a structure
func (*Response) SetRequest ¶ added in v0.23.0
SetRequest sets the request data from a JSON-serializable structure
func (*Response) SetResponse ¶ added in v0.23.0
SetResponse sets the response data from a JSON-serializable structure
type ResponseStatus ¶ added in v0.23.0
type ResponseStatus string
ResponseStatus represents the status of a response
const ( StatusPending ResponseStatus = "pending" StatusInProgress ResponseStatus = "in_progress" StatusCompleted ResponseStatus = "completed" StatusCancelled ResponseStatus = "cancelled" StatusFailed ResponseStatus = "failed" )
type Role ¶
type Role struct {
Id string `json:"role_id" db:"role_id,pk" msgpack:"role_id"`
Name string `json:"name" db:"name" msgpack:"name"`
Permissions []uint16 `json:"permissions" db:"permissions,json" msgpack:"permissions"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id" msgpack:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id" msgpack:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
Role
func GetRolesFromCache ¶
func GetRolesFromCache() []*Role
type Script ¶ added in v0.23.0
type Script struct {
Id string `json:"script_id" db:"script_id,pk"`
UserId string `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Content string `json:"content" db:"content"`
Groups []string `json:"groups" db:"groups,json"`
Zones []string `json:"zones" db:"zones,json"`
Active bool `json:"active" db:"active"`
ScriptType string `json:"script_type" db:"script_type"`
MCPInputSchemaToml string `json:"mcp_input_schema_toml" db:"mcp_input_schema_toml"`
MCPKeywords []string `json:"mcp_keywords" db:"mcp_keywords,json"`
Discoverable bool `json:"discoverable" db:"discoverable"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
func (*Script) IsGlobalScript ¶ added in v0.23.0
IsGlobalScript returns true if the script is a system/global script (UserId is empty)
func (*Script) IsUserScript ¶ added in v0.23.0
IsUserScript returns true if the script is a user script (UserId is not empty)
func (*Script) IsValidForZone ¶ added in v0.23.0
IsValidForZone determines whether the script is valid for execution in the specified zone. The function evaluates zone restrictions based on the script's Zones configuration. If no zones are specified, the script is considered valid for all zones (global). Zone names prefixed with '!' are treated as exclusions (negated zones). The function first checks for exclusions, then checks for explicit inclusions.
zone is the target zone name to validate against the script's zone restrictions.
Returns true if the script can be executed in the specified zone, false otherwise.
type Session ¶
type Session struct {
Id string `json:"session_id" db:"session_id,pk"`
Ip string `json:"ip" db:"ip"`
UserId string `json:"user_id" db:"user_id"`
UserAgent string `json:"user_agent" db:"user_agent"`
ExpiresAfter time.Time `json:"expires_after" db:"expires_after"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
}
Session object
type Skill ¶ added in v0.23.0
type Skill struct {
Id string `json:"skill_id" db:"skill_id,pk"`
UserId string `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Content string `json:"content" db:"content"`
Groups []string `json:"groups" db:"groups,json"`
Zones []string `json:"zones" db:"zones,json"`
Active bool `json:"active" db:"active"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
func (*Skill) IsGlobalSkill ¶ added in v0.23.0
func (*Skill) IsUserSkill ¶ added in v0.23.0
func (*Skill) IsValidForZone ¶ added in v0.23.0
type Space ¶
type Space struct {
Id string `json:"space_id" db:"space_id,pk" msgpack:"space_id"`
ParentSpaceId string `json:"parent_space_id" db:"parent_space_id" msgpack:"parent_space_id"`
PoolId string `json:"pool_id" db:"pool_id" msgpack:"pool_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
TemplateId string `json:"template_id" db:"template_id" msgpack:"template_id"`
DependsOn []string `json:"depends_on" db:"depends_on,json" msgpack:"depends_on"`
Name string `json:"name" db:"name" msgpack:"name"`
Description string `json:"description" db:"description" msgpack:"description"`
Note string `json:"note" db:"note" msgpack:"note"`
Stack string `json:"stack" db:"stack" msgpack:"stack"`
StackPrefix string `json:"stack_prefix" db:"stack_prefix" msgpack:"stack_prefix"`
Zone string `json:"zone" db:"zone" msgpack:"zone"`
NodeId string `json:"node_id,omitempty" db:"node_id" msgpack:"node_id,omitempty"`
Shell string `json:"shell" db:"shell" msgpack:"shell"`
StartupScriptId string `json:"startup_script_id" db:"startup_script_id" msgpack:"startup_script_id"`
TemplateHash string `json:"template_hash" db:"template_hash" msgpack:"template_hash"`
NomadNamespace string `json:"nomad_namespace" db:"nomad_namespace" msgpack:"nomad_namespace"`
ContainerId string `json:"container_id" db:"container_id" msgpack:"container_id"`
IconURL string `json:"icon_url" db:"icon_url" msgpack:"icon_url"`
VolumeData VolumeDataMap `json:"volume_data" db:"volume_data" msgpack:"volume_data"`
SSHHostSigner string `json:"ssh_host_signer" db:"ssh_host_signer" msgpack:"ssh_host_signer"`
IsDeployed bool `json:"is_deployed" db:"is_deployed" msgpack:"is_deployed"`
IsPending bool `json:"is_pending" db:"is_pending" msgpack:"is_pending"` // Flags if the space is pending a state change, starting or stopping
IsDeleting bool `json:"is_deleting" db:"is_deleting" msgpack:"is_deleting"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
AltNames []AltNameEntry `json:"alt_names" msgpack:"alt_names"`
CustomFields []SpaceCustomField `json:"custom_fields" db:"custom_fields,json" msgpack:"custom_fields"`
PortForwards []PortForwardEntry `json:"port_forwards" db:"port_forwards,json" msgpack:"port_forwards"`
Jobs []SpaceJob `json:"jobs" db:"jobs,json" msgpack:"jobs"`
JobsEnabled bool `json:"jobs_enabled" db:"jobs_enabled" msgpack:"jobs_enabled"`
StartedAt time.Time `json:"started_at" db:"started_at" msgpack:"started_at"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
Space object
func NewSpace ¶
func NewSpace(name string, description string, userId string, templateId string, shell string, altNames *[]AltNameEntry, zone string, iconURL string, customFields []SpaceCustomField) *Space
func (*Space) IsSharedWith ¶ added in v0.24.0
func (*Space) MaxUptimeReached ¶
func (*Space) NormalizeDependsOn ¶ added in v0.24.0
func (s *Space) NormalizeDependsOn()
func (*Space) NormalizeShares ¶ added in v0.24.0
func (s *Space) NormalizeShares()
func (*Space) SetSingleShare ¶ added in v0.24.0
func (*Space) SharedUserIds ¶ added in v0.24.0
type SpaceCustomField ¶
type SpaceJob ¶ added in v0.33.0
type SpaceJob struct {
Name string `json:"name" msgpack:"name"`
Command string `json:"command" msgpack:"command"`
Schedule string `json:"schedule,omitempty" msgpack:"schedule,omitempty"` // 5-field cron expression, empty = manual only
Enabled bool `json:"enabled" msgpack:"enabled"` // gates automatic firing only, manual runs always work
}
SpaceJob is one job definition stored on the space and pushed to the agent, which holds it in memory only — the space record is the source of truth.
type SpaceUsageSample ¶ added in v0.24.0
type SpaceUsageSample struct {
Id string `json:"space_usage_id" db:"space_usage_id,pk" msgpack:"space_usage_id"`
SpaceId string `json:"space_id" db:"space_id" msgpack:"space_id"`
UserId string `json:"user_id" db:"user_id" msgpack:"user_id"`
BucketKind string `json:"bucket_kind" db:"bucket_kind" msgpack:"bucket_kind"`
BucketStart time.Time `json:"bucket_start" db:"bucket_start" msgpack:"bucket_start"`
CPUPercent float64 `json:"cpu_percent" db:"cpu_percent" msgpack:"cpu_percent"`
MemoryUsedBytes uint64 `json:"memory_used_bytes" db:"memory_used_bytes" msgpack:"memory_used_bytes"`
MemoryLimitBytes uint64 `json:"memory_limit_bytes" db:"memory_limit_bytes" msgpack:"memory_limit_bytes"`
DiskUsedBytes uint64 `json:"disk_used_bytes" db:"disk_used_bytes" msgpack:"disk_used_bytes"`
DiskLimitBytes uint64 `json:"disk_limit_bytes" db:"disk_limit_bytes" msgpack:"disk_limit_bytes"`
ActivityWriteCount uint32 `json:"activity_write_count" db:"activity_write_count" msgpack:"activity_write_count"`
ActivityCreateCount uint32 `json:"activity_create_count" db:"activity_create_count" msgpack:"activity_create_count"`
ActivityDeleteCount uint32 `json:"activity_delete_count" db:"activity_delete_count" msgpack:"activity_delete_count"`
ActivityRenameCount uint32 `json:"activity_rename_count" db:"activity_rename_count" msgpack:"activity_rename_count"`
ActivityDistinctPaths uint32 `json:"activity_distinct_paths" db:"activity_distinct_paths" msgpack:"activity_distinct_paths"`
ActivitySpaceStarts uint32 `json:"activity_space_starts" db:"activity_space_starts" msgpack:"activity_space_starts"`
ActivitySpaceStops uint32 `json:"activity_space_stops" db:"activity_space_stops" msgpack:"activity_space_stops"`
ActivitySpaceCreates uint32 `json:"activity_space_creates" db:"activity_space_creates" msgpack:"activity_space_creates"`
ActivitySpaceDeletes uint32 `json:"activity_space_deletes" db:"activity_space_deletes" msgpack:"activity_space_deletes"`
LastActivityAt *time.Time `json:"last_activity_at,omitempty" db:"last_activity_at" msgpack:"last_activity_at,omitempty"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
}
func NewSpaceUsageSample ¶ added in v0.24.0
func NewSpaceUsageSample(spaceId, userId, bucketKind string, bucketStart time.Time) *SpaceUsageSample
type SpaceVolume ¶
type SpaceVolume struct {
Id string `json:"id"`
Namespace string `json:"Namespace"`
Type string `json:"type,omitempty"`
}
func (*SpaceVolume) Scan ¶
func (sv *SpaceVolume) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type StackComponent ¶ added in v0.24.0
type StackComponent struct {
Name string `json:"name" db:"name"`
TemplateId string `json:"template_id" db:"template_id"`
Description string `json:"description" db:"description"`
Shell string `json:"shell" db:"shell"`
StartupScriptId string `json:"startup_script_id" db:"startup_script_id"`
DependsOn []string `json:"depends_on" db:"depends_on,json"`
CustomFields []StackCustomField `json:"custom_fields" db:"custom_fields,json"`
PortForwards []StackPortForward `json:"port_forwards" db:"port_forwards,json"`
}
type StackCustomField ¶ added in v0.24.0
type StackDefinition ¶ added in v0.24.0
type StackDefinition struct {
Id string `json:"stack_definition_id" db:"stack_definition_id,pk"`
UserId string `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
IconURL string `json:"icon_url" db:"icon_url"`
Groups []string `json:"groups" db:"groups,json"`
Zones []string `json:"zones" db:"zones,json"`
Active bool `json:"active" db:"active"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
Components []StackComponent `json:"components" db:"components,json"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
func NewStackDefinition ¶ added in v0.24.0
func NewStackDefinition( name string, description string, iconUrl string, groups []string, zones []string, active bool, components []StackComponent, ownerUserId string, createdUserId string, ) *StackDefinition
func (*StackDefinition) IsGlobal ¶ added in v0.24.0
func (sd *StackDefinition) IsGlobal() bool
IsGlobal returns true if the definition is a system/global definition (UserId is empty)
func (*StackDefinition) IsValidForZone ¶ added in v0.24.0
func (sd *StackDefinition) IsValidForZone(zone string) bool
IsValidForZone determines whether the stack definition is valid for the specified zone. Follows the same !-prefix negation logic as Script.IsValidForZone.
type StackPortForward ¶ added in v0.24.0
type Template ¶
type Template struct {
Id string `json:"template_id" db:"template_id,pk"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Hash string `json:"hash" db:"hash"`
Platform string `json:"platform" db:"platform"`
IconURL string `json:"icon_url" db:"icon_url"`
Job string `json:"job" db:"job"`
Volumes string `json:"volumes" db:"volumes"`
Groups []string `json:"groups" db:"groups,json"`
Active bool `json:"active" db:"active"`
WithTerminal bool `json:"with_terminal" db:"with_terminal"`
WithVSCodeTunnel bool `json:"with_vscode_tunnel" db:"with_vscode_tunnel"`
WithCodeServer bool `json:"with_code_server" db:"with_code_server"`
WithSSH bool `json:"with_ssh" db:"with_ssh"`
WithRunCommand bool `json:"with_run_command" db:"with_run_command"`
AllowNodeMigration bool `json:"allow_node_migration" db:"allow_node_migration"`
StartupScriptId string `json:"startup_script_id" db:"startup_script_id"`
ShutdownScriptId string `json:"shutdown_script_id" db:"shutdown_script_id"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units"`
ScheduleEnabled bool `json:"schedule_enabled" db:"schedule_enabled"`
AutoStart bool `json:"auto_start" db:"auto_start"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
Schedule []TemplateScheduleDays `json:"schedule" db:"schedule,json"`
Zones []string `json:"zones" db:"zones,json"`
CustomFields []TemplateCustomField `json:"custom_fields" db:"custom_fields,json"`
MaxUptime uint32 `json:"max_uptime" db:"max_uptime"`
MaxUptimeUnit string `json:"max_uptime_unit" db:"max_uptime_unit"`
HealthCheckType string `json:"health_check_type" db:"health_check_type"`
HealthCheckConfig string `json:"health_check_config" db:"health_check_config"`
HealthCheckSkipSSLVerify bool `json:"health_check_skip_ssl_verify" db:"health_check_skip_ssl_verify"`
HealthCheckTimeout uint32 `json:"health_check_timeout" db:"health_check_timeout"`
HealthCheckInterval uint32 `json:"health_check_interval" db:"health_check_interval"`
HealthCheckMaxFailures uint32 `json:"health_check_max_failures" db:"health_check_max_failures"`
HealthCheckAutoRestart bool `json:"health_check_auto_restart" db:"health_check_auto_restart"`
DisableUserActivity bool `json:"disable_user_activity" db:"disable_user_activity"`
Ports []TemplatePort `json:"ports" db:"ports,json"`
Jobs []SpaceJob `json:"jobs" db:"jobs,json"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
Template object
func NewTemplate ¶
func NewTemplate( name string, description string, job string, volumes string, userId string, groups []string, platform string, withTerminal bool, withVSCodeTunnel bool, withCodeServer bool, withSSH bool, withRunCommand bool, allowNodeMigration bool, startupScriptId string, shutdownScriptId string, computeUnits uint32, storageUnits uint32, scheduleEnabled bool, schedule *[]TemplateScheduleDays, zones []string, autoStart bool, active bool, maxUptime uint32, maxUptimeUnit string, iconURL string, customFields []TemplateCustomField, ) *Template
func (*Template) AllowedBySchedule ¶
func (*Template) GetVolumes ¶
func (*Template) IsLocalContainer ¶
func (*Template) IsValidForZone ¶ added in v0.19.0
IsValidForZone determines whether the template is valid for deployment in the specified zone. The function evaluates zone restrictions based on the template's Zones configuration. If no zones are specified, the template is considered valid for all zones. Zone names prefixed with '!' are treated as exclusions (negated zones). The function first checks for exclusions, then checks for explicit inclusions.
zone is the target zone name to validate against the template's zone restrictions.
Returns true if the template can be deployed in the specified zone, false otherwise.
func (*Template) UpdateHash ¶
func (template *Template) UpdateHash()
type TemplateCustomField ¶
type TemplatePort ¶ added in v0.25.0
type TemplateScheduleDays ¶
type TemplateVar ¶
type TemplateVar struct {
Id string `json:"templatevar_id" db:"templatevar_id,pk"`
Name string `json:"name" db:"name"`
Zones []string `json:"zones" db:"zones,json"`
Value string `json:"value" db:"value"`
Protected bool `json:"protected" db:"protected"`
Local bool `json:"local" db:"local"`
Restricted bool `json:"restricted" db:"restricted"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
IsManaged bool `json:"is_managed" db:"is_managed"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
Template Variable object
func NewTemplateVar ¶
func (*TemplateVar) DecryptSetValue ¶
func (templateVar *TemplateVar) DecryptSetValue(text string)
func (*TemplateVar) GetValueEncrypted ¶
func (templateVar *TemplateVar) GetValueEncrypted() string
type Token ¶
type Token struct {
Id string `json:"token_id" db:"token_id,pk"`
UserId string `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
ExpiresAfter time.Time `json:"expires_after" db:"expires_after"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
// Scopes restricts which endpoint groups this token can reach.
// nil/empty = unrestricted (backward compatible with pre-scopes tokens).
// Non-empty = token may only reach endpoints covered by the listed scopes.
Scopes []string `json:"scopes,omitempty" db:"scopes,json"`
// RefreshToken marks tokens issued via the OAuth2 authorization-code
// flow; only these may be extended through the /token refresh grant.
RefreshToken bool `json:"refresh_token,omitempty" db:"refresh_token"`
}
Session object
type User ¶
type User struct {
Id string `json:"user_id" db:"user_id,pk" msgpack:"user_id"`
Username string `json:"username" db:"username" msgpack:"username"`
Email string `json:"email" db:"email" msgpack:"email"`
Password string `json:"password" db:"password" msgpack:"password"`
TOTPSecret string `json:"totp_secret" db:"totp_secret" msgpack:"totp_secret"`
ServicePassword string `json:"service_password" db:"service_password" msgpack:"service_password"`
SSHPublicKey string `json:"ssh_public_key" db:"ssh_public_key" msgpack:"ssh_public_key"`
SSHPrivateKey string `json:"ssh_private_key" db:"ssh_private_key" msgpack:"ssh_private_key"`
GitHubUsername string `json:"github_username" db:"github_username" msgpack:"github_username"`
ExternalAuthProviders map[string]ExternalProvider `json:"external_auth_providers" db:"external_auth_providers,json" msgpack:"external_auth_providers"`
Roles []string `json:"roles" db:"roles,json" msgpack:"roles"`
Groups []string `json:"groups" db:"groups,json" msgpack:"groups"`
Active bool `json:"active" db:"active" msgpack:"active"`
IsDeleted bool `json:"is_deleted" db:"is_deleted" msgpack:"is_deleted"`
MaxSpaces uint32 `json:"max_spaces" db:"max_spaces" msgpack:"max_spaces"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units" msgpack:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units" msgpack:"storage_units"`
MaxTunnels uint32 `json:"max_tunnels" db:"max_tunnels" msgpack:"max_tunnels"`
PreferredShell string `json:"preferred_shell" db:"preferred_shell" msgpack:"preferred_shell"`
Timezone string `json:"timezone" db:"timezone" msgpack:"timezone"`
Preferences map[string]any `json:"preferences" db:"preferences,json" msgpack:"preferences"`
LastLoginAt *time.Time `json:"last_login_at" db:"last_login_at" msgpack:"last_login_at"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at" msgpack:"updated_at"`
CreatedAt time.Time `json:"created_at" db:"created_at" msgpack:"created_at"`
}
User object
func (*User) CheckPassword ¶
Check the password for the user
func (*User) ClearOAuthTokens ¶ added in v0.24.0
func (*User) GetNavStarred ¶ added in v0.32.0
GetNavStarred returns the user's pinned (starred) navigation URLs in their chosen display order, or nil if none are set. JSON round-trips decode the stored array as []any, so coerce back to []string here.
func (*User) GetOAuthRefreshToken ¶ added in v0.24.0
GetOAuthRefreshToken returns the decrypted OAuth refresh token for the given provider, or empty string.
func (*User) GetOAuthToken ¶ added in v0.23.7
GetOAuthToken returns the decrypted OAuth access token for the given provider, or empty string.
func (*User) GetSSHPrivateKeyDecrypted ¶ added in v0.25.0
func (*User) HasAnyGroup ¶
func (*User) HasPermission ¶
func (*User) SetNavStarred ¶ added in v0.32.0
SetNavStarred stores the given navigation URLs as the user's pinned set in the supplied order. An empty slice clears the preference (opts out of the starred layout and returns the menu to its default arrangement).
func (*User) SetOAuthTokens ¶ added in v0.24.0
SetOAuthTokens stores encrypted OAuth tokens for the given provider. Refresh tokens are preserved when the provider omits them on a later login.
func (*User) SetPassword ¶
Set the password for the user
func (*User) SetSSHPrivateKeyEncrypted ¶ added in v0.25.0
ClearOAuthTokens removes the stored tokens for the given provider.
type Volume ¶
type Volume struct {
Id string `json:"volume_id" db:"volume_id,pk"`
Name string `json:"name" db:"name"`
Zone string `json:"zone" db:"zone"`
NodeId string `json:"node_id" db:"node_id"`
Platform string `json:"platform" db:"platform"`
Definition string `json:"definition" db:"definition"`
Active bool `json:"active" db:"active"`
IsDeleted bool `json:"is_deleted" db:"is_deleted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt hlc.Timestamp `json:"updated_at" db:"updated_at"`
}
Template object
type VolumeDataMap ¶
type VolumeDataMap map[string]SpaceVolume
VolumeDataMap is a custom type that implements the sql.Scanner and driver.Valuer interfaces
func (*VolumeDataMap) Scan ¶
func (v *VolumeDataMap) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type WebhookConfig ¶ added in v0.28.0
type WebhookConfig struct {
URL string `json:"url" msgpack:"url"`
Secret string `json:"secret" msgpack:"secret"`
Headers map[string]string `json:"headers,omitempty" msgpack:"headers,omitempty"`
BodyTemplate string `json:"body_template" msgpack:"body_template"`
SkipTLSVerify bool `json:"skip_tls_verify" msgpack:"skip_tls_verify"`
}