Lokyr
Documentation

Plugin system

On this page

Everything you see in Lokyr is a plugin: the tab bar, splits, the find bar, the palette; the themes are the host's. The kernel provides data and services, and plugins decide how things behave and look.

Two tiers, one API

First-party pluginsThird-party plugins
FormRust crate in plugins/, statically linkedLuau scripts, each plugin in its own sandboxed VM
LoadingAt startup, from the distribution (dist/*.toml)From disk (installed by Sleip), only when needed
TrustOur own reviewed codeSandboxed: only the capabilities granted to it
CostDirect calls, zero overheadOne Luau VM (about 1–2 MB when active); calls copy data
APIplugin-sdk, the Rust front endThe Luau front end of the same API
Failurescatch_unwind at the boundary; the plugin is disabledLua error, memory limit or missed deadline; the plugin is disabled and restarted with backoff

Extension points

AreaWhat a plugin can doExamplesPhase
CommandsRegister and run commands with typed arguments; add menu and palette entriestabs.new, search.openF3
KeymapBindings with a context (when), chords and leaders, modal key tablescmd+f → search.open when a pane has focusF3
EventsReceive kernel events (batched) and emit its owntab-created, layout-changed, pointer, search.progressF3
Workspace and layoutCreate, close and move tabs and panes; edit the layout treesplit, zoom, move to a new windowF3
UIProvide view trees for slotstab bar, find bar, status bar segmentsF3
TerminalRead lines and the selection; read the commands that the shell marked and hear their starts and ends (with a capability); follow a pane's view; write input (with a capability); use the search and decoration serviceshighlight matches, gutter marks, a command's headerF3
ConfigA [plugins.<namespace>] section of the config file, checked against the plugin's JSON Schema, of the keywords that the host checks and of annotations of x-, as x-guide, which no value is checked against, each key once in its object, as a schema of a key twice does not read, a wrong value refusing that section alone, and what another version would know ignored with a notice, the notice at the value's line as the file's lines move; enum and const comparing numbers by their values, and a whole number of a fraction, as 5.0, of a schema of integers alone the integer; read as a request, a change told as config-changed[plugins.tabs] position = "top"F3
StorageA file of the plugin's state, of plain values as JSON, 1 MiB at most, in the app's state directory, read as a request and written as the call returnssearch historyF3
SystemClipboard, notifications, opening URLs and files, global hotkeys and quick windows in F3; processes and the network, through the app to Sleip's helper, after 1.0.0, in F6 (with capabilities)notify when a command finishesF3; processes and the network F6
ProtocolsHandlers for rare OSC/DCS/APC sequencesiTerm2's OSC 1337F5
TriggersRegexes over completed lines, with batched callbacks; the config's own triggers, of no plugin, come first, in 1.7 (Triggers)highlight ERROR in redLater

UI slots

SlotProvidersUsed forRegion
tab-barOne, chosen in the configThe tab barIn the titlebar past the window's buttons and the small buttons, of the titlebar's height, or below a titlebar of the window's title, of its view's height; at the window's top in full screen
title-buttonsMany, side by side, three at mostA button of an icon beside the window's, as a toggle of a state that a plugin keepsIn the titlebar right after the window's buttons, each plugin's view one button of an icon alone, one of the host's icons but the ellipsis, the host's own, of no label nor children, of a key, named by its tooltip or its label, of 256 characters at most and of no character that hides the text, which the host refuses otherwise; each a square of 24 points in a room of 28 across, of the titlebar's height, whatever its layout; of four or more, the first two, and the host's ellipsis, More, whose native menu lists the rest by their names, a choice the button's click, its panel below the ellipsis; the button's press the content's, the rest the window's, which a drag moves; a tab bar through the titlebar, a sidebar or a title, finds the buttons in its Length::Buttons, after the window's; a plugin's button goes as the plugin stops, faults or is turned off, and comes back as it starts again; in full screen at the left of a tab bar across the top, and nowhere without one
status-barMany, on three sidesStatus informationAcross the window's bottom, of its tallest view's height, which the panes give up, the host's band of status-bar.bg across it while a plugin's view fills it; each plugin's view at its natural width on its side, start, center or end, of its manifest's [contributes.status-bar] side, the start of none, or of set_status_bar_side: the start's views from the bar's start edge in the plugins' order, the end's from its end edge, the first nearest it, the center's together in the middle; of too little room, the center gives way first, then each side keeps half the bar, or what the other leaves, its last views cut · Since 1.4
window-stripManyA thin strip across the window's top, under the titlebar or the tab bar: the programs' progressAcross the panes' top, over them, taking none of their rows
pane-headerOnePane titles in splitsAcross its pane's top, of its view's height, above the grid; a split pane's alone, as a floating pane's header is Lokyr's own, of its title and its close button · Since 1.5
sidebarMany (F5+)Side panels

The settings' pages are no slots: Lokyr's settings open in a window of their own, one at most, titled Settings, a little larger than System Settings, which holds no terminal and takes no other tab, closed by ⌘W, the tabs' close, nor any plugin's view of the terminals' windows, no slot's and no panel but those of its pages' nodes and of their panels' nodes, as a dialog's menu, the plugins seeing no window in front while it is, nor its focus, and closing, moving or asking a question on neither it nor its tab, a question of no window going to the terminals' window that had the focus last; its pages as tabs across the top and the chosen page below them, a view of its plugin's, { page = "<id>" }, which draws a sidebar of its own parts at its left where it needs one. Lokyr's own plugins alone have pages, which their manifests declare in contributes.pages, each of an id and one of the host's icons, its title the catalogs' page-<id>; another's manifest is refused. Each page's view takes the room below the tabs whole, its first field the keyboard's as the window opens; its plugin hears page-shown and page-hidden, to it alone, as the page shows and hides, and shows one of its own pages with show_page, which opens the window there.

The overlays and the popups are no slots: a plugin's floating panels, which it opens and closes, anchored to a cell, the cursor, the pointer, a node of its views, or a corner of a pane or of the window's room below the tab bar, as the find bar, the hints, the command's sticky header, the palette and the menus are.

A slot of no view takes no room, and a slot of many shares its width equally among its plugins' views, in their order, but the titlebar's buttons', each a square of the host's size, three at most. ui-core's chrome gives the regions of a window's size, its titlebar's height and its buttons' room, the tab bar's place and the heights of the views, as the slots' trees take them laid out across the window; each slot's view is a surface of its own, drawn over the panes in the window's one drawable and taking the pointer before them.

The dividers between panes are no slot's: the host draws them from the layout tree, in the theme's pane.divider, and takes their drags itself, a drag giving its split a ratio and a double click half and half, which the plugins learn of by layout-changed.

Execution model

Native and Luau plugins follow the same rules, so they behave the same way.

One API, two front ends

The API is defined once, in Rust: a protocol of requests, responses and events, whose types live in plugin-sdk, and which the kernel serves. Each tier reaches it through its own front end.

Rust, for first-party plugins:

use lokyr_plugin_sdk::command::{Args, Category, Code, Command, Error};
use lokyr_plugin_sdk::host::Binding;
use lokyr_plugin_sdk::plugin::{Cx, Plugin};

#[derive(Default)]
struct Search { query: String }

impl Plugin for Search {
    fn activate(&mut self, cx: &mut Cx<'_>) -> Result<(), Error> {
        cx.register_command(Command {
            name: "search.open".to_owned(),
            title: "Find".to_owned(),
            category: Category::View,
            capabilities: Vec::new(),
            params: Vec::new(),
            when: None,
        })?;
        cx.bind(Binding {
            keys: "cmd+f".to_owned(),
            command: "search.open".to_owned(),
            args: Args::new(),
            when: Some("pane.focused".to_owned()),
        })
    }

    fn on_command(&mut self, cx: &mut Cx<'_>, name: &str, args: Args) -> Result<(), Error> {
        match name {
            "search.open" => { /* the find bar */ Ok(()) }
            _ => Err(Error::new(Code::NotFound, format!("no command `{name}`"))),
        }
    }
    // Later: on_event, for results and panes that close, and render, for the find bar.
}

export_plugin!(Search); // a registration function, which gen-dist wires into the app

Luau, for third-party plugins. The entry module returns a table of callbacks, and the host passes cx to each of them:

--!strict
-- src/init.luau
local Search = {}

function Search.activate(cx: Cx)
    cx.register_command({ name = "search-plus.open", title = "Advanced search", category = "view" })
    cx.bind({ keys = "cmd+shift+f", command = "search-plus.open", when = "pane.focused" })
end

function Search.on_command(cx: Cx, name: string, args: Args)
    if name == "search-plus.open" then
        cx.open_panel("find", { anchor = { pane_corner = { pane = cx.focused_pane(), corner = "top-right" } }, role = "dialog", close_escape = true })
    end
end

function Search.on_event(cx: Cx, events: { Event })
    -- results, pane closed, …
end

function Search.render(cx: Cx, view: ViewId): View?
    -- the find bar, of the panel "find"
end

return Search

The Luau API

The guide for plugin authors, Writing a plugin, makes a plugin from sleip new to its publishing; this section tells how the API is made.

Versioning

Illustrative draft

The Luau front end of the API as plugin-sdk 0.1 has it: each of Cx's requests by the Rust front end's name, of its arguments and its answer, and the Rust types' shapes as tables. The definitions file that cargo xtask luau-types makes of the Rust types, lokyr.d.luau, is the reference of their names and shapes; this draft tells what they mean. The calls are as the Luau API above has them, a write answering true, or nil, the error's message and its code: (boolean, Error?) below reads (true?, string?, number?). A view's nodes and the events take the flat shapes shown here, as { kind = "text", text = "…" } and { kind = "tab-created", … }.

-- lokyr.d.luau: the types of the plugin API, for the type checker.

type WindowId = number
type TabId = number
type PaneId = number
type GroupId = number
type SessionId = number

-- Command arguments: named values of a flat schema, each a string, an
-- integer, a number or a boolean.
type Args = { [string]: string | number | boolean }

-- Plugins should prefer theme tokens (e.g. "tabs.active.bg") to literals.
type Color = string | { r: number, g: number, b: number, a: number? }

-- How a split lays its two parts out, the first left or above; a part of
-- a split; an edge of a pane, which a resize moves.
type Direction = "horizontal" | "vertical"
type Side = "first" | "second"
type Edge = "left" | "right" | "top" | "bottom"

-- A failed call's error: its message, then its code, whose hundreds tell
-- its category: 1xx usage, 2xx failure, 3xx security, 4xx fault.
-- `(T?, Error?)` below reads `(T?, string?, number?)`.
type Error = string

type WindowInfo = {
    id: WindowId,
    tabs: { TabId }, -- in their order
    active: TabId, -- the tab that it shows
    number: number?, -- from 1, the lowest that no other open window had as it opened; none for the quick terminal's
    keys: string?, -- the keys that bring it forward, as the platform writes them, as "⌥⌘1", for its titlebar to show; nil while the config hides them
    bell: boolean, -- its bell rang while it had not the focus, until it takes it, as `[bell] mark-title` marks its title, for a title that a plugin draws, as a single tab's; its views of the tab bar render again as it changes
    title: string, -- its title as the system's titlebar shows it, of none of the app's marks: its name, its program and, as `[window] title-size` says, its grid's size, as "lokyr — zsh — 120×30", for a title that a plugin draws, as a single tab's; its view of the tab bar renders again as it changes while it shows the title; to a plugin without `process-read`, its shown tab's title, as a read of its tabs tells it, of no folder nor program
    quick: boolean, -- a quick window, which slides in over every app's windows
    hidden: boolean, -- hidden, as a quick window hides
}

-- Where a quick window shows: the edge that it slides in from, or the centre, where it fades; how far it reaches into
-- its screen's area for windows, and its length along the edge, nil for the screen's whole, each a percentage, above 0
-- and at most 100, or points, from 1 to 100000; its screen; its slide, in milliseconds, from 0 to 2000; and whether it
-- shows on every Space.
type QuickPlace = {
    edge: "top" | "bottom" | "left" | "right" | "center",
    primary: { percent: number } | { points: number },
    secondary: ({ percent: number } | { points: number })?,
    screen: ("main" | "pointer" | "menu-bar")?,
    animation: number,
    ["every-space"]: boolean,
}

type BarPlace =
    | { kind: "titlebar" }
    | { kind: "below-titlebar" }
    | { kind: "bottom" }
    | { kind: "left", width: number }
    | { kind: "right", width: number }
    | { kind: "sidebar", width: number } -- down the left from the window's top, through the titlebar, the window's buttons over its top, the panes beside it below the titlebar
    | { kind: "title" } -- across the whole titlebar, in place of the window's title, as a window of a single tab shows its title and its marks; none in full screen

