Documentation
¶
Index ¶
- func CanUserAccessSkill(user *model.User, skill *model.Skill) bool
- func CanUserExecuteScript(user *model.User, script *model.Script) bool
- func ExecuteScriptWithMCP(script *model.Script, mcpParams map[string]object.Object, user *model.User) (string, error)
- func ExitOnSystemExit(result object.Object)
- func ForwardToNode(w http.ResponseWriter, r *http.Request, nodeId string) error
- func HandleScriptResult(result object.Object, err error, capturedOutput string) (int, string, error)
- func NewHealthCheckScriptlingEnv() (*scriptling.Scriptling, error)
- func NewMCPScriptlingEnv(client *apiclient.ApiClient, mcpParams map[string]object.Object, ...) (*scriptling.Scriptling, *knotscriptling.MCPLibrary, error)
- func NewRemoteScriptlingEnv(argv []string, client *apiclient.ApiClient, userId string, ...) (*scriptling.Scriptling, error)
- func NewRemoteStreamingScriptlingEnv(argv []string, client *apiclient.ApiClient, userId string, ...) (*scriptling.Scriptling, error)
- func ResolveScriptByName(name string, userId string) (*model.Script, error)
- func ResolveSkillByName(name string, userId string) (*model.Skill, error)
- func SelectNodeForSpace(template *model.Template, selectedNodeId string) (string, error)
- func SetContainerService(service Container)
- func SetTransport(t Transport)
- func SetUserService(service UserService)
- func ShouldForwardToNode(nodeId string) (bool, string)
- type Container
- type Icon
- type IconList
- type IconService
- type ScriptListOptions
- type ScriptService
- type SkillListOptions
- type SkillService
- type SpaceListOptions
- type SpaceService
- func (s *SpaceService) CheckUserQuotas(user *model.User, template *model.Template) error
- func (s *SpaceService) CreateSpace(space *model.Space, user *model.User) error
- func (s *SpaceService) DeleteSpace(spaceId string, user *model.User) error
- func (s *SpaceService) GetSpace(spaceId string, user *model.User) (*model.Space, error)
- func (s *SpaceService) GetSpaceCustomField(spaceId string, fieldName string, user *model.User) (string, error)
- func (s *SpaceService) ListSpaces(opts SpaceListOptions) ([]*model.Space, error)
- func (s *SpaceService) RemoveDependencyReferences(spaceId string, ownerUserId string) error
- func (s *SpaceService) SetSpaceCustomField(spaceId string, fieldName string, fieldValue string, user *model.User) error
- func (s *SpaceService) UpdateSpace(space *model.Space, user *model.User) error
- func (s *SpaceService) ValidateDependencies(space *model.Space) error
- func (s *SpaceService) ValidateDependenciesRunning(space *model.Space) error
- type TemplateListOptions
- type TemplateService
- func (s *TemplateService) CreateTemplate(template *model.Template, user *model.User) error
- func (s *TemplateService) DeleteTemplate(templateId string, user *model.User) error
- func (s *TemplateService) GetTemplate(templateId string) (*model.Template, error)
- func (s *TemplateService) GetTemplateUsage(templateId string) (total int, deployed int, err error)
- func (s *TemplateService) ListTemplates(opts TemplateListOptions) ([]*model.Template, error)
- func (s *TemplateService) UpdateTemplate(template *model.Template, user *model.User) error
- type Transport
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanUserAccessSkill ¶ added in v0.23.0
func CanUserExecuteScript ¶ added in v0.23.0
CanUserExecuteScript checks if a user has permission to execute a script
func ExecuteScriptWithMCP ¶ added in v0.23.0
func ExitOnSystemExit ¶ added in v0.23.0
ExitOnSystemExit checks for SystemExit and exits the process if found
func ForwardToNode ¶ added in v0.23.0
ForwardToNode forwards an HTTP request to another node in the cluster
func HandleScriptResult ¶ added in v0.23.0
func HandleScriptResult(result object.Object, err error, capturedOutput string) (int, string, error)
HandleScriptResult processes scriptling evaluation results with consistent exception handling. Returns (exitCode, output, error) where: - exitCode: 0 for success, non-zero for SystemExit - output: captured output or result inspection - error: non-nil for errors (excluding successful SystemExit with code 0)
func NewHealthCheckScriptlingEnv ¶ added in v0.24.0
func NewHealthCheckScriptlingEnv() (*scriptling.Scriptling, error)
NewHealthCheckScriptlingEnv creates a minimal scriptling environment for health check scripts. Registers the knot.healthcheck built-in library only — no system access, no API client.
func NewMCPScriptlingEnv ¶ added in v0.23.0
func NewMCPScriptlingEnv(client *apiclient.ApiClient, mcpParams map[string]object.Object, user *model.User) (*scriptling.Scriptling, *knotscriptling.MCPLibrary, error)
NewMCPScriptlingEnv creates a scriptling environment for MCP tool execution Libraries: stdlib, requests, secrets, htmlparser, knot.space, knot.ai, knot.mcp, knot.user, knot.group, knot.role, knot.template, knot.vars, knot.volume, knot.permission On-demand loading: Enabled - fetches from server only Output: Captured and returned The AI client connects to the server's OpenAI-compatible endpoint via createServerAIClient. The MCPServerContext middleware handles per-user tool discovery and execution when requests flow through the endpoint. Returns the environment and the MCP library instance for result retrieval
func NewRemoteScriptlingEnv ¶ added in v0.23.0
func NewRemoteScriptlingEnv(argv []string, client *apiclient.ApiClient, userId string, customLogger logger.Logger, isSystemCall bool) (*scriptling.Scriptling, error)
NewRemoteScriptlingEnv creates a scriptling environment for remote execution in spaces Libraries: stdlib, requests, secrets, subprocess, htmlparser, threads, os, pathlib, sys, scriptling.grep, scriptling.sed, knot.space, knot.ai, knot.mcp On-demand loading: Enabled - fetches from server only customLogger is optional - pass nil to use the default logger Output: Captured and returned for user scripts, discarded for system scripts (startup/shutdown)
func NewRemoteStreamingScriptlingEnv ¶ added in v0.23.0
func NewRemoteStreamingScriptlingEnv(argv []string, client *apiclient.ApiClient, userId string, customLogger logger.Logger, output io.Writer, input io.Reader) (*scriptling.Scriptling, error)
NewRemoteStreamingScriptlingEnv creates a scriptling environment for streaming remote execution Libraries: stdlib, requests, secrets, subprocess, htmlparser, threads, os, pathlib, sys, scriptling.grep, scriptling.sed, knot.space, knot.ai, knot.mcp Note: scriptling.console and scriptling.ai.agent.interact are registered after env creation in execute_script_stream.go On-demand loading: Enabled - fetches from server only customLogger is optional - pass nil to use the default logger Output: Connected to provided writer, input from provided reader
func ResolveScriptByName ¶ added in v0.23.0
ResolveScriptByName resolves a script by name with user override support First checks user scripts, then falls back to global scripts Returns nil if script not found, deleted, inactive, or not valid for current zone Supports zone-specific overrides - returns the best match for the current zone
func ResolveSkillByName ¶ added in v0.23.0
func SelectNodeForSpace ¶ added in v0.22.0
SelectNodeForSpace selects the best node for a space based on template requirements Returns node ID or empty string for auto-selection, or error if no suitable node found
func SetContainerService ¶
func SetContainerService(service Container)
func SetTransport ¶
func SetTransport(t Transport)
func SetUserService ¶
func SetUserService(service UserService)
func ShouldForwardToNode ¶ added in v0.23.0
ShouldForwardToNode checks if a request should be forwarded to another node
Types ¶
type Container ¶
type Container interface {
// Volumes
CreateVolume(volume *model.Volume) error
DeleteVolume(volume *model.Volume) error
// Spaces
StartSpace(space *model.Space, template *model.Template, user *model.User) error
StopSpace(space *model.Space) error
RestartSpace(space *model.Space) error
DeleteSpace(space *model.Space)
// Helpers
CleanupOnBoot()
}
func GetContainerService ¶
func GetContainerService() Container
type Icon ¶ added in v0.19.0
type Icon struct {
Description string `toml:"description" json:"description"`
Source string `toml:"-" json:"source"`
URL string `toml:"url" json:"url"`
}
Icon represents a single icon entry
type IconService ¶ added in v0.19.0
type IconService struct {
// contains filtered or unexported fields
}
func GetIconService ¶ added in v0.19.0
func GetIconService() *IconService
GetIconService returns the singleton icon service instance
func (*IconService) GetIcons ¶ added in v0.19.0
func (s *IconService) GetIcons() []Icon
GetIcons returns all available icons (built-in and user-supplied)
func (*IconService) ReloadIcons ¶ added in v0.19.0
func (s *IconService) ReloadIcons()
ReloadIcons reloads icons from configuration
type ScriptListOptions ¶ added in v0.23.0
type ScriptService ¶ added in v0.23.0
type ScriptService struct{}
func GetScriptService ¶ added in v0.23.0
func GetScriptService() *ScriptService
func (*ScriptService) ListScripts ¶ added in v0.23.0
func (s *ScriptService) ListScripts(opts ScriptListOptions) ([]*model.Script, error)
ListScripts returns a filtered list of scripts based on the provided options
type SkillListOptions ¶ added in v0.23.0
type SkillService ¶ added in v0.23.0
type SkillService struct{}
func GetSkillService ¶ added in v0.23.0
func GetSkillService() *SkillService
func (*SkillService) ListSkills ¶ added in v0.23.0
func (s *SkillService) ListSkills(opts SkillListOptions) ([]*model.Skill, error)
type SpaceListOptions ¶ added in v0.19.0
type SpaceService ¶ added in v0.19.0
type SpaceService struct{}
func GetSpaceService ¶ added in v0.19.0
func GetSpaceService() *SpaceService
func (*SpaceService) CheckUserQuotas ¶ added in v0.19.0
checkUserQuotas validates user quotas for space creation
func (*SpaceService) CreateSpace ¶ added in v0.19.0
CreateSpace creates a new space with validation and quota checks
func (*SpaceService) DeleteSpace ¶ added in v0.19.0
func (s *SpaceService) DeleteSpace(spaceId string, user *model.User) error
DeleteSpace marks a space as deleted with validation
func (*SpaceService) GetSpace ¶ added in v0.19.0
GetSpace retrieves a single space by ID with permission checks
func (*SpaceService) GetSpaceCustomField ¶ added in v0.21.5
func (s *SpaceService) GetSpaceCustomField(spaceId string, fieldName string, user *model.User) (string, error)
GetSpaceCustomField retrieves a single custom field value from a space
func (*SpaceService) ListSpaces ¶ added in v0.19.0
func (s *SpaceService) ListSpaces(opts SpaceListOptions) ([]*model.Space, error)
ListSpaces returns a filtered list of spaces based on the provided options
func (*SpaceService) RemoveDependencyReferences ¶ added in v0.24.0
func (s *SpaceService) RemoveDependencyReferences(spaceId string, ownerUserId string) error
func (*SpaceService) SetSpaceCustomField ¶ added in v0.21.5
func (s *SpaceService) SetSpaceCustomField(spaceId string, fieldName string, fieldValue string, user *model.User) error
SetSpaceCustomField sets or updates a single custom field on a space
func (*SpaceService) UpdateSpace ¶ added in v0.19.0
UpdateSpace updates an existing space with validation
func (*SpaceService) ValidateDependencies ¶ added in v0.24.0
func (s *SpaceService) ValidateDependencies(space *model.Space) error
func (*SpaceService) ValidateDependenciesRunning ¶ added in v0.24.0
func (s *SpaceService) ValidateDependenciesRunning(space *model.Space) error
type TemplateListOptions ¶ added in v0.19.0
type TemplateService ¶ added in v0.19.0
type TemplateService struct{}
func GetTemplateService ¶ added in v0.19.0
func GetTemplateService() *TemplateService
func (*TemplateService) CreateTemplate ¶ added in v0.19.0
CreateTemplate creates a new template with validation
func (*TemplateService) DeleteTemplate ¶ added in v0.19.0
func (s *TemplateService) DeleteTemplate(templateId string, user *model.User) error
DeleteTemplate marks a template as deleted with validation
func (*TemplateService) GetTemplate ¶ added in v0.19.0
func (s *TemplateService) GetTemplate(templateId string) (*model.Template, error)
GetTemplate retrieves a single template by ID
func (*TemplateService) GetTemplateUsage ¶ added in v0.19.0
func (s *TemplateService) GetTemplateUsage(templateId string) (total int, deployed int, err error)
GetTemplateUsage returns usage statistics for a template
func (*TemplateService) ListTemplates ¶ added in v0.19.0
func (s *TemplateService) ListTemplates(opts TemplateListOptions) ([]*model.Template, error)
ListTemplates returns a filtered list of templates based on the provided options
func (*TemplateService) UpdateTemplate ¶ added in v0.19.0
UpdateTemplate updates an existing template with validation
type Transport ¶
type Transport interface {
GossipGroup(group *model.Group)
GossipRole(role *model.Role)
GossipSpace(space *model.Space)
GossipTemplate(template *model.Template)
GossipTemplateVar(templateVar *model.TemplateVar)
GossipUser(user *model.User)
GossipToken(token *model.Token)
GossipVolume(volume *model.Volume)
GossipSpaceUsageSample(sample *model.SpaceUsageSample)
GossipAuditLog(entry *model.AuditLogEntry)
GossipSession(session *model.Session)
GossipScript(script *model.Script)
GossipSkill(skill *model.Skill)
GossipStackDefinition(stackDef *model.StackDefinition)
GossipResponse(response *model.Response)
GetAgentEndpoints() []string
GetTunnelServers() []string
LockResource(resourceId string) string
UnlockResource(resourceId, unlockToken string)
Nodes() []*gossip.Node
GetNodeByIDString(id string) *gossip.Node
EnqueueSpaceCleanup(space *model.Space)
}
func GetTransport ¶
func GetTransport() Transport
type UserService ¶
type UserService interface {
// User deletion operations
DeleteUser(user *model.User) error
RemoveUsersSessions(user *model.User)
RemoveUsersTokens(user *model.User)
// SSH key and space management
UpdateUserSpaces(user *model.User)
UpdateSpacesSSHKey(user *model.User)
UpdateSpaceSSHKeys(space *model.Space, user *model.User)
}
UserService defines operations that can be performed on users
func GetUserService ¶
func GetUserService() UserService