scriptling

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventParamsVarName = "__event_params"
	EventMetaVarName   = "__event"
)

Variables

View Source
var EmbeddedLibs embed.FS

Functions

func GetAILibrary

func GetAILibrary(aiClient ai.Client) *object.Library

GetAILibrary returns the knot.ai library for scriptling environments. Only Client() and get_default_model() are exposed, matching the Python standalone interface. When aiClient is nil, Client() will return an error.

func GetApiClientLibrary added in v0.23.6

func GetApiClientLibrary(client rest.RESTClient, userId string) *object.Library

GetApiClientLibrary returns the knot.apiclient Go transport library. In embedded contexts this replaces the Python apiclient.py transport stub. configure() and is_configured() are no-ops - the client is pre-configured. Tokens are never exposed to scripts.

func GetEventLibrary added in v0.28.0

func GetEventLibrary() *object.Library

func GetHealthCheckLibrary added in v0.24.0

func GetHealthCheckLibrary() *object.Library

GetHealthCheckLibrary returns the knot.healthcheck built-in library.

func GetIntAsUint16

func GetIntAsUint16(args []object.Object, index int, name string) (uint16, object.Object)

GetIntAsUint16 safely extracts an integer argument at the given index and converts to uint16. Returns the uint16 value and nil error on success, or 0 and error object on failure.

func GetMCPToolsLibrary

func GetMCPToolsLibrary(client *apiclient.ApiClient, mcpParams map[string]object.Object) *object.Library

GetMCPToolsLibrary returns the MCP tools library for scriptling (used in local/remote environments) This provides only tool access functions that communicate with the server via API calls

func GetMethodsLibrary added in v0.28.0

func GetMethodsLibrary() *object.Library

GetMethodsLibrary returns the knot.methods library, which exposes the Server class. The schema submodule is attached as a Dict constant so that `from knot.methods import schema` and `knot.methods.schema` both resolve to the same set of builder functions (mirroring the pattern scriptling's own runtime library uses for submodules like runtime.kv).

func GetMethodsSchemaLibrary added in v0.28.0

func GetMethodsSchemaLibrary() *object.Library

GetMethodsSchemaLibrary builds the knot.methods.schema library. Each function returns a JSON Schema fragment as a scriptling dict. Common constraints (description, default, enum) are accepted as keyword arguments alongside type-specific constraints (min_length, minimum, ...). Unknown kwargs are rejected. The extra={} kwarg is an escape hatch for less-common JSON Schema keywords; explicit kwargs win over keys in extra on conflict.

func RegisterMethodLibraries added in v0.28.0

func RegisterMethodLibraries(env *scriptling.Scriptling)

RegisterMethodLibraries registers knot.methods and knot.methods.schema on a scriptling env. This is opt-in: daemon-side script execution contexts (startup scripts via CmdExecuteScript, `knot methods register file.py`) call this so scripts running in the agent can register methods. CLI-side contexts (e.g. `knot run-script`) do not call it — those scripts cannot even import knot.methods, which makes the agent/CLI boundary explicit. Registering the libraries is independent of methodsRegistrar: the libraries give scripts a way to call Server(...).register(), and methodsRegistrar (installed once at daemon startup) is what register() actually invokes.

func SetMethodsRegistrar added in v0.28.0

func SetMethodsRegistrar(registrar func(*methods.Registration) error)

SetMethodsRegistrar installs the agent-side registrar. Called by the agent (or by knot run-script) before evaluating user scripts that use knot.methods.

func SetMethodsUnregisterAll added in v0.28.0

func SetMethodsUnregisterAll(fn func() error)

Types

type HealthCheckResult added in v0.24.0

type HealthCheckResult struct {
	Healthy bool `json:"healthy"`
}

HealthCheckResult holds the result of a health check execution.

func ParseHealthCheckResult added in v0.24.0

func ParseHealthCheckResult(msg string) (*HealthCheckResult, bool)

ParseHealthCheckResult extracts a HealthCheckResult from a script exception message.

type MCPLibrary

type MCPLibrary struct {
	// contains filtered or unexported fields
}

MCPLibrary is the exported type for accessing the result

func GetMCPLibraryInstance

func GetMCPLibraryInstance(client *apiclient.ApiClient, mcpParams map[string]object.Object) *MCPLibrary

GetMCPLibraryInstance creates a new MCP library instance that can be used to retrieve results

func (*MCPLibrary) GetLibrary

func (m *MCPLibrary) GetLibrary() *object.Library

GetLibrary returns the scriptling library

func (*MCPLibrary) GetResult

func (m *MCPLibrary) GetResult() *string

GetResult returns the stored result from mcp.return_* functions

Directories

Path Synopsis
Package pluginfetch implements the knot plugin's fetcher: the source of truth for knot:// scheme sources served to the scriptling CLI.
Package pluginfetch implements the knot plugin's fetcher: the source of truth for knot:// scheme sources served to the scriptling CLI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL