flib

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 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

This section is empty.

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) 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