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 ¶
- func InjectAllThemeBlocks(baseDir string) error
- func ThemeBlock(baseDir string) (string, error)
- type Config
- type Runtime
- func (r *Runtime) Configure() error
- func (r *Runtime) RegisterAPI(mux *http.ServeMux)
- func (r *Runtime) RunLua(code string) (string, error)
- func (r *Runtime) Shutdown(ctx context.Context) error
- func (r *Runtime) Start() (string, error)
- func (r *Runtime) StartAPI() (int, error)
- func (r *Runtime) UIHandleFunc(pattern string, handler http.HandlerFunc)
- func (r *Runtime) WithLua(fn func(rt *cli.LuaRuntime) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectAllThemeBlocks ¶ added in v0.29.0
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
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 ¶
Runtime is an embedded Frictionless server. Create with New, then call Configure, Start, and StartAPI in sequence.
func New ¶
New creates a Frictionless runtime configured for embedding. Call Configure, Start, and StartAPI to bring it up.
func (*Runtime) Configure ¶
Configure prepares the server environment — creates directories, runs auto-install if needed. Call before Start.
func (*Runtime) RegisterAPI ¶
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 ¶
RunLua executes Lua code in the current session. Returns the result as a string (or empty on nil result).
func (*Runtime) Start ¶
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 ¶
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