type TabInfo = {
    id: TabId,
    window: WindowId,
    kind: "terminal" | "settings", -- the settings' tab, one at most, alone in a window of its own, holds no pane: its `panes` are none, its `focused` no pane's, its title and color the host's; no tab goes into its window
    title: string, -- its own, as `set_tab_title` gave it, or its active pane's program's, or, of `process-read`, its pane's folder and program, as "src — vim"
    color: Color?, -- its own, as `set_tab_color` gave it, or its active pane's program's, an RGB one
    active: boolean, -- whether its window shows it
    panes: { PaneId }, -- in its layout's order
    focused: PaneId, -- the pane that has its keyboard
    zoomed: PaneId?,
    activity: boolean, -- output came while it did not show, until its window shows it
    bell: boolean, -- its bell rang while it did not show, until its window shows it
    progress: { state: "normal" | "error" | "paused" | "indeterminate", value: number? }?, -- OSC 9;4's, of its active pane or another, the value from 0 to 1 if told
    printing: boolean, -- of `process-read`: the program of `running` prints of its own, output within the last 3 seconds apart from the echo of the input typed and the redraw of a new size, as a build, rather than ssh, a REPL or an agent waiting for input
    running: boolean, -- of `process-read`: a program other than a shell runs in the foreground of one of its panes, whichever has the keyboard
    alternate: boolean, -- of `process-read`: its active pane's program shows the alternate screen, as vim's or htop's
    secure: boolean, -- the keyboard's protected input is on for it, as its window has the focus and shows it
    agent: ("working" | "waiting" | "done" | "error")?, -- of `process-read`: the state of an AI agent that runs in one of its panes, the most urgent of theirs: working while it prints, tells a progress or turns its title's spinner; waiting once it asks for attention, by a notification or its bell, until something is typed into its pane; done once quiet after a request; of an agent whose hooks tell its state, as Claude Code's of Lokyr › Install Claude Code Integration…, as they tell it, and error as an error ends its answer
    agent_message: string?, -- of `process-read`: the message of the notification by which an agent of its panes that waits asked for attention, as "Claude needs your permission to use Bash", 200 characters at most; none of a bell alone
    status: { text: string?, indicator: Color?, color: Color?, detail: string? }?, -- of `process-read`: the status that a program of its panes tells of its session, of OSC 21337, its active pane's or another's: a short text, as "Working", 256 bytes at most, the color of its dot, its text's color and a line of what it does, 1024 bytes at most, each none until the program tells it
    pinned: boolean, -- pinned at its window's start, after the tabs pinned before it
    group: GroupId?, -- the group that it is in
}

-- A group of a window's tabs, as a read of its groups gives it: its tabs next to one another, of no pinned tab.
type GroupInfo = {
    id: GroupId,
    window: WindowId,
    name: string, -- empty for none, 256 characters at most
    color: Color?, -- an RGB one
    folded: boolean, -- its tabs hidden behind its name in the bar
    tabs: { TabId }, -- in their order, one at least
}

-- A session, a group of windows, as a read of the sessions gives it: the active session's windows show, the others'
-- are hidden, their programs running · Since 1.5.
type SessionInfo = {
    id: SessionId,
    name: string, -- empty for none, 256 characters at most
    active: boolean, -- whether its windows show
    windows: { WindowId }, -- in the order they opened; none of a session whose first window has yet to open
    folder: string?, -- of `process-read`: the absolute path of the folder that it was opened in, as the sessions' switcher opens one
}

-- The folders that the sessions' switcher lists, each an absolute path, of `process-read` · Since 1.5.
type SessionFolders = {
    configured: { string }, -- those of the config's `[sessions] folders`, in their order
    recent: { string }, -- those that the panes' shells told last, the latest first, there still
    home: string?, -- the home directory, which a switcher shows the folders under as of `~`
    layouts: { string }, -- the names of the layouts, each opening as a new session of `window.open-layout`
}

-- Where a window's typed input goes beside the pane that has its keyboard: the keys, the input method's text and
-- the pastes of ⌘V and of drops · Since 1.5.
type BroadcastTo = "off" | "tab" | "window"

-- A pane that floats over its tab's split panes: its frame's corner and size, each a share of the tab's room, from
-- 0 to 1 · Since 1.5.
type FloatingPane = {
    pane: PaneId,
    x: number,
    y: number,
    width: number,
    height: number,
}

-- A tab's floating panes, which show or hide together, from the one at the back to the one in front
-- · Since 1.5.
type FloatingPanes = {
    shown: boolean,
    panes: { FloatingPane }?,
}

-- A window's broadcast of the typed input · Since 1.5.
type Broadcast = {
    to: BroadcastTo,
    left_out: { PaneId }?, -- the window's panes left out, which take their own input alone, in the order of their ids
}

-- A tab's layout: a pane, or a split of two layouts, whose ratio is the
-- first part's share, from 0 to 1, or none to share it by their panes.
type Layout =
    { pane: PaneId }
    | { direction: Direction, ratio: number?, first: Layout, second: Layout }

-- Of its content, of points, of a fraction of its parent's, from 0 to 1, or the window's: the titlebar's height,
-- and the width that the window's buttons take at its left, which a sidebar leaves them; 0 without them, as in
-- full screen.
type Length = "auto" | number | { fraction: number } | "titlebar" | "buttons"

-- A node's place and size among its siblings, and its children's, of flexbox's properties.
type NodeLayout = {
    direction: ("row" | "column")?,
    gap: number?,
    padding: { top: number?, right: number?, bottom: number?, left: number? }?,
    align: ("start" | "center" | "end" | "stretch")?,
    justify: ("start" | "center" | "end" | "space-between")?,
    width: Length?,
    height: Length?,
    min_width: Length?, -- its least width, which it keeps as its siblings share less room, as a tab among many
    grow: number?,
    -- of a text node, the most lines that its text takes, broken between its words at its width, the last cut of an
    -- ellipsis where the text goes on; 0 for as many as it needs; none for one line, cut of an ellipsis where it is
    -- too long; a text of a key and of lines hears "cut" as its layout first cuts it, and each time that changes; a
    -- list's rows keep one line
    lines: number?,
}

type Style = {
    hides_indicator: boolean?, -- of a scroll area, no indicator of its scroll, as a bar of tabs
    holds_ring: boolean?, -- the ring of the keyboard's focus of a node inside it round its own box, as a search field's box round its text
    hides_ring: boolean?, -- no ring of the keyboard's focus round it, as a palette's field, whose caret alone tells it
    text_size: ("regular" | "small" | "large" | "mini" | "callout" | "title")?, -- its texts' size, its children's too, unless they give their own: small, eleven thirteenths of the interface's, as a find bar's count and field; large, eighteen thirteenths, as a palette's field; mini, nine thirteenths, as a mini control's; callout, twelve thirteenths, as a description under a setting; title, fourteen thirteenths, as a setting's name
    font_size: number?, -- its texts' size in points, 4 to 200, in place of text_size's, its children's too
    font_weight: ("light" | "regular" | "medium" | "semibold" | "bold" | "heavy")?, -- its texts' weight, its family's face nearest to it, its children's too; regular of the terminal's family its own face
    font_family: ("interface" | "terminal")?, -- its texts' family, its children's too: the interface's, or the terminal's, of [font]'s face and size, as a command's line
    background: Color?,
    foreground: Color?,
    corner_radius: number?,
    pointer: ("arrow" | "text" | "pointing-hand")?, -- its children's too, unless they give their own
    opacity: number?, -- from 0 to 1, of its children too
    transition: { duration: number?, easing: ("linear" | "ease-in" | "ease-out" | "ease-in-out")? }?, -- its moves and fades, over seconds, and its hover's
    -- What a node of a key takes while the pointer is over it, what a node takes while the pointer is over its
    -- nearest node of a key around it, as a tab's close button under its tab, and what a node of a key takes while
    -- the primary button that went down over it is down, the pointer still over it: the host applies them as the
    -- pointer moves, with no render, their colors over the node's own, each over the ones before, fading them as
    -- the transition says, at once where the system reduces motion.
    hover: Hover?,
    parent_hover: Hover?,
    pressed: Hover?,
}

type Hover = { background: Color?, color: Color?, border: { color: Color, width: number }?, opacity: number? }

-- A view is a tree of nodes; the host flattens it into its arena. A node
-- that holds state, a field or a list, needs its key, by which the host
-- keeps that state; a field's text is the host's, which events tell. A key
-- is unique in the whole tree, as "tab-3.close", as the events tell a node
-- by its key alone; a list's rows are told apart by their item's index.
type Node = {
    key: string?,
    kind: "container" | "text" | "icon" | "field" | "button" | "toggle" | "switch" | "checkbox" | "radios"
        | "pop-up" | "separator" | "group" | "keys" | "list" | "scroll" | "progress" | "spacer" | "tabs" | "image"
        | "theme-preview" | "terminal-specimen" | "themed",
    -- A group node: a group box, as macOS 27's grouped rows of a form, a container of its rows, whose box the host
    -- draws where its style gives none, a rounded fill of `group.bg`, and a hairline of `group.separator` between each
    -- two rows, across their content, inside their padding; its title, if it has one, a text above it.
    -- A callout, a tag and an empty state are containers of their parts, as Lokyr's own pages make them: a callout a
    -- box of `callout.<tone>.bg`, of radius 8, of an icon of `callout.<tone>.fg` ("info", "check", "warning" or
    -- "error") and a text of as many lines as it needs; a tag a text, small, of `callout.<tone>.fg`, in a capsule of
    -- `callout.<tone>.bg`, a radius larger than half its height; an empty state an icon, large, a title and a line of
    -- the secondary text, down a column in the middle of its room; the tones "info", "success", "warning" and
    -- "error", or `button.bg` and `text.secondary` of none.
    text: string?, -- for text nodes; a button's, a toggle's, a switch's and a checkbox's label
    -- For icon nodes, by its name, one of the host's: the codicons, as "search" or "close", the marks of programs,
    -- languages and AI agents, as "rust", "python", "git" or "claude" · Since 1.7, and two that the host draws as
    -- macOS 27's search field does, "magnifying-glass" and "clear-circle", its cross knocked out of a disc; a
    -- button's and a toggle's icon, before its label.
    icon: string?,
    on: boolean?, -- for toggle, switch and checkbox nodes, the plugin's state
    mixed: boolean?, -- for checkbox nodes: neither on nor off, a dash in place of its check, as a checkbox over
    -- others of which some are on; its click asks for on
    disabled: boolean?, -- for button, toggle, switch, checkbox, radios, pop-up and field nodes: dimmed, and takes neither a click nor the focus, a field nor a value of accessibility's (a field's · Since 1.4)
    -- For radios nodes, a group of radio buttons of one choice: its options, each of its label and whether it is
    -- disabled; the option chosen, from 0, nil of none; whether they go across a row rather than down a column.
    -- A click on an option, or an arrow while the group has the focus, tells a "select" of its index.
    options: { { label: string, disabled: boolean? } }?,
    chosen: number?,
    across: boolean?,
    -- For pop-up nodes, a pop-up button, as macOS's: the text of its choice chosen, from 0, and a pair of chevrons,
    -- as wide as its widest choice unless its layout says otherwise; nil of none, which shows its `placeholder`. A
    -- click, or Space, Return, ↑ or ↓ while it has the focus, opens the system's menu of its choices over it, the one
    -- chosen ticked; the menu tells a "highlight" of the choice under the pointer or the arrows, nil as it closes, and
    -- a "select" of the choice made, which the next render gives.
    choices: { string }?,
    -- For button, toggle, switch, checkbox, radios, pop-up, field and tabs nodes, the control's size, as macOS 27's: "large", 28 points high,
    -- "regular", 24, by default, "small", 20, of the small text, or "mini", 16, of the mini text; a switch 64 by 28,
    -- 54 by 24, 44 by 20 or 36 by 16; a checkbox's box and a radio button's circle 18, 16, 14 or 12.
    size: ("large" | "regular" | "small" | "mini")?,
    placeholder: string?, -- for field nodes, shown while the field is empty; for pop-up nodes, while no choice is chosen
    -- For field nodes, `text` is the text that it holds, which the host takes as the field first shows and as a
    -- render gives another, over what was typed; nil keeps what the host holds.
    stepped: boolean?, -- for field nodes: ↑ and ↓ tell a "step" rather than move the caret, as a number's field
    -- For field nodes, `records`: the field records a shortcut. While it has the keyboard, the keys pressed are its
    -- own, the menus' key equivalents too, of no binding's command run nor text typed: the host shows them as macOS
    -- writes them, as ⇧⌘Y, and tells a "recorded" of them as a config writes keys; Delete takes them away, and Tab and
    -- Escape do as elsewhere. Lokyr's own plugins alone: an installed plugin's field that records is a plain field.
    records: boolean?,
    -- For field nodes, `search`: a search field, as macOS's, a capsule where its style gives it no box of its own, a
    -- magnifying glass inside at its left, and, while it holds text, a button inside at its right that empties it,
    -- telling an "input-changed" of no text, as Escape does first while it has the keyboard, but in a panel that
    -- Escape closes, as a find bar's; its glyphs as large as its text.
    search: boolean?,
    link: boolean?, -- for button nodes: a link's look, its label underlined in the accent's color, of no box, the pointer a hand over it
    -- For button nodes, what its press does: "plain", by default; "default", the view's main action, of the accent's
    -- fill, which Return presses wherever the view's focus is but in a field or a list, none of a themed part's; "destructive", an action that
    -- removes something, its label red.
    variant: ("plain" | "default" | "destructive")?,
    keycaps: boolean?, -- for button nodes: its label a shortcut, as macOS writes it, drawn as key caps
    -- For keys nodes, a shortcut as macOS writes it, as "⇧⌘N", drawn as key caps: each of its modifiers' symbols and
    -- its key in a cap of its own, of `keycap.bg` and `keycap.fg`, of the node's text's size; a list's row takes one,
    -- of an item's text, as it takes a text.
    keys: string?,
    progress: {
        state: ("normal" | "error" | "paused" | "indeterminate")?,
        value: number?, -- from 0 to 1
        shape: ("bar" | "ring" | "outline")?, -- an outline its parent's, along its edges, over its children
        radius: number?, -- a bar's corners', a pill's without it; an outline's, its parent's without it
        thickness: number?, -- a ring's line's, or an outline's
        segment: number?, -- an indeterminate one's moving part, of the bar, of the turn or of the outline, from 0 to 1
        period: number?, -- an indeterminate one's sweep, turn or run along, in seconds
    }?, -- for progress nodes: its track of the style's background, its fill of the style's color
    count: number?, -- for list nodes, of all their items
    first: number?, -- for list nodes, the index of the first of `items`
    items: { ListItem }?, -- for list nodes, flat: a window of them, from `first`, as the host asks for them
    row: Node?, -- for list nodes: the template of a row, of containers, texts, icons, spacers and separators
    row_height: number?, -- for list nodes, of rows of one height, a point at least; without it, each row takes its own, a point at least
    menu: boolean?, -- for list nodes, a menu's look: the row under the pointer hovered, the selection a rounded band inset from its edges, of the accent's whether the list has the keyboard or not, the first item selected as it shows, as a palette's, and a row activated of a click, the selected one's too, as a menu's item, where another list's takes a double click
    tabs: { { label: string, icon: string?, disabled: boolean? } }?, -- for tabs nodes, in their order: a control of them over the box of its page, its child
    chosen: number?, -- for tabs nodes, the tab chosen, whose page is its child; a click or the arrows choose another, as "select" tells
    distribution: ("fit" | "fill" | "fill-equally" | "fill-proportionally")?, -- for tabs nodes, as macOS's segmented controls: each tab of its content's width, the control in the middle, by default; or the control of the view's width, each tab of its content's and an equal share of the room left, of equal widths, or of its content's share
    theme: string?, -- for theme-preview nodes, a theme's name, of which the host draws a sample terminal in its colors within the room that the node's layout gives it: its background, a prompt, an `ls` of colors and the sixteen colors; nothing of a name that names no theme, nor out of its view's room, as of a card scrolled away; the node has no size of its own
    -- A terminal-specimen node: a terminal of the theme in force, drawn as the panes draw theirs from its top left
    -- corner within the room that its layout gives it, of every combination that a theme colors; it has no size of
    -- its own, and is drawn in the settings window alone; within a themed node, of that node's theme, in any window.
    -- A themed node: a container whose box and children are drawn in the theme that `theme` names, as it resolves, of
    -- its tokens and its terminal's colors, whatever the window's theme: the texts, the controls of their hover and
    -- press, a field, a list, a progress and a terminal-specimen among them; of the window's own of a name that names
    -- no theme. A tooltip of a node within it is the window's. Its theme's file is followed as the themes in force
    -- are, and its change tells `theme-changed`.
    image: number?, -- for image nodes, the id of an image that the host keeps, as `render_image` of `keep` answers it: drawn whole within the room that the node's layout gives it, in the middle, of its own proportions, and nothing of an id let go; the node has no size of its own
    layout: NodeLayout?,
    style: Style?,
    focusable: boolean?, -- takes the keyboard's focus, by its key
    -- Dragged among its siblings that are reorderable too, along its parent's direction, by its key, as a
    -- bar's tabs: the host moves it under the pointer within their room, over them, slides the others out of
    -- its way and scrolls a scroll area around them past its ends; Escape puts it back. A drop at another
    -- place gives it a "reorder" of its index among them, which the next render shows; a render that keeps
    -- the order, or none within half a second, slides them back.
    reorderable: boolean?,
    -- A reorderable node's tab, as a bar's tab carries it: dragged across its parent past a margin, or out
    -- of its window, it leaves its siblings, which close its room, and the host shows the tab's panes under
    -- the pointer, its window showing another tab meanwhile; the bar of another window opens a room for it.
    -- A drop there gives it a "drop-on-bar", on a pane of another tab, whose half nearest the pointer lights
    -- up, a "drop-on-pane", outside every window a "drop-outside", before its "drag-end", of which its
    -- plugin makes the tab's move; Escape, or a drop elsewhere, puts it back.
    carries: number?,
    tooltip: string?, -- shown as the pointer rests over the node, by its key
    children: { Node }?,
    -- What accessibility, as VoiceOver, takes the node for, in place of its kind's: a container a group, a
    -- toolbar, a status or an alert, a text a heading, an icon an image; a widget keeps its own.
    role: ("group" | "toolbar" | "status" | "alert" | "heading" | "image")?,
    -- What accessibility calls it, in place of its text, a button's or a toggle's label, or its tooltip: what a
    -- button of an icon alone gives, without a tooltip; an icon of none is left out, as a decoration.
    label: string?,
}
type View = Node

