flib

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package flib provides an embeddable Frictionless runtime. Downstream binaries (e.g. ark) import this to get the full Frictionless stack — ui-engine, MCP tools, Lua globals, HTTP API — without needing to access internal packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectAllThemeBlocks added in v0.29.0

func InjectAllThemeBlocks(baseDir string) error

InjectAllThemeBlocks patches all HTML files in html/ that contain frictionless markers with the current theme block (script + CSS links with cache-busting). Called at startup and when themes change.

func ThemeBlock added in v0.29.0

func ThemeBlock(baseDir string) (string, error)

ThemeBlock returns the frictionless theme HTML block (script + CSS links) for the given base directory. Suitable for injecting into HTML templates between <!-- #frictionless --> markers.

Types

type Config

type Config struct {
	Dir     string // base directory for UI assets and state
	Host    string // bind host (default "127.0.0.1")
	Project string // project directory for skill installation (optional; derived from Dir if empty)
	Port    int    // preferred HTTP port (0 = auto-select)
}

Config holds configuration for an embedded Frictionless runtime.

type Runtime

type Runtime struct {
	Cfg *cli.Config
	// contains filtered or unexported fields
}

Runtime is an embedded Frictionless server. Create with New, then call Configure, Start, and StartAPI in sequence.

func New

func New(cfg Config) (*Runtime, error)

New creates a Frictionless runtime configured for embedding. Call Configure, Start, and StartAPI to bring it up.

func (*Runtime) Configure

func (r *Runtime) Configure() error

Configure prepares the server environment — creates directories, runs auto-install if needed. Call before Start.

func (*Runtime) RegisterAPI

func (r *Runtime) RegisterAPI(mux *http.ServeMux)

RegisterAPI registers Frictionless API handlers (/api/*, /wait, /state, /variables) on an external mux. Use this instead of StartAPI when the embedding binary has its own listener.

func (*Runtime) RunLua

func (r *Runtime) RunLua(code string) (string, error)

RunLua executes Lua code in the current session. Returns the result as a string (or empty on nil result).

func (*Runtime) Shutdown

func (r *Runtime) Shutdown(ctx context.Context) error

Shutdown gracefully stops both the UI and API servers.

func (*Runtime) Start

func (r *Runtime) Start() (string, error)

Start starts the UI HTTP server and creates a Lua session with the mcp global. Returns the base URL (e.g. "http://127.0.0.1:PORT").

func (*Runtime) StartAPI

func (r *Runtime) StartAPI() (int, error)

StartAPI starts a standalone HTTP API server that serves /api/*, /wait, /state, /variables endpoints. Returns the port number. Use RegisterAPI instead when embedding into an existing server.

func (*Runtime) UIHandleFunc added in v0.29.0

func (r *Runtime) UIHandleFunc(pattern string, handler http.HandlerFunc)

UIHandleFunc registers a custom HTTP handler on the UI server's mux. CRC: crc-FlibRuntime.md

func (*Runtime) WithLua

func (r *Runtime) WithLua(fn func(rt *cli.LuaRuntime) error) error

WithLua executes a closure in the Lua executor goroutine (thread-safe) without triggering afterBatch (no UI update push). This is the passive execution path — use it to register Go functions on the Lua mcp table or perform other Lua-side setup after Start returns. CRC: crc-FlibRuntime.md

Jump to

Keyboard shortcuts

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