-- A list's item: the texts that its row's template shows, by their places
-- in it, its texts' and its icons' in the tree's order; its index tells it
-- apart.
type ListItem = { texts: { string }, divider: boolean? } -- `divider`: a line above its row, which divides the items before it from it, as a sidebar's groups · Since 1.5

-- A row's text, by its number, without the spaces that end it, but where it wraps into the next.
type Line = { row: number, text: string, wrapped: boolean }

-- What a search of a pane's terminal looks for: the text, as it is, or a regex, of the syntax of Rust's `regex`;
-- case "smart" counts of a text of a capital letter alone; whole words alone, as `whole_word` asks.
type SearchQuery = { text: string, regex: boolean?, case: ("smart" | "sensitive" | "insensitive")?, whole_word: boolean? }

-- What a selection takes of its cells: the cells in reading order, the words or the logical lines that its ends are in,
-- or the block of their columns and rows.
type SelectionKind = "cells" | "words" | "lines" | "block"

-- A match of a search: its first cell and its last, each { column, row's number }.
type SearchMatch = { first: { number }, last: { number } }

-- A command that the shell marked, as its integration tells it (OSC 133): its id, of the pane's commands from 1 in their
-- prompts' order; each mark's cell, { column, row's number }, if its row is in the pane still, of its prompt, the input
-- typed past it, its output, and its end; and its exit status, if it ended and the shell told it. Its output is the
-- cells from `output` to before `end`, in reading order, which `read_lines` reads. The times of its start, at its
-- output's mark, and of its end, of the system's clock, in milliseconds since 1970 in UTC; and the folder where it
-- started, as the shell told it last before its start (OSC 7), with its machine where it is another one, as a
-- shell's over ssh, to a plugin of `process-read` alone · Since 1.4.
type ShellCommand = {
    id: number,
    prompt: { number }?, input: { number }?, output: { number }?, ["end"]: { number }?,
    status: number?,
    started: number?, ended: number?, folder: string?, host: string?,
}

-- A pane's view, as its last frame showed it: the number of its first row, its rows, the number of the screen's first
-- row, as `top` is while it shows the screen and less above, the number of the oldest row, which the scrollback's limit
-- raises, the epoch of the rows' numbers, which a resize changes as it numbers them anew, whether the alternate
-- screen shows, of rows of its own, of no scrollback nor commands, and the folds that it shows, from its top, each one
-- row in place of a command's output or of its whole block, `whole`, from its `first` row to its `last`, so that the
-- view shows the rows past `top + rows` too · Since 1.4.
type ViewFold = { command: number, whole: boolean, first: number, last: number }
type Viewport = { top: number, rows: number, screen: number, oldest: number, epoch: number, alternate: boolean, folds: { ViewFold }? }

-- The cells of a row from a column to another, of one style, as the program gave it.
type StyleRun = { first: number, last: number, style: { foreground: any?, background: any?, bold: boolean, italic: boolean, underline: string? } }

-- An image of cells that the host renders: rows of a text, as a read of rows gives it, and its styles' runs, a later
-- over an earlier; a bar of the window's three buttons and a title, if it shows them; rounded corners, a shadow, the
-- room around the window, in points, from 0 to 256, and what fills it, the theme's background darker by default; the
-- pixels of a point, from 1 to 4, the display's of the focused window without.
type ImageSpec = {
    rows: { { text: string, runs: { StyleRun }? } },
    title: string?,
    buttons: boolean?,
    rounded: boolean?,
    shadow: boolean?,
    padding: number?,
    background: ("theme" | "clear" | { rgb: { number } })?,
    scale: number?,
    -- Whether the host keeps it, as a picture of the renderer's, which an image node shows by the id that the answer
    -- gives, until `drop_image`, four more kept, or the plugin's stop.
    keep: boolean?,
    -- The least columns and rows of the window's cells, 1000 at most: a narrower or shorter text leaves the cells at
    -- its right and below it empty.
    min_columns: number?,
    min_rows: number?,
}

-- The image that the host rendered: a PNG, a string of its bytes, its size in pixels, its pixels a point, and the id
-- of one that the host keeps.
type Image = { png: string, width: number, height: number, scale: number, id: number? }

-- A decoration's look: an underline, of its own color or the text's, a background, the pointing hand over its cells,
-- and a label over its first cells.
type DecorationLook = {
    underline: ("single" | "double" | "curly" | "dotted" | "dashed")?,
    underline_color: { number }?, -- red, green, blue
    background: { number }?,
    pointing: boolean?,
    label: string?, -- drawn over its first cells in place of their text, as a hint's letters, of the theme's colors for labels: one to three ASCII letters and digits
}

-- The workspace's changes, as its operations record them; an index is a
-- tab's place among its window's tabs.
type Event =
    { kind: "window-opened", window: WindowId }
    | { kind: "window-closed", window: WindowId }
    | { kind: "tab-created", tab: TabId, window: WindowId, index: number }
    | { kind: "tab-closed", tab: TabId, window: WindowId }
    | { kind: "tab-activated", tab: TabId, window: WindowId }
    | { kind: "tab-moved", tab: TabId, from: WindowId, window: WindowId, index: number }
    | { kind: "pane-created", pane: PaneId, tab: TabId }
    | { kind: "pane-closed", pane: PaneId, tab: TabId }
    | { kind: "pane-focused", pane: PaneId, tab: TabId }
    | { kind: "pane-moved", pane: PaneId, from: TabId, tab: TabId }
    | { kind: "layout-changed", tab: TabId }
    -- A tab's title or color changed, its own, its program's, or its active pane's folder and program as output comes;
    -- to a plugin without `process-read`, which reads no folder nor program, as its title or color changes alone.
    | { kind: "tab-changed", tab: TabId }
    -- A pane's header changed: its program's title, or, of none, its folder and program as output comes; to a plugin
    -- without `process-read`, which reads no folder nor program, as its program's title changes alone.
    | { kind: "pane-changed", pane: PaneId, tab: TabId }
    -- A group of tabs was made, or changed: its name, its color, its fold or its tabs, or it went, taken apart or of no
    -- tab left; its window, or the one that it was in.
    | { kind: "group-changed", group: GroupId, window: WindowId }
    -- A session was made, renamed, switched to or from, or went, of no window left or closed · Since 1.5.
    | { kind: "session-changed", session: SessionId }
    -- A window's broadcast of the typed input changed: where it goes, or a pane of it left out or taken back in
    -- · Since 1.5.
    | { kind: "broadcast-changed", window: WindowId }
    -- The keymap's bindings changed, as the config's or a plugin's: the keys of `keys_of` may be others.
    | { kind: "keys-changed" }
    -- A window took the keyboard's focus, or lost it, as a click goes to another app or another window; not as a question of
    -- the app's on it takes it.
    | { kind: "window-focus", window: WindowId, focused: boolean }
    -- The pointer over another cell of a pane, or out of it, or the modifiers changed over it, or a frame changed the text
    -- of its row or scrolled its pane's rows under it, at the same cell; while Command is up, its
    -- moves come only as the system gives them, as a program that tracks the mouse asks.
    | { kind: "pointer", pane: PaneId, at: { number }?, mods: { shift: boolean, control: boolean, option: boolean, command: boolean } }
    -- A click of the left button on a pane's cell that the terminal kept: one click, of no modifier, that dragged over no
    -- cell, and that no binding nor program took, as the button went up; the cell, its column and its row's number, as
    -- the drawn frame showed it · Since 1.4.
    | { kind: "click", pane: PaneId, at: { number } }
    -- The right button pressed over the prompt rows of a block that the host pins at a pane's top, or the left one with
    -- Control: the pane, its window, where a plugin's menu opens at the pointer, and the block's command; the terminal and
    -- the program take none of it · Since 1.4.
    | { kind: "prompt-rows-menu", pane: PaneId, window: WindowId, command: number }
    -- A pane's view changed, as a frame showed it: its first row, as a scroll by hand or output moved it, its rows, the
    -- screen's first row, as output scrolled the screen under a view above it, the oldest row, as the scrollback's limit
    -- took rows away, the epoch or the screen shown; once a frame of the pane at most, a pane that does not show telling
    -- it as it shows again.
    | { kind: "viewport-changed", pane: PaneId, viewport: Viewport }
    -- A command that the shell marked started, as its output's mark came, and ended, as its end's came, of the status
    -- that the shell told; or of none, as its pane let go of it before its end, as a reset or a screen cleared under it
    -- does. A shell that marks no end tells none. To a plugin of `history-read`, which a subscription needs.
    | { kind: "command-started", pane: PaneId, command: number }
    | { kind: "command-ended", pane: PaneId, command: number, status: number? }
    -- A read of rows that the plugin asked for, to it alone; incomplete if a resize renumbered the rows.
    | { kind: "lines", id: number, pane: PaneId, lines: { Line }, complete: boolean }
    -- A part's matches of a search that the plugin asked for, to it alone, the nearest to the view first; how many it
    -- found so far, past the 100 000 kept too; and whether it went to its end, or stopped at a resize or the pane's close.
    | { kind: "searched", id: number, pane: PaneId, matches: { SearchMatch }, count: number, done: boolean }
    -- A panel of the plugin's closed, as a click outside it, Escape, the app or the plugin closed it, to it alone.
    | { kind: "panel-closed", id: string }
    -- A page of the plugin's of the settings' window shows, or no longer does, as another page shows or the window
    -- closes, to it alone: Lokyr's own plugins' alone, which have pages.
    | { kind: "page-shown", page: string }
    | { kind: "page-hidden", page: string }
    -- The answer to a question of `ask_text`, `copy_theme`, `new_theme` or `convert_theme`, to it alone: the text, or
    -- the theme's name, or none as the question was cancelled.
    | { kind: "answered", id: number, text: string? }
    -- The end of a save of `save_file`, to it alone: the path of the file that the host wrote at the place chosen; none
    -- as the panel was cancelled or its window closed; or the error of a write that failed.
    | { kind: "saved", id: number, path: string?, error: string? }
    -- A popup that the plugin opened closed, to it alone, as its command ended, at a key after it failed, or as it,
    -- its tab or its window was closed: its command's status, 128 and a signal's number for a signal, as shells give
    -- it, or nil while the command still ran · Since 1.5.
    | { kind: "popup-closed", pane: PaneId, status: number? }
    -- The answer to a question of `ask_choice`, to it alone: the button chosen, from 0, or nil as its window closed.
    | { kind: "chosen", id: number, button: number? }
    -- A color chosen in the color panel that the plugin showed, `show_color_panel`, as it moves, and the panel's
    -- closing, to it alone.
    | { kind: "color-picked", color: string }
    | { kind: "color-panel-closed" }
    -- A line of a job of `packages`, to it alone: Sleip's event, an object of its `event` and its fields, as
    -- PACKAGE-MANAGER.md writes them down of each command; then the job's end, whether its command succeeded.
    | { kind: "package", id: number, line: { event: string, [string]: any } }
    | { kind: "packages-ended", id: number, ok: boolean }
    -- The plugins changed, as `plugins` would tell them: one installed, removed, turned off or on, activated, faulted,
    -- or a capability's decision; or the installed plugins were taken anew, as their lockfile changed, whatever `plugins`
    -- tells, as of a package that Lokyr refused; to a plugin of `packages` that subscribes to it.
    | { kind: "plugins-changed" }
    -- The settings changed, as the config applied anew, which `settings` would tell; to a plugin of `config` that
    -- subscribes to it.
    | { kind: "settings-changed" }
    -- The themes that the app can show changed, as `themes` tells: their list read, as the app reads it off its main
    -- thread, or a theme added, removed or changed; of no capability.
    | { kind: "themes-changed" }
    -- The theme in force resolved anew, of other colors: another theme named, its file saved, the appearance
    -- changed, which `theme_tokens` reads; or the theme of a themed node that a view shows, of other colors; of no
    -- capability.
    | { kind: "theme-changed" }
    -- A drag of the edge of the plugin's tab bar's column ended, to it alone: its width since, in points,
    -- which the plugin keeps, as for its next start.
    | { kind: "tab-bar-resized", width: number }
    -- The plugin's section of the config changed, to it alone, which `config` reads.
    | { kind: "config-changed" }
    -- A timer of the plugin's fired, to it alone, once however many times it fired since the plugin last heard of it.
    | { kind: "timer", id: number }
    -- The modifier that the plugin watches, of `watch_double_tap`, was pressed and let go of alone twice, to it alone.
    | { kind: "double-tapped", modifier: "ctrl" | "alt" | "cmd" | "shift" }
    -- An event that a plugin emitted, of its namespace; a value nests 64 levels at most.
    | { kind: "custom", name: string, schema: string, value: any }

-- A view of a plugin's: a window's slot, a pane's header, one of its panels, by the id that it gives it, or one of
-- its pages of the settings' window, by its manifest's id, Lokyr's own plugins' alone.
type ViewId =
    { tab_bar: WindowId } | { window_strip: WindowId } | { status_bar: WindowId }
    | { pane_header: PaneId } | { panel: string } | { page: string }

-- Where a panel goes, and the window that it shows in.
type Anchor =
    { cell: { pane: PaneId, column: number, row: number } } -- below it
    | { cursor: PaneId } -- below it
    | { pointer: WindowId } -- where it is as the panel opens
    | { node: { view: ViewId, key: string } } -- below a node of a view of the plugin's
    | { pane_corner: { pane: PaneId, corner: Corner } }
    | { pane_top: PaneId } -- across a pane's top, of its width, at its edge, as a command's header
    | { window_corner: { window: WindowId, corner: Corner } } -- of its room below the tab bar
    | { view_window: { view: ViewId, corner: Corner } } -- of the room of the window that shows a view of the plugin's, of no window's id, as a page's dialog in the settings' window
    | { view_pointer: { view: ViewId } } -- at the pointer in the window that shows a view of the plugin's, of no window's id, as a page's context menu in the settings' window
type Corner = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top" | "center" -- "top": the top's middle, an eighth of the height down, as a palette's; "center": the middle, as a dialog's

type PanelOptions = {
    anchor: Anchor,
    -- a dialog by default; a menu of menu items alone shows as the platform's own; an overlay takes the pointer, a scroll
    -- going through to the pane under it but where a list or a scroll area of its own is, and not the keyboard
    role: ("tooltip" | "menu" | "dialog" | "overlay")?,
    close_outside: boolean?, -- a click outside it closes it
    close_escape: boolean?, -- Escape closes it, while it has the keyboard's focus
    -- it holds the keys back from the program, as a mode of the keyboard's, as the copy mode's: while it shows and the
    -- keyboard is its pane's, of an anchor of a pane, or any pane's, of another, the keys that no binding takes and the
    -- text typed go nowhere; the pane keeps the keyboard, and its cursor its look
    takes_keys: boolean?,
    -- a key or a text typed into a pane of its window closes it, as a tip's card goes at the first key: the key goes to
    -- the program still, and the plugin hears `panel-closed`
    close_typing: boolean?,
}

type UiEvent = {
    view: ViewId,
    key: string,
    kind: "click" | "double-click" | "middle-click" | "hover-enter" | "hover-leave" | "context-menu"
        | "input-changed" | "submit" | "focus" | "blur" | "scroll"
        | "drag-start" | "drag-move" | "drag-end" | "drag-cancel" | "reorder" | "drop-on-bar"
        | "drop-on-pane" | "drop-outside" | "set-value" | "toggle" | "select" | "highlight" | "activate"
        | "list-range" | "cut" | "step" | "recorded",
    text: string?, -- a field's text, as the host holds it: at each change, "input-changed", and as Return goes to it, "submit"
    revision: number?, -- an "input-changed" text's, one more at each edit, which `set_text` gives back
    shift: boolean?, -- a "submit"'s, whether Shift was held, as Shift-Return goes the other way
    up: boolean?, -- a "step"'s, of a field of steps' arrow key: ↑ a step up, ↓ a step down
    keys: string?, -- a "recorded"'s, the keys that a field that records a shortcut took, as `cmd+shift+y`; nil as Delete took them away
    item: number?, -- a list's item, selected or activated; a pop-up button's choice made, or highlighted, nil of none
    first: number?, count: number?, -- the items of a list that the host asks for, which the next render gives
    x: number?, y: number?, -- a drag's, from its start, or a scroll's, in points; a "drop-outside"'s, where the tab's new window puts its content's corner on the screens
    index: number?, -- a "reorder"'s, the node's new index among its reorderable siblings, before its "drag-end"; a "drop-on-bar"'s, the tab's index among the window's
    window: number?, -- a "drop-on-bar"'s, the window whose bar took the tab
    pane: PaneId?, edge: ("left" | "right" | "top" | "bottom")?, -- a "drop-on-pane"'s, the pane and its edge nearest the pointer
    value: string?, -- set by accessibility, as VoiceOver's; its press comes as a click, its focus as a focus
    on: boolean?, -- a toggle's or a switch's state asked, the other than its render's, which the next render gives
    cut: boolean?, -- a text of lines', whether it is cut, of more lines than its layout's or of a word wider than it, as a tip's More button shows
}

-- A command, as its registration describes it.
type Command = {
    name: string, -- `namespace.action`
    title: string,
    category: "app" | "windows" | "tabs" | "panes" | "input" | "clipboard" | "edit" | "find" | "view",
    capabilities: { string }?, -- those that its action needs, as "pty-write"
    params: { { name: string, kind: "string" | "integer" | "number" | "boolean", default: (string | number | boolean)? } }?,
    when: string?, -- the context in which it can run, as a binding's `when`
}

-- The themes that the app can show, as a read of them gives them: the appearance in force, its theme as `[theme]` names
-- it, and every theme by name, a file of the themes folder before one of its name that the app holds or builds in, each
-- of its file's format, Lokyr's own or an `.itermcolors` file's.
type Themes = {
    appearance: "light" | "dark", current: string,
    themes: {
        {
            name: string, variant: "light" | "dark", origin: "folder" | "held" | "built-in",
            format: "lokyr" | "itermcolors",
        }
    },
}

-- The system's font families, as a read of them gives them: the family in force, the config's `[font] family` where
-- the system has it, else the default one, every monospaced family by name, in their names' order, and every family,
-- monospaced or not, as a family of the text past ASCII or of the interface takes.
type Fonts = { current: string, families: { string }, all: { string } }

-- A command, as a read of the registry gives it; `plugin`, `keys`, `when` and `enabled` to a plugin of `user-commands`
-- alone: the plugin that registered it, nil of the app's own; its keys of no arguments, as "⌘T"; its context; and whether
-- the menus enable it now.
type CommandInfo = {
    name: string, title: string, category: string,
    params: { { name: string, kind: string, default: (string | number | boolean)? } },
    plugin: string?, keys: string?, when: string?, enabled: boolean?,
}

-- An item that a plugin added to the menu bar, as a read of them gives it: its command of its arguments, its title,
-- its own or its command's, and its submenu's, its menu's category, its keys, as "⌘D", whether the menu bar enables
-- it and ticks it now, and its plugin. · Since 1.6
type MenuBarItem = {
    command: string, args: Args, title: string, submenu: string?, menu: string, keys: string?,
    enabled: boolean, ticked: boolean, plugin: string,
}

-- `keys`: e.g. "cmd+f" or "ctrl+a>c"; `when`: e.g. "pane.focused && !search.open", where a plugin's
-- panels give `namespace.open` while one shows, not one of a pane behind another tab or a zoomed pane, and
-- `namespace.focused` while one has the keyboard, and its selection of a block `namespace.selected` while the pane
-- that has the keyboard shows it · Since 1.4; each panel alone gives `namespace.panel.open` and
-- `namespace.panel.focused` too, of its id, as "search.find-all.focused" · Since 1.6. A key taken from every
-- app, with `global-hotkey`, starts with "global:", as "global:ctrl+`", without `when`: one key, by its place on the US
-- layout, with Command, Control or Alt, or a function key; the config's global keys come first.
type Binding = { keys: string, command: string, args: Args?, when: string? }

-- An item of the menu bar's menu of a category, after its commands, or of the pane's context menu, after the editing's:
-- a command and its arguments, a whole call, as Split Left's `{ direction = "left" }`; its title the message `title` of
-- the plugin's catalogs, or `title` itself where they lack it, or the command's without one. The menu bar shows the keys
-- bound to the same call; the command's `when` dims the item, and its plugin's `applies` the context menu's.
type MenuItem = {
    place: { bar: "app" | "windows" | "tabs" | "panes" | "input" | "clipboard" | "edit" | "find" | "view" } | "pane-context",
    command: string, args: Args?, title: string?,
    -- The title of a submenu of the menu, a message or a text, which gathers the plugin's items of the same one.
    submenu: string?,
    -- A menu bar's item ticked; the same item added again, of another tick, changes it.
    ticked: boolean?,
}

-- The logical line of a row: its text, and each character's cell, { column, row's number }.
type LineText = { text: string, cells: { { number } } }

-- `row`: to the row of that number, at the view's top, as far as the scrollback's first row and the screen let it.
type Scroll = { up: number } | { down: number } | "page-up" | "page-down" | "top" | "bottom" | "previous-prompt" | "next-prompt" | { row: number }

-- The host's requests, each by the Rust front end's name. A read answers at once, of the state as it is; a
-- write, and a request of the app's, as a window to open or a command to run, applies as the call returns,
-- the writes first; a read of the call reads the state before them. A write to a tab or a pane that an
-- earlier write of the call opens finds it. A call that returns an error, or fails, drops its writes and requests.
type Cx = {
    -- Declarations, at once.
    register_command: (command: Command) -> (boolean, Error?),
    bind: (binding: Binding) -> (boolean, Error?),
    -- An item of a menu, of a registered command and its arguments, which the plugin may run, for as long as it runs.
    add_menu_item: (item: MenuItem) -> (boolean, Error?),
    -- The workspace's events, as "tab-created", the pointer's, "pointer", the windows' focus, "window-focus", and plugins' own, as
    -- "search.progress".
    subscribe: (names: { string }) -> (boolean, Error?),
    -- An event of the plugin's namespace, which comes after the call returns.
    emit: (name: string, schema: string, value: any) -> (boolean, Error?),
    -- Runs a command, once the call returns: of a plugin of `user-commands`, any, as if run by hand, without a declaration.
    run_command: (name: string, args: Args?) -> (boolean, Error?),
    -- The registered commands, in the order of their registrations, as the menus list them.
    commands: () -> ({ CommandInfo }?, Error?),
    -- The items that the plugins added to the menu bar, in their menus' order, as the menu bar shows them now, of
    -- `user-commands`. · Since 1.6
    menu_bar_items: () -> ({ MenuBarItem }?, Error?),
    -- The themes that the app can show, the appearance in force and its theme: the themes' folder's, the held ones and
    -- the built-in ones, which the app reads off its main thread, a read starting where none did lately; the built-in
    -- ones alone, of `loading`, while its first read runs, whose end `themes-changed` tells.
    themes: () -> (Themes?, Error?),
    -- Every color of the theme of a name, or of the appearance in force's of nil, as it resolves, its terminal's and
    -- its tokens: its color and its origin, its file's path and line, a theme of no file's, or its rule's text, and its
    -- value as the theme gives it, a color or an expression, nil of a rule's; nil of a name of no theme. A file's path
    -- is given whole to a plugin of `config` alone, its file's name to the others.
    theme_tokens: (theme: string?) -> (ThemeTokens?, Error?),
    -- Require `appearance-write`: shows a theme in place of the appearance in force's, for a while, as a picker
    -- previews it; nil shows the config's.
    preview_theme: (name: string?) -> (boolean, Error?),
    -- Names a theme in the config's `[theme]` for an appearance, which shows at once, a preview ending: a theme that
    -- `themes` lists, of either appearance, else refused.
    set_theme: (variant: "light" | "dark", name: string) -> (boolean, Error?),
    -- Require `config`: asks the name of a copy of a theme, as Duplicate… does, writes it into the themes folder of
    -- every color of the theme's and names it in `[theme]` for its appearance; the question's id, whose answer,
    -- `answered`, is the copy's name once written, or nil as the question is cancelled or the copy fails, which Lokyr tells.
    copy_theme: (name: string) -> (number?, Error?),
    -- Require `config`: asks the name of a new theme of Lokyr's own values of an appearance, as the Themes page's New…
    -- does, writes it into the themes folder, every key written, and names it in `[theme]` for that appearance; the
    -- question's id, whose answer, `answered`, is the theme's name once written, or nil.
    new_theme: (variant: "light" | "dark") -> (number?, Error?),
    -- Require `config`: asks whether to convert an `.itermcolors` theme of the themes folder to Lokyr's format, and
    -- converts it, of its colors and its name, its `.itermcolors` file moved to the Trash; the question's id, whose
    -- answer, `answered`, is the theme's name once converted, or nil as the question is cancelled or the conversion fails.
    convert_theme: (name: string) -> (number?, Error?),
    -- Require `config`: sets a color of a theme of Lokyr's format of the themes folder, by the name that
    -- `theme_tokens` gives it, to a value, a color, or for a token an expression, or takes it away of nil, in the
    -- theme's file, its comments and order kept, which shows at once; refused of a value that does not read or whose
    -- names do not resolve, a read-only theme, or a palette's color taken away alone.
    set_theme_value: (theme: string, name: string, value: string?) -> (boolean, Error?),
    -- Require `config`: shows a color of a theme of the themes folder of a value in place of its file's, wherever the
    -- theme shows, as a color panel moves, until it is written, its write fails, the plugin stops, its file is read
    -- anew, or nil shows its file's again, whatever the color.
    preview_theme_value: (theme: string, name: string, value: string?) -> (boolean, Error?),
    -- The system's color panel of a color, of its opacity's slider where asked, of no capability: the colors that the
    -- user chooses come as `color-picked`, its closing as `color-panel-closed`, to the plugin that showed it last, the
    -- one before hearing it closed. While one of Lokyr's own plugins shows it, another plugin's hears it closed at
    -- once; it closes as the plugin that showed it stops.
    show_color_panel: (color: string, alpha: boolean) -> (boolean, Error?),
    -- Closes the color panel, if the plugin showed it last.
    close_color_panel: () -> (boolean, Error?),
    -- The system's monospaced font families, of no capability, read of the system's fonts at most every 30 s.
    fonts: () -> (Fonts?, Error?),
    -- The styles of a font family, by the names that the font gives its faces, as "Bold Italic", from the lightest,
    -- each upright before its italic, of no capability; none of a family that the system lacks.
    font_styles: (family: string) -> ({ string }?, Error?),
    -- Require `appearance-write`: shows a monospaced family, as `fonts` lists it, its case aside, in every pane in place
    -- of the config's, for a while, as a picker previews it, of the config's styles that it has, its own in place of
    -- those that it lacks; nil shows the config's. A family changes the cell's size:
    -- every pane takes its grid anew and its program the signal of it, so a picker previews once its selection rests.
    -- nil ends a face's style's preview too.
    preview_font: (family: string?) -> (boolean, Error?),
    -- Require `appearance-write`: shows a face of the terminal's text, "regular", "bold", "italic" or "bold-italic", in
    -- every pane of a style of the family in force, as `font_styles` lists it, in place of the config's `[font] style`,
    -- `bold-style`, `italic-style` or `bold-italic-style`, for a while, as a picker previews it, until `preview_font`
    -- of nil, or a change of the config's font; a style that the family lacks refused.
    preview_font_style: (face: FontFace, style: string) -> (boolean, Error?),
    -- Names a monospaced family in the config's `[font] family`, edited in place, which shows at once, a preview
    -- ending: one that `fonts` lists, else refused. The config's styles that it lacks, as `style = "Medium"`, are
    -- commented out where they were, as the config would refuse them, to be taken back by hand.
    set_font: (family: string) -> (boolean, Error?),

    -- Today, in whole days since 1 January 1970, of the system's clock, of no capability, as a plugin that shows
    -- something once a week counts its days.
    day: () -> (number?, Error?),
    -- The time of the system's clock, in milliseconds since 1970 in UTC, and the local time zone's offset from UTC,
    -- in seconds east of it, of no capability, as a plugin that shows a time of day reads them · Since 1.4.
    now: () -> ({ time: number, offset: number }?, Error?),
    -- Whether a notice of the app's shows, as an error of the config, of no capability, so that a plugin's card that
    -- can wait gives way to it.
    notice_shows: () -> (boolean?, Error?),
    -- Whether the host keeps the plugin's state between the app's runs, of no capability: it does not without a state's
    -- folder, where a plugin that shows something once in a while would show it at every start.
    keeps_state: () -> (boolean?, Error?),
    -- Writes `bytes` as the plugin's temporary file `name`, of no capability, in a folder of the plugin's own that Lokyr
    -- empties as it quits and as it starts, a file of the same name in place of the old one, marked as downloaded, so
    -- that macOS asks before it opens as a program, readable by your account alone: its path, as an editor opens it. A
    -- name of a file's alone, of no `/`, ending in a text's extension (`.txt`, `.log`, `.md`, `.json`, `.yaml`, `.yml`,
    -- `.toml`, `.diff` or `.patch`), 8 MiB a file, 16 files and 32 MiB together at most; 32 MiB of writes at once, each
    -- 256 KiB at least, given back at 8 MiB a second, a write past them refused until they come back; an error without
    -- a state's folder and of a call that only looks, as `applies`; the tests' host keeps the bytes in memory, of a
    -- path in `/tmp/lokyr-temporary` · Since 1.4.
    temp_file: (name: string, bytes: string | buffer) -> (string?, Error?),
    -- The AI agents that run in the panes, of every window, in the windows', tabs' and panes' order, of
    -- `process-read`: each one's pane, tab, window, program's name, state, message while it waits, what it asks for
    -- while it waits, `kind`, of "permission", "question" or "auth", where its program tells it, and `since`, how
    -- long it has been in its state, in milliseconds.
    agents: () -> ({ AgentInfo }?, Error?),

    -- The focus: the window that has it, and its pane that has the keyboard.
    focused_window: () -> WindowId?,
    focused_pane: () -> PaneId?,

    -- The workspace. A new tab's and a split's ids come at once; what a move made, as a new window, comes as
    -- the workspace's events.
    windows: () -> ({ WindowInfo }?, Error?),
    tabs: (window: WindowId) -> ({ TabInfo }?, Error?),
    -- A window's tabs in the order of their use, the one that showed last first, as Control-Tab steps through them.
    recent_tabs: (window: WindowId) -> ({ TabInfo }?, Error?),
    -- A window's groups of tabs, in the order of their tabs.
    groups: (window: WindowId) -> ({ GroupInfo }?, Error?),
    -- The sessions, in the order of their use, the active one first and the one before it second
    -- · Since 1.5.
    sessions: () -> ({ SessionInfo }?, Error?),
    -- The folders that the sessions' switcher lists, of `process-read` · Since 1.5.
    session_folders: () -> (SessionFolders?, Error?),
    -- A window's broadcast of the typed input · Since 1.5.
    broadcast: (window: WindowId) -> (Broadcast?, Error?),
    -- A tab's floating panes, which a tab's panes list after its layout's while they show · Since 1.5.
    floating_panes: (tab: TabId) -> (FloatingPanes?, Error?),
    layout: (tab: TabId) -> (Layout?, Error?),
    -- A tab of a new pane, whose program starts as a new pane's beside the window's focused one, at `index` of
    -- its tabs or at their end: the tab's id and the pane's. The window shows the tab that it showed. Its pane
    -- starts in `directory`, a path absolute or from `~`, or in the folder of a file there, if given, and as a new
    -- pane's of a path that is not there. Its program takes `environment`, variables by their names, 64 at most,
    -- over the terminal's own, the shells' integration keeping its own, with `pty-write` too.
    -- Its environment · Since 1.6.
    new_tab: (window: WindowId, index: number?, directory: string?, environment: { [string]: string }?) -> ({ tab: TabId, pane: PaneId }?, Error?),
    -- A new pane on `side` of `pane`'s part, whose program starts as a new pane's beside it, in `directory` and of
    -- `environment` as `new_tab`'s: its id.
    -- Its folder and its environment · Since 1.6.
    split: (pane: PaneId, direction: Direction, side: Side, directory: string?, environment: { [string]: string }?) -> (PaneId?, Error?),
    -- A popup over the active tab of `window`, of the focused one for none: a floating pane in the tab's middle, of
    -- `width` and `height`, shares of its room, 0.8 and 0.7 by default, whose program is the user's login shell
    -- running `command`, in `folder`, a path absolute or from `~` of a folder that is there, the focused pane's for
    -- none, never in a window that is hidden: its pane's id. It
    -- shows whether the tab's floating panes do, closes as the command exits with 0 or is interrupted, as with
    -- Control-C, and keeps its screen otherwise until a key; "popup-closed" tells the plugin its close. It takes
    -- `workspace-write` and `pty-write` · Since 1.5.
    open_popup: (window: WindowId?, command: string, folder: string?, width: number?, height: number?)
        -> (PaneId?, Error?),
    -- Closes a tab, or a pane; with `ask`, once it is confirmed while a program other than a shell runs there,
    -- as the host asks for a window. Of `keep` seconds, a day at most, the host keeps the tab for them, its
    -- programs running, 16 tabs at most, the oldest closing for good past them; but a window's last tab and a tab
    -- whose close was confirmed. `reopen_tab` gives back the tab closed last that the host keeps, at its place in
    -- its window, or in `window` once its own closed or hides with its session, which shows it; nothing of none kept.
    close_tab: (tab: TabId, ask: boolean?, keep: number?) -> (boolean, Error?),
    reopen_tab: (window: WindowId) -> (boolean, Error?),
    close_pane: (pane: PaneId, ask: boolean?) -> (boolean, Error?),
    -- A title or a color of a tab's own, in place of its program's; none gives the program's back.
    set_tab_title: (tab: TabId, title: string?) -> (boolean, Error?),
    set_tab_color: (tab: TabId, color: Color?) -> (boolean, Error?),
    -- Pins a tab, which goes to its window's start, after the tabs pinned before it; or unpins it, which goes right
    -- after them.
    set_tab_pinned: (tab: TabId, pinned: boolean) -> (boolean, Error?),
    -- A group of tabs of one window, none pinned, of a name and a color, its tabs next to one another at the first's
    -- place, each out of the group that it was in: its id, given at once. A tab put into a group goes to the end of
    -- its tabs; a tab taken out goes right after them, and a group left of none goes. A folded group hides its tabs
    -- behind its name in the bar; showing one of its tabs unfolds it. `ungroup` takes a group apart, its tabs staying
    -- where they are.
    new_group: (tabs: { TabId }, name: string?, color: Color?) -> (GroupId?, Error?),
    add_to_group: (tab: TabId, group: GroupId) -> (boolean, Error?),
    remove_from_group: (tab: TabId) -> (boolean, Error?),
    rename_group: (group: GroupId, name: string) -> (boolean, Error?),
    set_group_color: (group: GroupId, color: Color?) -> (boolean, Error?),
    fold_group: (group: GroupId, folded: boolean) -> (boolean, Error?),
    ungroup: (group: GroupId) -> (boolean, Error?),
    -- A session of a name, which it switches to, the windows of the active one hidden, their programs running, then
    -- its first window, its pane in `directory`, a path absolute or from `~` of 1024 bytes at most, if given: its id, given
    -- at once. A session goes as its last window closes, unless it is the only one, and as a switch leaves it of no
    -- window, as a second one made in the same call leaves the first, whose window opens not; the active one that goes
    -- leaves the one used before it active · Since 1.5.
    new_session: (name: string?, directory: string?) -> (SessionId?, Error?),
    switch_session: (session: SessionId) -> (boolean, Error?),
    -- Require `workspace-write` and `pty-write`: a window's typed input sent to `to` beside the pane that has its
    -- keyboard, each key encoded of each pane's own terminal's modes, a pane of a program that ended taking none; a
    -- pane left out, which takes its own input alone, or taken back in · Since 1.5.
    set_broadcast: (window: WindowId, to: BroadcastTo) -> (boolean, Error?),
    set_pane_broadcast: (pane: PaneId, left_out: boolean) -> (boolean, Error?),
    activate_tab: (tab: TabId) -> (boolean, Error?),
    focus_pane: (pane: PaneId) -> (boolean, Error?),
    move_tab: (tab: TabId, window: WindowId, index: number) -> (boolean, Error?),
    -- The tab's panes beside a pane of another tab, at its edge, the tab's layout whole in that half, half and
    -- half: the tab goes, its programs running on, its window closing if it has none left.
    tab_into_pane: (tab: TabId, pane: PaneId, edge: "left" | "right" | "top" | "bottom") -> (boolean, Error?),
    -- A window of its own, its content's corner at `at` on the screens, from the menu bar's screen's top
    -- left corner, where it is given; a tab alone in its window stays, its window moving to `at`.
    tab_to_new_window: (tab: TabId, at: { x: number, y: number }?) -> (boolean, Error?),
    pane_to_new_tab: (pane: PaneId, window: WindowId, index: number) -> (boolean, Error?),
    pane_to_new_window: (pane: PaneId) -> (boolean, Error?),
    -- Moves an edge by `by`, a share from -1 to 1 of the room of the split whose divider it is.
    resize_pane: (pane: PaneId, edge: Edge, by: number) -> (boolean, Error?),
    -- A pane's grid, as its window last laid it out, as a resize by cells reads it.
    pane_grid: (pane: PaneId) -> ({ columns: number, rows: number }?, Error?),
    -- A pane's title, as its header shows it: its program's, or, of `process-read`, its folder and its program.
    pane_title: (pane: PaneId) -> (string?, Error?),
    -- A pane's title of its parts, of `process-read`: the name of the program in its foreground, the title that its
    -- program gave it, of OSC 0 or 2, and its folder, the one that its shell told of this machine, of OSC 7, or else
    -- the system's, its home as `~`; each nil where Lokyr knows it not · Since 1.7.
    pane_label: (pane: PaneId) -> ({ program: string?, title: string?, folder: string? }?, Error?),
    -- The panes that have not their tab's keyboard, of a tab of more than one, faded toward their background by this
    -- share, from 0 to 1, their text, lines and cells' backgrounds, while the plugin runs; the most that the plugins ask.
    set_inactive_dim: (dim: number) -> (boolean, Error?),
    -- The panes of a tab of more than one shown as cards, or plain, edge to edge, while the plugin runs: as cards
    -- unless a plugin asks for them plain · Since 1.7.
    set_pane_look: (look: "cards" | "plain") -> (boolean, Error?),
    -- The plugin's own icons of programs, a program's name in lowercase to one of the host's icons, over Lokyr's, of
    -- the headers of the panes that Lokyr draws, a floating pane's, while the plugin runs: 256 at most, a name of 64
    -- characters at most; the last that it gives · Since 1.7.
    set_program_icons: (icons: { [string]: string }) -> (boolean, Error?),
    -- The keyboard goes to the pane that the pointer comes over, while the plugin runs, as any plugin asks.
    set_focus_follows_mouse: (on: boolean) -> (boolean, Error?),
    -- The commands' blocks of every pane drawn so, while the plugin runs, each look that any plugin asks: the gutter's
    -- bar of a command along its block's rows (`bars`), a hairline at the top of each block, across the pane, of the
    -- theme's `blocks.divider` (`dividers`), a failed block's rows tinted of `blocks.failed` (`failed_tint`), and the
    -- prompt rows of the block whose rows the view's top shows pinned over the view's first rows once the prompt's first
    -- row leaves the view's top, three at most, which the block's end pushes up, a line of `blocks.divider` under them,
    -- which a click scrolls to the prompt (`prompt_rows`), and a blank row before each prompt that follows a command that
    -- ended, which the terminal puts there as the prompt's mark comes, of no block, the divider through its middle and the
    -- blocks' tints meeting there, none before the first prompt nor at the screen's top (`spacing`) · Since 1.4. While a
    -- block's command runs and the view shows the screen, its pinned rows stay as its output scrolls and go once its
    -- program draws at the screen's top (`"auto"`, the default), stay over that too (`"always"`), or go while it runs
    -- (`"never"`), each plugin's that is not `"auto"` winning (`header_while_running`) · Since 1.7.
    set_block_looks: (looks: { bars: boolean?, dividers: boolean?, failed_tint: boolean?, prompt_rows: boolean?, spacing: boolean?, header_while_running: ("auto" | "always" | "never")? }) -> (boolean, Error?),
    -- Selects the block of a pane's command, by its id, or none: the host tints its rows, of the theme's
    -- `blocks.selected.bg`, and the keys' context holds `namespace.selected` while the pane has the keyboard, until the
    -- plugin selects another or none, or a key that the program takes, a text typed or a click in the pane ends it;
    -- of a command that the pane keeps · Since 1.4.
    select_block: (pane: PaneId, command: number?) -> (boolean, Error?),
    -- Requires `history-read`: the command whose block the plugin selected in a pane, while the selection lasts, as
    -- `shell_commands` gives it · Since 1.4.
    selected_block: (pane: PaneId) -> (ShellCommand?, Error?),
    -- Swaps two panes of one tab, each taking the other's room, the tab's keyboard staying with its pane.
    swap_panes: (pane: PaneId, with: PaneId) -> (boolean, Error?),
    -- The split at `path`, the parts from the layout's top, takes the first part's share `ratio`, or its panes'.
    set_ratio: (tab: TabId, path: { Side }, ratio: number?) -> (boolean, Error?),
    equalize: (tab: TabId) -> (boolean, Error?),
    zoom: (tab: TabId, pane: PaneId?) -> (boolean, Error?),
    -- A window, its pane in `directory` and of `environment`, as `new_tab`'s, if given.
    -- Its environment · Since 1.6.
    open_window: (directory: string?, environment: { [string]: string }?) -> (boolean, Error?),
    -- A quick window of a new pane, which shows at `place` over every app's windows and takes the focus, its pane in
    -- `directory`, if given: its id, at once. With `global-hotkey`. The plugin's own, which closes as the plugin stops,
    -- shown first if hidden, of the close's question of a program that runs.
    open_quick_window: (place: QuickPlace, directory: string?) -> (WindowId?, Error?),
    -- Shows one of the plugin's quick windows at `place`, which takes the focus, or hides it, of nil, the app that had
    -- the focus taking it back. With `global-hotkey`.
    show_quick_window: (window: WindowId, place: QuickPlace?) -> (boolean, Error?),
    close_window: (window: WindowId) -> (boolean, Error?),
    quit: () -> (boolean, Error?),

    -- The views and the panels.
    request_render: (view: ViewId) -> (boolean, Error?),
    -- Sets the text of a field of the view, by its key, cut to the field's 10 000 characters: its caret at its end, and no
    -- "input-changed"; of the revision of the "input-changed" that it answers, so that it is not set over the keys typed since.
    set_text: (view: ViewId, key: string, text: string, revision: number) -> (boolean, Error?),
    -- Moves the selection of a list of the view, by its key, to an item, which the list scrolls to; of a view that the
    -- same call renders, of the list of its new tree, as the host shows it.
    select: (view: ViewId, key: string, item: number) -> (boolean, Error?),
    -- Scrolls the nearest scroll area around a node of the view, by its key, as little as shows it, once the view shows
    -- it, as a tab bar shows its active tab: the node of a render yet to show too.
    reveal: (view: ViewId, key: string) -> (boolean, Error?),
    -- Gives the keyboard's focus to a node of the view, by its key, which tells it "focus": a field selects all of its
    -- text, as macOS's does as it becomes the first responder, so that typing replaces it; of a view that the same
    -- call renders, a node of its new tree, as the host shows it.
    focus_node: (view: ViewId, key: string) -> (boolean, Error?),
    -- Opens a panel, by an id of the plugin's, which the host then renders; a "panel-closed" event tells as it closes.
    -- A dialog or a menu takes the keyboard as it opens, at its first field, or at its first node that takes it.
    open_panel: (id: string, options: PanelOptions) -> (boolean, Error?),
    -- Closes it at once, so that the same call can open it again; its tree goes, and its plugin hears "panel-closed", as
    -- the call returns: a call that fails, or a look of `applies`, leaves it open, of its tree.
    close_panel: (id: string) -> (boolean, Error?),
    -- Puts the plugin's tab bar, in the windows that show it, in the titlebar, below a titlebar of the window's title,
    -- at the bottom, or down a column on a side of 60 to 600 points; `tab_bar_place` reads it, a column's width as a
    -- drag of its edge left it, as the bar's view lays its tabs out across or down.
    set_tab_bar_place: (place: BarPlace) -> (boolean, Error?),
    -- Puts the plugin's view of the status bar on a side, "start", "center" or "end", in place of its manifest's
    -- `[contributes.status-bar] side`, until it stops; of no capability, as it moves its own view alone
    -- · Since 1.4.
    set_status_bar_side: (side: StatusBarSide) -> (boolean, Error?),
    -- Puts the plugin's tab bar of one window at its own place, over the place of every window, as a window of a
    -- single tab shows its title in its titlebar; nil gives it that place again.
    set_window_tab_bar_place: (window: WindowId, place: BarPlace?) -> (boolean, Error?),
    tab_bar_place: () -> (BarPlace?, Error?),
    -- The keys that run a command of its arguments, one key that no later binding takes, as the platform writes them,
    -- as "⌘1"; none without a binding.
    keys_of: (command: string, args: { [string]: any }) -> (string?, Error?),
    -- Asks for a text, in an alert on `window`, or on the focused one, of a field that holds `text`:
    -- returns the question's id, and the answer comes as an "answered" event. The message and the detail are
    -- messages of the plugin's catalogs, shown in the language shown, or the texts themselves where they lack them:
    -- a message of 1 to 256 characters and a detail of 1024 at most, of no control character but the detail's line
    -- breaks nor one that hides the text around it, as a change of direction. The alert of a plugin other than
    -- Lokyr's own names it. A plugin asks one question at a time: another, of a text or of buttons, fails as
    -- `unavailable` until the last one's answer comes.
    ask_text: (window: WindowId?, message: string, detail: string, text: string) -> (number?, Error?),
    -- Asks a question of 1 to 4 buttons, the first the default, in an alert on `window`, or on the focused one: returns
    -- the question's id, and the button chosen, from 0, comes as a "chosen" event, nil as its window closes. Its texts
    -- are messages of the plugin's catalogs, or the texts themselves, bounded as `ask_text`'s, a button's of 64
    -- characters; its alert, and its one at a time, are as `ask_text`'s; the settings window takes Lokyr's own
    -- plugins'.
    ask_choice: (window: WindowId?, message: string, detail: string, buttons: { string }) -> (number?, Error?),
    -- Asks where to save `bytes`, a string, as a file, in the platform's save panel, a sheet on `window` or on
    -- the focused one, of `name` suggested and of its extension's type: returns the question's id, the host writes
    -- the file at the place chosen, the panel having asked before it replaces one, and its path comes as a "saved"
    -- event. No capability, as the place is chosen in the panel and the plugin never holds the disk. The panel
    -- names the plugin over it and shows the whole name, its extension too; the file is marked as come from
    -- elsewhere, as a download is, macOS's quarantine, so that Lokyr and Gatekeeper ask before it opens as a program,
    -- and a volume that keeps no such mark writes nothing. The host writes on a thread of its own; a write that fails
    -- is a notice of the app's too. A window shows one panel at a time, a second refused while one shows, or ended of
    -- an error as it reaches the app after another plugin's; the panel goes, of no write, as its plugin stops, and
    -- ends of no path as its window closes. A name of 1 to 255 bytes, of no `/`, `:`, control character, character
    -- that hides or moves the text around it nor mark of direction; 256 MiB at most.
    save_file: (window: WindowId?, name: string, bytes: string) -> (number?, Error?),
    -- Shows `text` in Lokyr's notice card, at the panes' top right, as the app's own notices: of the icon and the color
    -- of `level`, "info" by default (the accent's info), "success" (a green check), "warning" (a yellow warning) or
    -- "error" (a red error), and of `title` beside the plugin's namespace, or the namespace alone, with the card's
    -- buttons that copy its text and close it. It goes by itself after 4 seconds, 8 of a warning or an error, unless the
    -- pointer rests on it, and takes the place of the plugin's last notice, the notices under it showing again as it
    -- goes; Lokyr's own notices, as a config that does not read, show over the plugins'. A text of 1 to 1024
    -- characters and a title of 1 to 100, of no control character nor one that hides the text around it; one notice a
    -- second, a second one within it refused. No capability, as the card names the plugin.
    notify: (text: string, level: ("info" | "success" | "warning" | "error")?, title: string?) -> (boolean, Error?),
    -- The text of a message of the plugin's catalogs, of its arguments, a text or a number each, in the language
    -- shown, or English's where that one lacks it, as a view's texts, labels and tooltips take them: the id itself
    -- where the catalogs lack it. A change of the language rebuilds the menus, which `keys-changed` tells.
    message: (id: string, args: { [string]: string | number }?) -> (string, Error?),

    -- The terminal. The reads require `terminal-read`, and return a `denied` error without it.
    selection_text: (pane: PaneId) -> (string?, Error?),
    -- The logical line of a row, by its number, its wrapped rows joined as far as `reach` rows before it and after it, 256 at most, with each character's cell.
    line_text: (pane: PaneId, row: number, reach: number) -> (LineText?, Error?),
    -- The target of the OSC 8 link at a cell, by its row's number.
    link_at: (pane: PaneId, column: number, row: number) -> (string?, Error?),
    -- Reads 100 000 rows at most, from the row numbered `first`, on a thread of the host's, a part at a time:
    -- returns the read's id, and the rows come as a "lines" event. Four of a plugin's reads are under way at most,
    -- past which another fails until one ends; they stop as the plugin stops.
    read_lines: (pane: PaneId, first: number, count: number) -> (number?, Error?),
    -- Searches a pane's terminal, its scrollback too, on a thread of the host's, a part of its rows at a time from the
    -- view's outward: returns the search's id, and the matches come as "searched" events. The plugin's search of the pane
    -- before ends. The host keeps 100 000 matches at most as their cells' pins, through new output, scrolls and reflows,
    -- until the next search of the pane, `end_search` or the pane's close; the count goes on past them.
    search: (pane: PaneId, query: SearchQuery) -> (number?, Error?),
    end_search: (id: number) -> (boolean, Error?),
    -- Shows a search's matches over its pane's cells in the theme's `search.match`, or hides them, as `all` says, and
    -- its current match apart in `search.match.current`, whose row the view scrolls to, as the call returns: the host
    -- draws those that the view shows at each frame, until the search ends. Those of the plugin's search before of the
    -- pane, if they showed, show until this one does. While a current match shows, output leaves the view where it is,
    -- whatever `scroll-on-output` says.
    show_matches: (id: number, all: boolean, current: SearchMatch?) -> (boolean, Error?),
    -- Shows the rows of a search's matches alone in its pane's view of the main screen, with `pane-view`, each run of the
    -- rows between them a blank row, scrolled by whole rows; while it shows, the rows that new output brings are searched
    -- as they come, and the plugin hears the count. `filter` false, or the search's end, gives the view back, at the
    -- current match · Since 1.6.
    filter_matches: (id: number, filter: boolean) -> (boolean, Error?),
    -- A search's matches in the rows' order, from the one at `first`, 100 000 at most, as their cells are now, those that
    -- left the scrollback gone; how many it found; and whether it went to its end.
    search_matches: (id: number, first: number, count: number) -> ({ matches: { SearchMatch }, count: number, done: boolean }?, Error?),
    -- A search's current match as its cells are now, which a resize moves, and its place among the matches now, which
    -- those that leave the scrollback lower; nil of none, or of one that left; and how many matches the host keeps.
    current_match: (id: number) -> ({ current: { place: number, match: SearchMatch }?, kept: number }?, Error?),
    -- The styles of a row, by its number, as runs of cells of one style.
    styles: (pane: PaneId, row: number) -> ({ StyleRun }?, Error?),
    -- The cells of the selection, if there is one, as `render_image` takes them: of each row the columns that it takes,
    -- a rectangle's alike on every row, wide characters whole, their text without the spaces that end it and their
    -- styles, a background that an erase left among them; 1000 rows at most, from its first.
    selection_cells: (pane: PaneId) -> ({ { text: string, runs: { StyleRun } } }?, Error?),
    -- The cells of the rows that the view shows, from its top, likewise.
    screen_cells: (pane: PaneId) -> ({ { text: string, runs: { StyleRun } } }?, Error?),
    -- The cells of `count` rows of the active screen from the row numbered `first`, whole, likewise, as many as the
    -- pane holds from it, 1000 at most, as a command's block's rows; nothing of a first row that it does not hold
    -- · Since 1.4.
    row_cells: (pane: PaneId, first: number, count: number) -> ({ { text: string, runs: { StyleRun } } }?, Error?),
    -- Requires `history-read`: the commands that the shell marked, 10 000 at most kept, whose rows meet the rows
    -- numbered from `top` to before `bottom`, oldest first: the last whose first row is at `top` or above it, whose
    -- output the row `top` may show, and those after it whose first rows are above `bottom`; a command's first row is
    -- its prompt's, or the oldest row of one whose prompt left the scrollback but not its end.
    shell_commands: (pane: PaneId, top: number, bottom: number) -> ({ ShellCommand }?, Error?),
    -- Requires `history-read`: a command's line, as it was typed: as the shell told it, of OSC 133 `C`'s
    -- `cmdline_url`, which a right prompt on its row leaves out, or else the text from its input's mark to its
    -- output's; as the long command's notification takes it.
    command_line: (pane: PaneId, command: number) -> (string?, Error?),
    -- Requires `history-read`: a command by its id, as `shell_commands` gives it; nil of one not kept · Since 1.4.
    shell_command: (pane: PaneId, command: number) -> (ShellCommand?, Error?),
    -- Requires `history-read`: the command whose block holds a row, from its first row to its end's, which is its own
    -- where the end is past its first column and the next prompt's otherwise, or to the next command's first row of
    -- one that has not ended; nil above every command, or past an end before the next command · Since 1.4.
    command_at: (pane: PaneId, row: number) -> (ShellCommand?, Error?),
    -- The view, as its last frame showed it, which "viewport-changed" tells the changes of; no capability, as it tells
    -- no text.
    viewport: (pane: PaneId) -> (Viewport?, Error?),
    -- An image of cells, in the theme's colors and the terminal's font, as a window shows them, in a frame as a
    -- window's, which the host renders offscreen with the terminal's own renderer: its PNG. The window is as wide as
    -- its widest row, of its text and of the cells past it that show something, as a background, and as its bar's
    -- buttons and title need. No capability, as it reads nothing of the app's but the theme and the font: the cells
    -- are the plugin's, as `line_text` and `styles` read them, in the theme's colors and not those that a program set
    -- of its own. 1000 rows of 1000 columns, a row's 4000 characters and a title's 256: the rest left out, the title
    -- shortened. 16 384 pixels a side and 16 million pixels at most: an image past them at its scale drawn at a lower
    -- one, down to 0.5, which `Image`'s `scale` tells, refused past them even there. 4 a call, none of a look, and of
    -- the plugin's budget, 32 million pixels at once, given back at 4 million a second, which each image takes of its
    -- pixels, or of 128 a cell where they are more, though it is refused: as each takes the main thread some
    -- milliseconds. A Luau plugin carries 16 MiB of bytes back to the host, an image's PNG to save or copy among them.
    render_image: (image: ImageSpec) -> (Image?, Error?),
    -- Lets go an image that the host keeps, as the call returns, whose nodes then draw nothing; one that it does not
    -- keep stays so.
    drop_image: (image: number) -> (boolean, Error?),
    -- Decorates the cells from one to another, in reading order, each { column, row's number }: returns the
    -- decoration's id. It keeps its text as output scrolls it and a resize reflows it, and goes with it.
    decorate: (pane: PaneId, from: { number }, to: { number }, look: DecorationLook) -> (number?, Error?),
    undecorate: (pane: PaneId, id: number) -> (boolean, Error?),
    -- Lays a mark of a color, { red, green, blue }, in the pane's gutter, at the left of its cells, on a row by its
    -- number: returns the mark's id. It keeps its row as output scrolls it and a resize reflows it, and goes with it;
    -- it shows over the mark of a prompt of its row, and only while `[window] gutter` is on.
    mark_gutter: (pane: PaneId, row: number, color: { number }) -> (number?, Error?),
    unmark_gutter: (pane: PaneId, id: number) -> (boolean, Error?),
    select_all: (pane: PaneId) -> (boolean, Error?),
    -- Selects the cells from one to another, each { column, row's number }, as `kind` takes them, "cells" by default,
    -- as a drag would, which a copy then takes, and scrolls the view, through the scrollback, to show the last, the end
    -- that a keyboard's selection moves, as the call returns.
    select_cells: (pane: PaneId, first: { number }, last: { number }, kind: SelectionKind?) -> (boolean, Error?),
    -- A cursor of the plugin's over a cell, { column, row's number }, in place of the terminal's, which hides while it
    -- shows, as a mode of the keyboard's over the scrollback moves one: of the terminal's cursor's shape and colors,
    -- still, while the view shows its row, keeping its text as output scrolls it and a resize reflows it; while the
    -- other screen shows, the terminal's; nil gives the terminal's cursor back, as the plugin's stop or fault does.
    show_cursor: (pane: PaneId, at: { number }?) -> (boolean, Error?),
    -- Takes the selection away, as a click would.
    deselect: (pane: PaneId) -> (boolean, Error?),
    -- The cell of the terminal's own cursor, { column, row's number }.
    cursor_cell: (pane: PaneId) -> ({ number }?, Error?),
    clear_scrollback: (pane: PaneId) -> (boolean, Error?),
    clear: (pane: PaneId) -> (boolean, Error?),
    -- Require `pty-write`: a paste, as ⌘V's, whose text of line breaks may ask for a confirmation first,
    -- and text sent as typed.
    paste: (pane: PaneId, text: string) -> (boolean, Error?),
    -- A paste as ⌘V pastes into a pane: into it, and into the other panes that its window broadcasts the input
    -- to, each bracketed as its program asks, of one question for all where one is asked; `paste`, `send_text` and
    -- `run_line` reach their pane alone · Since 1.5.
    paste_broadcast: (pane: PaneId, text: string) -> (boolean, Error?),
    send_text: (pane: PaneId, text: string) -> (boolean, Error?),
    -- A key sent to `pane`'s program, pressed and released, with `pty-write`, as the keyboard encodes it of the modes
    -- that the program asked for: one combination as a binding writes it, as `ctrl+c`, `up` or `shift+tab`, of no
    -- click nor wheel. Option acts as Meta; Command reaches a program of the keyboard protocol alone · Since 1.6.
    send_key: (pane: PaneId, keys: string) -> (boolean, Error?),
    -- A mouse event sent to `pane`'s program over a cell of its screen, with `pty-write`: `action` `press`, `release`,
    -- `move`, `scroll-up`, `scroll-down`, `scroll-left` or `scroll-right`, its `button` (`left` for none of a press),
    -- `column` and `row` from 0, `shift`, `control` and `alt`, and a scroll's `steps`, 1 to 100; as the program's
    -- modes encode it, a program of no mouse scrolling the pane's view of the wheel alone · Since 1.6.
    send_mouse: (pane: PaneId, input: MouseInput) -> (boolean, Error?),
    -- A key pressed in `pane` as the user presses it, with `user-commands` and `pty-write`: the pane takes its window's
    -- keyboard, and a binding of `keys` in its context runs its command, as `cmd+a` selects all; another key goes to
    -- the program as `send_key` sends it · Since 1.6.
    press_key: (pane: PaneId, keys: string) -> (boolean, Error?),
    -- Text sent as the user's keys reach a pane: to it, and to the other panes that its window broadcasts the input
    -- to, as `send_text` sends it to one, as `pane.send-text`'s keys send it · Since 1.5.
    send_text_broadcast: (pane: PaneId, text: string) -> (boolean, Error?),
    -- Requires `terminal-read`: the command line that the shell edits at its prompt, as its cells show it, after its
    -- input's mark and before its output's (OSC 133), of no right prompt, its lines apart, without the spaces that end
    -- it; "" of nothing typed; nil while a command runs, a program's own screen shows, or the shell marks no prompt ·
    -- Since 1.4.
    edited_line: (pane: PaneId) -> (string?, Error?),
    -- Requires `pty-write`: a command line run at the shell's prompt, pasted, bracketed as the program asks, and
    -- Return, of no confirmation, while the shell edits an empty command line, as `edited_line` tells it; refused,
    -- `unavailable`, otherwise, and of a line of nothing but spaces · Since 1.4.
    run_line: (pane: PaneId, line: string) -> (boolean, Error?),
    scroll: (pane: PaneId, scroll: Scroll) -> (boolean, Error?),
    -- The text's size, in points, of every window, from 4 to 200, or the config's with none.
    font_size: () -> (number?, Error?),
    set_font_size: (size: number?) -> (boolean, Error?),

    -- Require `process-read`: the directory of the program in the pane's foreground.
    working_directory: (pane: PaneId) -> (string?, Error?),
    -- Requires `process-read`: the branch of the git repository that holds the folder of the absolute path `folder`,
    -- as its `HEAD` tells, which Lokyr reads up from the folder, a worktree's too, without running git; a detached
    -- head's short hash; nothing out of a repository · Since 1.4.
    git_branch: (folder: string) -> (string?, Error?),
    -- Requires `open`: a URL of `http`, `https`, `mailto` or `file`, a `file` URL of this machine alone, of no host,
    -- `localhost` or its name, as OSC 7's folder, or a path from `/` or `~`.
    open: (target: string) -> (boolean, Error?),
    -- Whether `open` would open `target`: a URL of its schemes, or a path that is there.
    opens: (target: string) -> (boolean, Error?),
    -- Opens the file `target`, a path or a `file` URL, at its `line` and `column`, from 1, in the editor that the config's
    -- `[links] editor` names, of the editor's address, or as `open` does where it names none; of `open`.
    open_at: (target: string, line: number, column: number?) -> (boolean, Error?),
    -- Require `clipboard-read` and `clipboard-write`.
    clipboard_text: () -> (string?, Error?),
    set_clipboard_text: (text: string) -> (boolean, Error?),
    -- An image on the clipboard, a PNG of its signature, in place of what it held, 256 MiB at most.
    set_clipboard_image: (bytes: string) -> (boolean, Error?),
    -- Requires `keep-awake`: keeps the system ("system"), or the system and the display ("display"), from idle sleep,
    -- or lets it sleep ("off"), as the call returns. The host holds one power assertion for every plugin, the
    -- strongest that one asks, which `pmset -g assertions` lists of the plugins' names, and releases it as the last
    -- lets go, stops, faults or is turned off.
    keep_awake: (awake: "off" | "system" | "display") -> (boolean, Error?),
    -- Requires `packages`, Lokyr's own plugins' alone: a job of the packages' service, the bundle's Sleip of `--json`,
    -- as the call returns, of its id, whose lines come as `package` events and whose end as `packages-ended`, to the
    -- plugin alone; a name is `owner/name`, a search or a constraint 256 bytes at most, never starting with `-`, an
    -- empty search every plugin of the registry.
    packages: (call: "list" | { search: { query: string } } | { info: { plugin: string } }
        | { add: { plugin: string, constraint: string? } } | { update: { plugin: string? } }
        | { remove: { plugin: string } }) -> (number?, Error?),
    -- Ends a job that runs, of no success.
    cancel_packages: (job: number) -> (boolean, Error?),
    -- Requires `packages`: the plugins, built in and installed, in the order of their activation, each of its name,
    -- its namespace, its version, its manifest's description, whether it is built in, its state, "waiting", "active", "off", "faulted" or
    -- "replaced", its fault, the plugin that replaces it, `replaced_by`, while one does, and its manifest's capabilities, each of the decision on it, "granted", "refused" or "undecided".
    plugins: () -> ({ PluginInfo }?, Error?),
    -- Requires `packages`: turns a plugin, by its name, on or off, as its section of the config,
    -- `[plugins.<namespace>] enabled`, which the host writes as the call returns, keeping the rest of the file; the
    -- plugin stops at once, or starts anew.
    set_plugin_enabled: (plugin: string, enabled: boolean) -> (boolean, Error?),
    -- Shows the settings' window at a page of the plugin's own, by its manifest's id, opening it or bringing it
    -- forward, as the call returns: its view renders, and the plugin hears `page-shown`. Lokyr's own plugins' alone,
    -- as their manifests have pages; another page is not found.
    show_page: (page: string) -> (boolean, Error?),
    -- Requires `config`, Lokyr's own plugins' alone: the settings, the config's sections of its schema, in its order,
    -- then each plugin's of a config schema, in the plugins' order, whether its plugin runs as the config says,
    -- `enabled` · Since 1.4; each key of its name, its description, its
    -- platforms, its kind ("boolean", a number of its range, step and whether it is whole, a text of its fewest and
    -- most characters and the values that it suggests, a choice of its values, a list of texts, or another), its
    -- control, its default, its value in force and the address of its text in the config guide; the bindings of keys
    -- in force, the defaults of the keymap that the config leaves and then the config's `[keys]`, each of its keys as
    -- the config writes them, its command, the command's title and category, its arguments and context, whether it is
    -- a default, whether it is macOS's own, of its app menu (Quit's `cmd+q`, Settings' `cmd+,`), whose keys a write
    -- refuses but their default given back, and whether the file tells more of it, keys that the config takes away of no command and of the
    -- default's title and category; and what is
    -- wrong with the config file where it does not read, its message, line and column, the settings then those that
    -- applied last.
    settings: () -> (Settings?, Error?),
    -- Requires `config`, Lokyr's own plugins' alone: writes a key of the settings into the config file, of a section
    -- as the settings name it, an app's of no plugin or a plugin's of its name, keeping the rest of the file and its
    -- comments, as the call returns, the config applying anew; a value that the key does not take, as the parser or
    -- the plugin's schema tells it, fails at once, nothing written; of no value, the key goes, back to its default.
    -- The section `keys` binds keys, any as the parser reads them, to a command that the app has, or `false`. A
    -- plugin's section's `enabled`, `true` or `false`, turns the plugin on or off, as the Plugins page does, written of
    -- the plugin's own default, its section's `enabled` in the settings telling it · Since 1.4. Nothing is
    -- written over a file that does not read.
    set_setting: (section: string, plugin: string?, key: string, value: Data?) -> (boolean, Error?),

    -- The plugin's config, its section's values with its schema's defaults; its state, of plain values,
    -- 1 MiB at most as JSON, kept for the next run, as the call returns.
    config: () -> (any, Error?),
    state: () -> (any, Error?),
    set_state: (value: any) -> (boolean, Error?),

    -- Declarations, at once: a timer of the host's time, which fires once `delay` milliseconds passed, from 10 ms, a
    -- shorter delay waiting 10, to a day, and again at each delay after, if it repeats: its id, of its "timer" events.
    -- 64 of a plugin's at most; they end as it stops. A cancelled timer's events come no more, the one that it owes
    -- neither; one that is not there stays so.
    start_timer: (delay: number, repeats: boolean) -> (number?, Error?),
    cancel_timer: (timer: number) -> (boolean, Error?),
    -- Require `global-hotkey`: hears the double tap of a modifier from any app, in place of the one before, or of none
    -- for nil: `double-tapped` comes to the plugin alone as the modifier is pressed and let go of alone twice within
    -- the system's double-click interval; it ends as the plugin stops. macOS asks to allow Lokyr in Input Monitoring the
    -- first time, which Lokyr tells; Lokyr reads the modifiers alone.
    watch_double_tap: (modifier: ("ctrl" | "alt" | "cmd" | "shift")?) -> (boolean, Error?),
}

-- What a plugin's entry module returns.
type Plugin = {
    activate: ((cx: Cx) -> ())?,
    on_event: ((cx: Cx, events: { Event }) -> ())?,
    on_command: ((cx: Cx, name: string, args: Args) -> ())?,
    -- Whether a command would do something with `args`, as a menu asks before it dims its item; what
    -- the call asks of the app is dropped. Without it, every command would.
    applies: ((cx: Cx, name: string, args: Args) -> boolean)?,
    render: ((cx: Cx, view: ViewId) -> View?)?,
    on_ui_event: ((cx: Cx, event: UiEvent) -> ())?,
}

Commands

Capabilities

CapabilityAllowsRisk
(none)Registering commands, and running those that the manifest declares; keymap, events, UI, themes, config, storage, logging, timers—
terminal-readReading screen and scrollback text, and the selectionHigh: the screen may show secrets
pty-writeSending input to the shellVery high
clipboard-readReading the clipboardHigh
clipboard-writeWriting to the clipboardMedium
notificationsShowing system notificationsLow
openOpening URLs and files with the system handlerMedium
process-spawnStarting processes; refused before 1.0.0, with a noticeVery high
net:<host>HTTP requests to the listed hosts, whatever their case; refused before 1.0.0, with a noticeHigh
fs-read:<path>, fs-write:<path>Access to the listed paths and to the paths under them, of whole components and no ..High
global-hotkeySystem-wide shortcuts, bindings of global: keys, a modifier's double tap from any app, watch_double_tap, and quick windows, which slide in over every app'sMedium
env-read:<name>Reading the listed variables of the app's environment and of the panes' programs', with * as AWS_*High: they often hold secrets, as GITHUB_TOKEN
input-readSeeing the keys typed before they reach the programVery high: a keylogger's power
history-readReading the commands that the shell ran and their output, which shell integration marks, and hearing their starts and ends of their exit statuses, as shell_commands, shell_command, command_at, command-started and command-endedHigh: a password typed by mistake ends up there
process-readSeeing the panes' processes: their command lines and working directories, a command's folder among them, the git branch of a folder, git_branch, and what their programs tell of their state, as an agent's and a session's status; hearing as a command that the shell marked starts and ends, command-started and command-ended, of no exit status · Since 1.4Medium: command lines can hold passwords
workspace-writeOpening, closing and moving windows, tabs and panes, a closed tab kept and given back, tabs pinned and grouped, sessions made and switched, the typed input broadcast to a tab or a window, with pty-write, the keyboard's focus between them, a split's ratio, the panes equalized and swapped, the zoom, and the app's quitHigh: it can end every program, start shells, or move the keys typed to another pane
pane-viewThe panes' scroll and selection, the screen and the scrollback cleared, the font's size, the tabs' titles and colors, the tab bar's place, the inactive panes' fade and the focus that follows the mouseMedium: a cleared scrollback is lost text, and a selection is what a copy takes
decorateDrawing over a pane: decorations and their labels, the gutter's marks, a search's matches and a held cursorMedium: a drawing over the text can show what the terminal does not hold
pointer-readThe pointer event: the cell under the pointer over the panes, and the modifiers held; the click event, a plain click on a pane's cell, and the prompt-rows-menu event, a context click on a block's pinned prompt rows · Since 1.4Low
keep-awakeKeeping the system, or the system and the display, from idle sleep, keep_awake, of a power assertion that the host holds for every plugin together, the strongest that one asks, and releases as the last lets go, stops, faults or is turned offHigh: a display kept awake keeps the screen from locking, and of a battery's cost
configThe config in force, the app's keys and every plugin's section with their schemas, settings, and their changes, settings-changed; its keys written into the file, set_setting; a theme copied into the themes folder, copy_theme, a new one there, new_theme, or an .itermcolors one there converted, convert_theme, each once its question is answered, and a theme's colors there written, set_theme_value, or shown before they are, preview_theme_value; Lokyr's own plugins' alone, refused to another's manifest with a notice and by sleip checkVery high: a key written can change the program that a pane runs
packagesThe plugins themselves, through the bundle's Sleip: the installed ones, the registry's search and a plugin's versions, installs, updates and removals, packages, of their lines as events, and cancel_packages; every plugin's state and capabilities' decisions, plugins, and a plugin turned on or off in the config, set_plugin_enabled; Lokyr's own plugins' alone, refused to another's manifest with a notice and by sleip checkVery high: a plugin that installs another runs code of its choice
user-commandsRunning any command as if run by hand, without declaring it, as the palette does; reading the whole registry, with each command's plugin, keys and context, the plugins installed, and the menu bar's items, menu_bar_items; a key pressed as the user presses it, press_key, with pty-write · Since 1.6Very high: pane.send-text types into the shell
appearance-writePreviewing a theme, a monospaced font family and a face's style, and naming the ones chosen in the config's [theme] and [font] family, edited in place, preview_theme, set_theme, preview_font, preview_font_style and set_font, as the palette's theme picker and a font picker doMedium: the config changes, visibly and reversibly; no text of a pane, no command, no file but the config's two keys

A request takes every capability that it needs, as a subscription to pointer and to command-started takes pointer-read and history-read or process-read. The reads of the workspace, the plugin's own views, panels and questions, its declarations, its config and its state take none; neither does a file saved through the save panel, where the place is chosen in the panel and the host writes it, nor an image of the plugin's own cells.

Lifecycle

installed ──▶ resolved ──▶ consent ──▶ loaded ──▶ active
                               ▲                     │ error / deadline / panic
                               │                     ▼
                         re-enabled ◀── disabled ◀── restart with backoff

Limits and isolation

Native code and the hardened runtime

First-party plugins

PluginRolePhase
core-actionsCopy, paste, select all, scrolling, font size, new windowsF2
links⌘-click opens a link, a URL or a path of the text, file:line in the editor; later hints and smart selectionF2, F5a, F5c
tabsiTerm2-style tab bar and tab commandsF3
splitsSplit commands, dividers and interactionF3
searchFind bar and search commandsF3
keymap-macosDefault macOS shortcuts, as iTerm2's: the keys of the app's commands and of the other plugins', which bind none of their ownF3
keymap-linuxDefault Linux shortcutsF7
command-paletteCommand palette and theme pickerF3
settingsThe settings' window's first page, Settings: every key of the config and of the plugins' sections, of the config's schema and the plugins', by its section, of its value in forceF3b
plugin-managerThe settings' window's Plugins page, of the packages' service: every plugin of its state, active or disabled, and its capabilities' decisions, disabled, enabled, updated or removed, and the registry's plugins, filtered, of their versions and capabilities, to install, Lokyr › Plugins…F3b
automationWhat scripts and shortcuts of other apps ask, which the host's bridges of the system hand it as the automation event, of the capability automation: windows, tabs and splits opened in a folder and running a command line, text sent, a window, a tab or a pane brought forward or closed, a command of the registry run, the workspace's windows, tabs and panes by their ids, and a pane's text after a question for each app, kept in its state; enabled = false turns the automation off · Since 1.6F5b
blocksCommand + output blocks, over the prompts' marks that the kernel keeps since F3: the command's header of command-header's module, which both crates hold by its path, and its button to the block's end; it replaces command-header ([plugin] replaces), off by default ([plugin] enabled-by-default = false) · Since 1.4F5a
quick-terminalThe quick terminal: its command, which shows and hides its quick window, its autohide and its place, of [plugins.quick-terminal], through the quick windows and the global keys of global-hotkeyF3
progressThe programs' progress (OSC 9;4), in the window-strip slot; the tab shows it with tabsF3
command-headerThe command whose output the view shows, at the pane's top, a pill of its line on a hairline across the pane, in an overlay of the pane's top, over OSC 133's marks, as iTerm2'sF3
copy-modeThe keyboard's selection over the screen and the scrollback, as tmux's and vim'sF3
tmux-cc, profilesiTerm2 power features; the broadcast, since 1.5, and the triggers, of 1.7, are Lokyr's own, of no pluginF5b
imagesInline imagesF5c

Rules (details in ARCHITECTURE.md):

Distribution

The "distribution" is the list of first-party plugins compiled into the app.

# dist/default.toml
[distribution]
name = "default"

[plugins]
keymap-macos    = { path = "../plugins/keymap-macos", target = "macos" }
keymap-linux    = { path = "../plugins/keymap-linux", target = "linux" }    # from F7
core-actions    = { path = "../plugins/core-actions" }
links           = { path = "../plugins/links" }
tabs            = { path = "../plugins/tabs" }
splits          = { path = "../plugins/splits" }
search          = { path = "../plugins/search" }
command-palette = { path = "../plugins/command-palette" }
plugin-manager  = { path = "../plugins/plugin-manager" }   # from F3b
automation      = { path = "../plugins/automation" }       # from F5b