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 plugins | Third-party plugins | |
|---|---|---|
| Form | Rust crate in plugins/, statically linked | Luau scripts, each plugin in its own sandboxed VM |
| Loading | At startup, from the distribution (dist/*.toml) | From disk (installed by Sleip), only when needed |
| Trust | Our own reviewed code | Sandboxed: only the capabilities granted to it |
| Cost | Direct calls, zero overhead | One Luau VM (about 1–2 MB when active); calls copy data |
| API | plugin-sdk, the Rust front end | The Luau front end of the same API |
| Failures | catch_unwind at the boundary; the plugin is disabled | Lua error, memory limit or missed deadline; the plugin is disabled and restarted with backoff |
Extension points
| Area | What a plugin can do | Examples | Phase |
|---|---|---|---|
| Commands | Register and run commands with typed arguments; add menu and palette entries | tabs.new, search.open | F3 |
| Keymap | Bindings with a context (when), chords and leaders, modal key tables | cmd+f → search.open when a pane has focus | F3 |
| Events | Receive kernel events (batched) and emit its own | tab-created, layout-changed, pointer, search.progress | F3 |
| Workspace and layout | Create, close and move tabs and panes; edit the layout tree | split, zoom, move to a new window | F3 |
| UI | Provide view trees for slots | tab bar, find bar, status bar segments | F3 |
| Terminal | Read 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 services | highlight matches, gutter marks, a command's header | F3 |
| Config | A [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 |
| Storage | A 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 returns | search history | F3 |
| System | Clipboard, 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 finishes | F3; processes and the network F6 |
| Protocols | Handlers for rare OSC/DCS/APC sequences | iTerm2's OSC 1337 | F5 |
| Triggers | Regexes over completed lines, with batched callbacks; the config's own triggers, of no plugin, come first, in 1.7 (Triggers) | highlight ERROR in red | Later |
UI slots
| Slot | Providers | Used for | Region |
|---|---|---|---|
tab-bar | One, chosen in the config | The tab bar | In 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-buttons | Many, side by side, three at most | A button of an icon beside the window's, as a toggle of a state that a plugin keeps | In 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-bar | Many, on three sides | Status information | Across 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-strip | Many | A thin strip across the window's top, under the titlebar or the tab bar: the programs' progress | Across the panes' top, over them, taking none of their rows |
pane-header | One | Pane titles in splits | Across 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 |
sidebar | Many (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.
- Short calls, of messages:
- The kernel calls into the plugin (
activate,on_event,on_command,render,on_ui_event), and the plugin sends the host requests,plugin-sdk'smessage::Call, each with its identity and the capability that it needs, which the host answers with aResponse. The host checks the capability against the plugin's: a built-in plugin has every one until its manifest says which; a call that comes as another plugin's fails. - Long-running work goes to asynchronous host services (search, timers, processes), whose results come back as events.
- The kernel calls into the plugin (
- Reads at the host's time: a request reads the main thread's state as the host handles it; an id that is gone gives
not-found. A read of much text runs on a thread of the host's, which holds a pane's lock as briefly as a frame's copy. - Writes queued, for every plugin: what a plugin changes, the kernel's state and the app's, the host applies in order as the plugin's call returns, on the main thread as on a worker and in Luau; plugins never change the state in place. A write to a pane that is not there fails as it is asked; one to a tab or a pane that an earlier write of the call opens, of the ids that its request gave, finds it, as the writes apply in their order, so that a call opens a tab and activates it. The kernel's writes, as a selection, a paste or the clipboard's text, come first, then the app's requests, as a window to open or a command to run; a read in the same call reads the state before the call's writes. A call that returns an error, or panics, leaves things as they were: its writes, its requests of the app and its reads of rows go, the timers that it started too, those that it cancelled coming back, and the ids that it was given name nothing. A plugin's declarations, its commands, its keys, its subscriptions and its timers, take effect at once, as the host checks them; a call that only looks, as
applies, declares nothing. - Owned data: plugins receive copies, never references into kernel state.
- No re-entrancy: events generated during a callback are queued and delivered only after the callback returns; those that a delivery's calls emit, in the next batch.
- No threads of their own, no blocking I/O: time is the host's, of the timers that a plugin starts,
cx.start_timer, of a delay and whether it repeats, and cancels,cx.cancel_timer, whosetimerevents come to it alone, which no subscription needs, once however many times a timer fired since the plugin last heard of it; a plugin of a thread of its own hears of them once its thread is free, so that a timer that its call under way cancels tells it nothing. A timer that repeats and falls behind, as the app was busy, waits its delay again from the time that it fires; its plugin's timers end as it stops. The app wakes for the next of them alone, none while no timer waits. - Filtered, batched events: a plugin subscribes to the events that it names,
cx.subscribe, the workspace's, astab-created, and plugins' own,namespace.event; the kernel gathers the workspace's changes and the events that plugins emit, and delivers them toon_eventin their order, each plugin those that it subscribed to, as a batch, once a turn of the main thread, which a frame, a key, a click or a wake is. - Rendering:
render(view), of a view of the plugin's, a slot of a window or a pane that its manifest declares, or one of its panels, is called as a window or a pane shows the slot, as a panel opens, as the plugin asks for an update (request_render) and as the theme changes. The result is cached, and stays as the plugin is disabled, so that the windows' layout does not jump: the view takes no event then, and a notice of the windows tells that the plugin stopped, its error in the log. A view of a window or a pane that closed goes with it.- Native plugins run on the main thread, unless their manifest asks for a thread of their own,
thread = "worker": each such plugin then has a thread of the host's, which makes all its calls, its renders too, with the same messages as a Luau plugin's, and the host takes their results on the main thread as they are ready, never waiting for them; a call of the main thread's plugins that takes long is logged as it returns, and stopped by nothing, as the plugins are ours. The main thread stays for the plugins that must answer at once, as the tab bar's. Luau plugins run on the plugin executor, with a deadline per call. - A plugin on its thread, one each, which waits on a channel at rest, without a wakeup: the thread starts as the plugin activates, and makes one call at a time; the host keeps each call's writes, which it applies as the call returns, as for a plugin of the main thread.
- Each request crosses to the main thread, whose turn answers it with the state as it is then, and the plugin's thread waits for the answer: a request costs a turn of the main thread, its wake included. A turn takes the threads' messages for 1 ms at most, each plugin's in turn, those left for the next turn, so that frames and keys come between.
- What the host asks of it meanwhile waits for the call under way: the events of the deliveries join one batch, and a render of a view whose render is under way or waits is not asked again; the plugin's own
request_renderwithin its render brings the next. - A call reads the focus of the time that it was asked, as it would have run then on the main thread, a context menu's command its window's. The events posted as the plugin activates wait for its activation's end, whose requests make its subscriptions, and come then; its commands, registered as its activation's requests are served, take their catalogs' titles and show in the menus then. The commands that its command runs are one deeper than it, whenever its call ends, so that a command that runs itself stops at the same depth as on the main thread.
- A view shows its last tree until its render comes, and nothing before the first; a render that ends once its view went keeps nothing. A menu's question of whether its command applies is not asked of it, as the main thread does not wait: its commands apply.
- A command's failure is told as its call ends, as one of the main thread's is; a panic disables the plugin, whose thread ends, and its call's writes go.
- A slow call of a plugin on the main thread, of 8 ms or longer, a frame's time at 120 Hz, goes to the log by the plugin's name and its callback, as
on_command. - If a Luau plugin misses its deadline, the last valid view tree stays on screen.
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
- Rust front end:
Cx's methods make the requests, which the host serves in place for a plugin of the main thread and through a channel for a worker's.export_plugin!(T)generates a registration function, whichxtask gen-distwires into the app.- The host's API and the
Plugintrait come withplugin-sdk'sunstablefeature while they grow. - A command's calls come to the plugin's
on_command, by the command's name, as in Luau: only data crosses the boundary, never code or references into the kernel's state. A table of handlers, one a command, can come later inside the SDK, overon_command, without changing the host. - A render and a look of
appliesreturn no error: a plugin whose code can fail there, as a Luau plugin's, tells it after the call throughtake_failure, which the host and the fake host take as a call's error, a fault faulting the plugin. - What changes the kernel or the app, as a tab's title, opening or closing a window, quitting, the font's size or running another command, comes once the plugin's call returns, in its order; a chain of commands that run commands, from a command run by hand or from a call of no command's, all of whose runs it is however many the call asks, goes 16 deep at most and runs 256 commands at most past its first, as a command that runs itself twice would run 2^16 times within the depth; a chain whose commands run keeps its count, however many chains come after it.
- The plugins' bindings come after the app's and before the config's
[keys], which win over them. A key runs its call on behalf of whoever presses it, so that a plugin of a manifest that is not a first-party one binds a call that it may make alone, as its menu items: a command that it registered or that its[uses]declares, of the capabilities that the command needs, of arguments that make a whole call; a global key too.
- The host's API and the
- Luau front end:
plugin-host-luaubinds the same messages to Luau.- The bindings and the Luau type definitions are generated from the Rust types where possible.
- The semantics are implemented once, in the kernel, behind both front ends.
- Names: the Luau API uses the Rust names (
request_render,on_event), so the two front ends read the same and share one reference. - Conformance: the conformance suite runs the same scenarios through both front ends, with Rust and Luau test plugins, and compares their command and event traces. It is
lokyr-kernel's testconformance: each scenario is of steps, each a call of the test plugin's, of the requests that it makes with the answers that they take, the workspace's events that the host posts after it, the time that the host's clock moves on, which fires the plugin's timers, and the batch of events that the plugin then hears; the test plugin makes the requests through its front end, and its trace, each request with its answer, the ids of reads and decorations of 0, and each batch, must be the scenario's. The scenarios hold every request of the API, its failures among them, which a test checks of an exhaustive match: those of the first-party plugins,links' andcore-actions', and of the events, the panels, the capabilities, the declarations, the app's requests, the state, the reads of rows, the views, the images of cells, the cells' reads, the clipboard's image, the saves and the workspace's writes that every plugin meets; the Rust test plugin runs them on the kernel's host and on the SDK's fake host, which must answer alike, in CI's macOS and Linux jobs. A window, a tab, a pane or a timer that a scenario opens, whose id each host gives its own, is a symbol of the order in which the trace first meets it, which the test plugin asks with the host's id of. The harness of the kernel's host does the app's part: it posts the workspace's changes, makes the renders that the calls ask for, renders the images as the fake host does, a clear pixel, tells a save's end as a scenario posts it, and gives each scenario a state directory of its own. The Luau test plugin takes the scenarios as JSON: its code makes each request through its function ofcx, of the symbols, which a host between it and the host of the call gives the host's ids of, and returns what each answered and each batch of events as it took them; its trace is of the requests as they reached the host from Luau, and of the answers and the events that Luau took, back as the SDK's types by the front end's own conversions, and must be the scenario's on both hosts, as the Rust test plugin's. - Testing for plugin authors:
- The Rust SDK ships a fake host for unit tests,
lokyr_plugin_sdk::fake::FakeHost, of itsfakefeature, a plugin's dev-dependency. The test sets what it holds, its panes, their lines, rows, links, styles, selections and directories, the commands that their shells marked and their views, the focus, the clipboard, the text's size, the targets not there, and the plugin's config and state; it answers the requests as the app's host does, the reads at once and the writes as the call returns, then the app's requests, refuses what the plugin's capabilities lack, and keeps the plugin's commands, bindings and subscriptions, what it did as the requests themselves, its decorations, its panels and its views' trees. It checks what the app's host checks, of the same code where the SDK holds it, the grammars of a binding's keys and of a context, the names, a command's registration and a call's arguments: a request of a pane, a tab, a window or a view not there, of a value out of its range, of a name, keys or a context that is none, of a command that is not registered or that the manifest does not declare, fails as it would in the app;with_capabilities,with_uses,with_slots,with_pagesandwith_commandsgive what the plugin's manifest declares and the commands of the app's and of the other plugins',with_manifestthe manifest's own;show_pageopens the settings' window at one of the plugin's pages as a click on its tab does, which the plugin'sshow_pageopens too,hide_pagecloses it, andpagetells the one shown;take_renderstells the renders that the calls asked for, a panel's opening among them; a config's change reaches an active plugin alone, its schema's defaults the test's to give. Its workspace is the app's, of the panes that the test gives: each window's tabs in their order and the one that it shows, each tab's layout, the pane of its keyboard and its zoom; the plugin's writes change it as the app's workspace changes, owing their events in the app's order, and a later write of a call finds what an earlier one opens; a drag of a pane's edge changes nothing of it, as it has no sizes. It owes the plugin its events, whichdelivergives it as a batch, andsnapshotwrites a view tree as text, a node a line, for tests to compare. It searches literal text alone, in each row apart, its matches in one event, where the app's host searches regexes and logical lines too. It renders an image as a clear pixel, at the scale asked for or of a display of 2, its checks the app's, and keeps the ids of four at most,kept_images, as the app keeps their pictures.awaketells what the plugin keeps from idle sleep.popupstells the popups that the plugin opened, andclose_popupends one's command of a status and closes it, as the app does, which the plugin hears · Since 1.5. Its pane's view's cells are its rows' texts and styles, its selection's cells those that the test gives, which a deselection takes away; an image on its clipboard,clipboard_image, takes its text's place; a save's panel shows as the call returns, one a window,savestells those that show, andanswer_savecloses one, of a path, whose filesaved_filethen holds, or of none, as the plugin hears at the next delivery. It holds a call within the app's bounds, its writes and requests of the app's together, its searches, which a look refuses and a failed call ends, its images, which a look refuses too, and a plugin's declarations, one made again changing nothing; it tellstab-changedas a tab's title, its own or its active pane's, its color or its marks change, a tab shown losing its activity and its bell, and, to a plugin that does not read the processes, the changes of what it reads alone, which reads no program's marks nor a pane's folder; a command's first row is its prompt's or its first mark's, a mark above the rows held having left the scrollback, as the app's. The conformance suite holds it to the app's host.core-actions' andlinks' tests run on it. - The fake host keeps a temporary file's bytes in memory,
temporary_file, its path in/tmp/lokyr-temporaryor the folder thatset_temporary_foldergives, refused as the app's host refuses it, of a call that only looks too; a folder's branch is the one thatset_git_branchgives a folder over it; the plugin's reads since the last take show,take_reads, and its reads of rows that it has yet to hear of are cut short, as a resize cuts them,cut_reads· Since 1.4. - For Luau,
sleip testruns the plugin's tests on the same fake host: each filetests/*.luau, its folders' files its modules, returns a table of functions, each a test, which takes aTestHostof its own, the plugin made anew of a fresh VM, of its manifest's capabilities and its English messages of no argument, of a pane that has the focus.TestHost, whichlokyr.d.luaudeclares, activates the plugin, runs its commands and looks, gives it events and its views' events, renders its views, tells its panels, its commands, its writes, its state and the clipboard, moves the host's time on, its timers' events given, and sets a message, the clipboard and its config; it gives the pane's view and its selection cells,set_screenandset_selection, and tells the clipboard's image, the saves whose panels show, whichanswer_savecloses of a path or of none, the file that a save wrote,saved_file, the images that the host keeps, and what the plugin keeps from idle sleep,awake; it tells the focused window and its tab,windowandtab, opens a tab as ⌘T opens one,open_tab, tells the popups that the plugin opened,popups, and ends one's command of a status,close_popup, as its plugin hears · Since 1.5, gives a tab the marks that a read of the tabs tells, asrunning,set_tab_marks, of which the plugin hearstab-changed, and tells the plugin's menu items,menu_items. A render that fails, or a tree that the host refuses, raises its error. A test fails at its first error, asassertraises it or a call that the plugin fails raises the plugin's, of its file and line, and runs 10 s at most; the tests run in a VM of the plugins' sandbox, whoserequirereads the plugin's modules.sleip checkchecks the tests' types too. TestHostgives the pane the commands that its shell marked,set_commands, their rows the screen's from 0, the pane its folder,set_directory, and a folder a repository's branch,set_git_branch; it tells a temporary file's bytes,temporary_file, the side of the status bar of the plugin's view,status_bar_side, and the plugin's reads since the last look,reads, and cuts its reads of rows short, as a resize does,cut_reads· Since 1.4.
- The Rust SDK ships a fake host for unit tests,
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.
- Shape:
- A plugin is a package of Luau modules. Its entry point,
src/init.luau, returns the table of callbacks shown above. Every callback is optional. requireresolves only the modules inside the plugin's own package: each module's environment holds the package's own, and the globals none, mlua'srequireof the file system taken from them.
- A plugin is a package of Luau modules. Its entry point,
- Types: a definitions file,
lokyr.d.luau, declares the API's types for Luau's type checker:Cx, of a function of each request, its parameters and its answer,(T?, string?, number?), as each request tells the response that answers it (Request::answer);EventandUiEvent, of their flat shapes;Node;Plugin, the table of callbacks; and every type that they use, by its Rust name, but where two share one, asNodeLayoutandNodeRole.cargo xtask luau-typesmakes it of the SDK's own types, as serde tells them, and a test of the Luau host fails as it is not the SDK's. Sleip's templates include it, with aluau-lspconfiguration that points to it,.vscode/settings.json, and.luaurc's strict mode, as in the template, whose analysis by luau-lspjust luau-lspruns.sleip checkchecks a plugin's sources against the same definitions with Luau's own type checker, built into Sleip of the version of the app's Luau (sleip-analyzer), in strict mode and of the solver that luau-lsp takes by default, so that a plugin that the editor passes passes Sleip, and the registry's CI. Plugins are written with--!strict. luau-lsp tells a field that a table lacks as it is read, a value of another type, a node of no such kind and a field that a table requires and lacks; Luau's table types take more fields than they name, so that a field of a wrong name in a table that a plugin gives is told by the host, as it refuses it. - Calls:
cx, which each callback takes first, holds a function of each of the SDK's requests, by its Rust name, read from the SDK's own type, so that a new request reaches Luau at once. A request of fields takes them as arguments in their order, ascx.line_text(pane, row, reach)orcx.new_tab(window, index, directory), anilleaving an optional one out, its default or its none, and a plain value'snilbeing its value; a request of a value takes it, ascx.selection_text(pane); a request of none takes nothing, ascx.focused_pane(). An argument of another shape, or more arguments than the request takes, raises an error that names it, asbad argument to cx.line_text: argument 2 (row): expected a whole number, not a text, and the host takes no request.cxis read-only, and reaches the host within the plugin's calls alone. - Answers: a call answers with the response's value, as a pane's id, a table of a line or
nilof none;trueof a write done, a declaration or a request of the app's taken; or, of a failure,nil, the error's message and its code. A response of fields is a table of them, as a new tab's{ tab = 3, pane = 7 }and a grid's{ columns = 80, rows = 24 }. - Errors: a failed request answers
nil, its error's message and its code, as Lua's standard library answers, so thatassert(cx.paste(pane, text))raises the message, after the place of the call, andlocal done, message, code = cx.paste(pane, text)reads them; the code's hundreds tell its category, as 101 of a pane that is not there. A Lua error raised by a callback ends the call, and counts as a plugin failure; a render's or a look's ofapplies, which return no error, the plugin tells after the call, throughPlugin::take_failure, which the host takes as the error of a call that tells one: its writes go, a view's last tree stays, and a fault, as a deadline passed, faults the plugin. - Shapes: the SDK's types cross as tables of their Rust names: a struct is a table of its fields, as
close_escapeandmin_width, a field ofnilleft out; a variant of a value is a table of one field, of its name, as{ pane_corner = { pane = 3, corner = "top-right" } }or{ up = 3 }, and a variant of none its name, a text, as"page-up"or"dialog"; a map's keys are as they are, a command's arguments' and a state's; a list is a sequence; a capability is its text, as a manifest writes it,"pty-write"or"net:example.com". A plain value, an event's, a state's, a config's or a command's argument, is as a Luau table is:nil,trueorfalse, a number, a text, or a table of them, a sequence a list and another table, an empty one too, a map, but an empty list that the host gave, such as a setting's value, which comes back a list. A whole number is an integer. A plain value nests 64 levels of tables at most, as the host takes it, and another value 144, a tab's layout of many splits; a value holds a million values at most, those read out of its tables and not converted yet among them, so that a table that holds itself many times holds no more of the host's memory, and 16 MiB of texts and buffers, as the VM holds one text however many times its tables hold it, the names of tables' fields and nodes' kinds among them; a value past them is refused, a table that holds itself too; a conversion stops as its call's deadline passes, a request's arguments as the call runs and a render's view within the render's deadline, as a deadline passed; a number is finite, a NaN or an infinity refused; its tables are read raw, of no metamethod, as no code of the plugin's runs outside its calls. - Views: a view's node is a flat table of its fields, its
kinda text, and its kind's own fields beside the node's, as{ kind = "button", key = "go", text = "Go", icon = "play" }: a text's text and a button's or a toggle's label are itstext, an icon's name itsicon, as the node'slabelis what accessibility calls it; itschildrena list of nodes, a list'srowa node, and itslayout,styleandprogresstables of their fields. A field of another kind than the node's, or of none, is refused, of its place in the tree, asthe node at children[2].row: no field on of a text node. A view converts without recursion, a node at a time, and nestsNode::DEEPESTlevels at most as it converts, a list's row a level of its own, so that no tree deeper than the host takes is made: a deeper one, or a node that holds itself, is refused; a node that a list of children holds many times converts each time, and counts each time against the million values. - Events: an event is a flat table of its
kind, its name, and its fields, as{ kind = "tab-created", tab = 3, window = 1, index = 0 },{ kind = "keys-changed" }or a panel's closing{ kind = "panel-closed", id = "find" };on_eventtakes a list of them. A view's event alike, of itsview, its node'skey, itskindand its fields, as{ view = { panel = "find" }, key = "query", kind = "submit", text = "x", shift = false }. - Data:
- Small values are plain tables, possibly nested: command arguments, view trees, events.
- The host stores view trees as a flat arena of nodes and diffs them between renders. A node that holds state, as a text field or a list, has a key, by which the host keeps its state, its text, caret, selection and composition, its scroll; the plugin learns of changes through events, and sets a field's text through a request. A large list is data, its items flat with a row's template, which the host instantiates for the rows that show: its plugin gives its count and a window of its items, those that the host asks for about the rows that show, by
list-range, as they scroll past the window. - Bulk data uses buffers. For example, a highlighter returns its spans in one
buffer, which the host reads in one copy: reading 100000 spans from tables costs 6–7 ms, against about 1.5 ms through Lua's C API, as measured in F0.
- Handles to host objects: windows, tabs and panes are opaque integer ids, as in the Rust front end.
- Rows are numbers, which output, the view's scrolling and the scrollback's limit leave a row, until it leaves the scrollback; a resize numbers the rows anew. A command of a cell, as a click's, takes the number of the row clicked, as the drawn frame showed it (ARCHITECTURE.md).
- Plugin-defined events:
customevents carry a name, of the plugin's namespace, assearch.progress, a schema id, assearch.progress/1, and a plain value, the SDK'smessage::Data: text, numbers, true or false, and lists and maps of them, as a Luau table is.cx.emitemits one, which comes after the call returns. A value, an event's or a state's, nestsData::DEEPESTlevels at most, 64, as the host walks the values that it takes recursively on the main thread: a deeper one is refused,failed, checked without recursion and dropped a level at a time, a worker's on its own thread; the Luau front end's conversion of tables keeps the same limit. A view's tree nestsNode::DEEPESTlevels at most, 64, alike: a render of a deeper one is refused, the last staying, a worker's checked on its own thread.
Versioning
- The API version is the version of
plugin-sdk(plugin-sdk 0.1.9↔ API 0.1), whichlokyr --api-versiontells. A patch adds requests, events and the test host's functions: 0.1.9, of Lokyr 1.7, adds since 0.1.8 whether a running command's pinned prompt rows stay,header_while_runningofcx.set_block_looks; the panes' look, as cards or plain,cx.set_pane_look, ofpane-view, which floating panes take too; the plugin's own icons of programs, over Lokyr's, for the headers that Lokyr draws, a floating pane's,cx.set_program_icons, ofpane-view; a pane's title of its parts, its program's name, its own title and its folder,cx.pane_label, ofprocess-read; the iconscreen-full, and the icons of programs, languages and AI agents, asrust,python,nodejs,git,docker,vim,claudeoropenai, of Nerd Fonts' devicons and codicons; texts of twelve and fourteen thirteenths of the interface's size,calloutandtitleoftext_size; and, of Lokyr's own plugins alone, the other key's value that a key of the settings applies of,applies_when, the default of a field of a table of entries,defaultof a field, and the triggers' section of the settings; a plugin that needs it asksapi = "^0.1.9"· Since 1.7; 0.1.8, of Lokyr 1.6, adds since 0.1.7 the items that the plugins added to the menu bar, each of its command's arguments, its title, its keys and its state,cx.menu_bar_items, ofuser-commands, which the palette lists; a split's folder,directoryofcx.split; a new pane's environment variables,environmentofcx.open_window,cx.new_tabandcx.split, which takepty-writetoo; a mouse event sent to a pane over a cell, a button's press or release, a move or the wheel's steps, as the program's modes encode it,cx.send_mouse, ofpty-write; the rows of a search's matches alone in its pane's view, the rows of new output searched as they come,cx.filter_matches, ofpane-view; a key sent to a pane as the keyboard encodes it,cx.send_key, ofpty-write, and pressed as the user presses it, its binding's command or the program's key,cx.press_key, ofuser-commandsandpty-write; and, of Lokyr's own plugins alone, the requests of scripts and shortcuts, the eventautomationandcx.answer_automation, ofautomation; a plugin that needs it asksapi = "^0.1.8"· Since 1.6; 0.1.7, of Lokyr 1.5, adds since 0.1.6 the sessions,cx.sessions, a session made and switched to,cx.new_sessionandcx.switch_session, ofworkspace-write, and the eventsession-changed, and the folders that the sessions' switcher lists,cx.session_folders, ofprocess-read; a window's broadcast of the typed input,cx.broadcast, set,cx.set_broadcastandcx.set_pane_broadcast, ofworkspace-writeandpty-write, a paste and text sent to the panes that it reaches,cx.paste_broadcastandcx.send_text_broadcast, ofpty-write,broadcastof a tab, and the eventbroadcast-changed; a tab's floating panes,cx.floating_panes; a popup that runs a command,cx.open_popup, ofworkspace-writeandpty-write, and the eventpopup-closed; and the test host'spopupsandclose_popup; a plugin that needs them asksapi = "^0.1.7", which Lokyr 1.4 refuses with its notice · Since 1.5; 0.1.6, of Lokyr 1.4, adds since 0.1.5 the commands' blocks, their looks,cx.set_block_looks, a block selected,cx.select_block, ofpane-view, and read,cx.selected_block, ofhistory-read, a command by its id and of a row,cx.shell_commandandcx.command_at, ofhistory-read, a command's times, folder and host,started,ended,folderandhost, the view's folds,foldsofcx.viewport, a plain click on a cell, the eventclick, and a right-click on a block's pinned prompt rows,prompt-rows-menu, ofpointer-read, the command line at the prompt,cx.edited_line, ofterminal-read, run there,cx.run_line, ofpty-write, and the eventscommand-startedandcommand-endedto a plugin ofprocess-readtoo; a plugin that replaces another,replacesof its manifest; the status bar's sides,[contributes.status-bar] sideandcx.set_status_bar_side; a temporary file,cx.temp_file, and the time of day,cx.now, of no capability; a folder's git branch,cx.git_branch, ofprocess-read; the cells of a range of rows,cx.row_cells, ofterminal-read; the controls of macOS 27, their sizes,size, the switch, the checkbox, the radio buttons, the pop-up button, the search field, the group box and the key caps, the buttons'variantand a text fielddisabled; the iconsgit-branch,magnifying-glassandclear-circle; and the test host'sset_commands,set_directory,set_git_branch,readsandcut_reads; a plugin that needs them asksapi = "^0.1.6", which Lokyr 1.3 refuses with its notice; 0.1.5, of Lokyr 1.3, adds since 0.1.4 a window's tabs in the order of their use,cx.recent_tabs; a tab pinned,cx.set_tab_pinned, andpinnedof a tab; a closed tab kept,keepofcx.close_tab, and given back,cx.reopen_tab; the groups of tabs,cx.groups,cx.new_group,cx.add_to_group,cx.remove_from_group,cx.rename_group,cx.set_group_color,cx.fold_groupandcx.ungroup,groupof a tab and the eventgroup-changed; a session's status,statusof a tab, and what a waiting agent asks for,kindofcx.agents, ofprocess-read; a decoration's label,labelof its look; a modifier's double tap from any app,cx.watch_double_tap, ofglobal-hotkey, and its eventdouble-tapped; and, of Lokyr's own plugins alone, the settings' maps of tables and a key's page of the documentation; a plugin that needs them asksapi = "^0.1.5", which Lokyr 1.2 refuses with its notice; 0.1.4, of Lokyr 1.2, adds since 0.1.3 every token of a theme as it resolves,cx.theme_tokens, and the eventtheme-changed, each theme's format in the read of the themes, andcx.set_themeof a theme of either appearance; the system's color panel,cx.show_color_panelandcx.close_color_panel, of no capability, and its eventscolor-pickedandcolor-panel-closed; a question of buttons,cx.ask_choice, its answerchosen; a view's part drawn in a theme of a name, the nodethemed; and, of Lokyr's own plugins alone, ofconfig, a theme copied, made, converted, and its colors written or shown before they are,cx.copy_theme,cx.new_theme,cx.convert_theme,cx.set_theme_valueandcx.preview_theme_value; a plugin that needs them asksapi = "^0.1.4", which Lokyr 1.1 refuses with its notice; 0.1.3, of Lokyr 1.1, adds since 0.1.2 a notice in Lokyr's card,cx.notify, of no capability, and the test host'snotices; the styles of a family,cx.font_styles, of no capability, and a style's preview,cx.preview_font_style, ofappearance-write; a theme's preview in a view, the nodetheme-preview, the themes' list'sloadingand the eventthemes-changed; a number's field of steps,stepped, and a button of a link's look,link; a panel in the middle of a view's window,view_window; a window's title as its titlebar shows it,WindowInfo.title; and, of Lokyr's own plugins alone, the settings window's pages, the plugins' list and the config's keys; a plugin that needs them asksapi = "^0.1.3", which Lokyr 1.0 refuses with its notice; 0.1.2, of Lokyr 1.0, adds since 0.1.1 the agents of every window,cx.agents, ofprocess-read, and a file opened at its line in the editor,cx.open_at, ofopen, which a plugin asks withapi = "^0.1.2"; 0.1.1, of Lokyr 0.9, adds since 0.8.0's 0.1.0 the images of cells and the view's image node, the cells of the selection and of the screen, the clipboard's image, the save panel,keep_awake, the titlebar's buttons, the menus' ticks and submenus, the packages' service, the font families' list, preview and choice and the capabilityappearance-write, which the themes' preview and choice take in place ofuser-commands, and the test host's screen, selection, saves, tabs, marks and menu items; a plugin that needs them asksapi = "^0.1.1", which an older Lokyr refuses with its notice. - New APIs start as unstable: in Rust behind the
unstablefeature; in Luau every request is a function ofcxby its Rust name, unprefixed, the whole API experimental whileplugin-sdkis 0.x, until F6, so that a request that becomes stable keeps its name and no plugin breaks of a rename. They become stable in a minor release. - The manifest declares the API version it requires (
api = "^0.1"). The host supports the current major version and, through adapters, the previous one. - Before 1.0, minor versions may break compatibility. After 1.0, semver is followed strictly.
Illustrative draft
The Luau front end of the API as
plugin-sdk0.1 has it: each ofCx'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 thatcargo xtask luau-typesmakes 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 answeringtrue, ornil, 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
-
A command has a name,
namespace.action, each part of lowercase letters, digits and-, from a letter, aswindow.new,tabs.gotoorsearch-plus.open; a title, for the menus and the palette; a category, which also tells the menu that lists it; the capabilities that its action needs; its parameters, a flat schema: each named as the parts are, of a string, an integer, a number or a boolean, and required, or optional with a default of its kind; and, if it needs one, the context in which it can run, written as a binding'swhen, as Copy'sselection, outside of which its menu's item is dimmed. Its plugin'sappliescan dim the item too, where the command would do nothing, as Open Link where no link is. Its title, in the language that Lokyr shows, comes from its plugin's own catalogs, by the messagecommand-and the command's name with-for its., ascommand-pane-copy, or English's; a title that they lack is the one registered. A native plugin gives its catalogs throughPlugin::catalogs, built in; a Luau plugin carries them in its package,locales/<language>/*.ftl, which the app reads as it loads it, a language's files one catalog, with the config's schema that its manifest names, so that its commands' titles,cx.messageand its section of the config work as a built-in plugin's do. -
The pane's context menu, of a right click, lists the commands of a cell, which take the
columnand therowof the cell clicked, then those of the clipboard and of the editing that need no arguments, then the plugins' items, a group of each namespace of their commands, an item of a submenu in it, and an item of a command of a cell, of no arguments of its own, of the cell clicked too; its commands run in the pane that it opened over (UI-AND-FEATURES). -
A plugin's menu items add a command with its arguments to a menu, as a command that needs an argument has no item of its own:
add_menu_item, a declaration, of the menu bar's menu of a category, after its commands, each plugin's a group of their own, or of the pane's context menu, each plugin's a group of their own too, assplits' Split Left,splits.splitof{ direction = "left" }. The command is registered, the arguments make a whole call, and the plugin may run it, as its manifest's commands and its capabilities say; the items go with their plugin, as it stops or the config turns it off. An item's title and submenu, as a command's title, have 256 characters at most, of no control character nor one that hides or moves the text around it, which the host refuses otherwise, so that a plugin's declarations stay small. An item whose title is that of one of the app's items in the same menu, whatever its case, the dots of an item that asks more, its full-width letters and the letters of Cyrillic and Greek that look as Latin ones, as a plugin's "Copy" in the Edit menu, is left out, as the log tells, so that no plugin's item passes for the app's; so is one whose title of the plugin's catalogs hides characters. The menu bar shows the keys bound to the same call, as ⌘D beside Split Right; the command'swhendims an item in both menus, and its plugin'sapplies, of the item's arguments, in the context menu. An item of the menu bar shows a tick of itsticked, as a state in force that its plugin keeps, as a mode that is on: the same item added again, of the same place, command, arguments, title and submenu, with anotherticked, changes its tick alone, and the menus are made anew. An item of asubmenu, a message of the plugin's catalogs or a text, goes into a submenu of that title, in the menu bar or the context menu, with the plugin's other items of the same one, in their order, the submenu where the first of them would be, as a plugin's modes in a submenu of the View menu; a plugin's submenu of the title of one of the app's items of the menu is left out, as an item is. A plugin's own command that its item of a menu runs of no arguments has no item of its own in that menu: the plugin's item takes its place, as a plugin's modes, its commands in the palette and of their keys, show in their submenu of View, ticked; so does another plugin's command that an item of a submenu of one of Lokyr's own plugins runs of no arguments, asblocks' Block submenu of the context menu takescore-actions' Copy Command Output and Select Command Output in · Since 1.4. An item of the context menu of a command of a cell, of no arguments of its own, runs of the cell clicked, as the command's own item does · Since 1.4. -
The kernel's registry,
kernel::commands::Registry, registers the commands of the app and of the plugins, and checks a call before its action runs: its name, and its arguments, to which it adds the defaults of those left out; an integer is a number too. The checks of a command and of a call are the SDK's,Command::checkandCommand::check_call, which the registry and the fake host share. A plugin's call is checked as well against the commands that its manifest declares and the capabilities that it has, its own commands aside. The action runs where it can: in the app for those that the platform does, in the plugin that registered the command otherwise. -
The app's commands, whose actions the platform does:
app.quit,window.newandwindow.close; the appearances,app.appearance-system,app.appearance-lightandapp.appearance-dark; andpane.look-up,pane.man-page,pane.man-searchandpane.search-web, the context menu's Look Up, Open man Page, Search man Page Index and Search the Web, of the selection. -
Errors: a code, never renumbered, whose hundreds tell the category and how serious it is, a kind, as the Luau API names it, and a message:
Code Kind Category Meaning 101 not-foundUsage No command of the name 102 invalid-argsUsage An argument that the command does not take 103 invalid-argsUsage A required argument missing 104 invalid-argsUsage An argument of another kind than its parameter's 105 invalidUsage A command's or a parameter's name that is not one 106 invalidUsage A command registered already 107 invalidUsage A schema that repeats a parameter, or whose default is of another kind 108 invalidUsage A binding whose keys, command or context is not one 109 invalidUsage A config that does not read, or whose values are not its keys' 201 failedFailure The command ran, and failed 202 failedFailure What an action needs is not there, as a font's family that is not installed 301 deniedSecurity A command that the plugin's manifest does not declare 302 deniedSecurity A capability that the command needs, which the plugin lacks 401 faultFault A command that broke, as by a panic Usage errors go to the caller, failures to the log and, later, a notice in the window, security errors to the log and the audit log, and faults to the log, with a notice, and can disable the plugin.
Capabilities
| Capability | Allows | Risk |
|---|---|---|
| (none) | Registering commands, and running those that the manifest declares; keymap, events, UI, themes, config, storage, logging, timers | — |
terminal-read | Reading screen and scrollback text, and the selection | High: the screen may show secrets |
pty-write | Sending input to the shell | Very high |
clipboard-read | Reading the clipboard | High |
clipboard-write | Writing to the clipboard | Medium |
notifications | Showing system notifications | Low |
open | Opening URLs and files with the system handler | Medium |
process-spawn | Starting processes; refused before 1.0.0, with a notice | Very high |
net:<host> | HTTP requests to the listed hosts, whatever their case; refused before 1.0.0, with a notice | High |
fs-read:<path>, fs-write:<path> | Access to the listed paths and to the paths under them, of whole components and no .. | High |
global-hotkey | System-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's | Medium |
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-read | Seeing the keys typed before they reach the program | Very high: a keylogger's power |
history-read | Reading 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-ended | High: a password typed by mistake ends up there |
process-read | Seeing 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.4 | Medium: command lines can hold passwords |
workspace-write | Opening, 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 quit | High: it can end every program, start shells, or move the keys typed to another pane |
pane-view | The 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 mouse | Medium: a cleared scrollback is lost text, and a selection is what a copy takes |
decorate | Drawing over a pane: decorations and their labels, the gutter's marks, a search's matches and a held cursor | Medium: a drawing over the text can show what the terminal does not hold |
pointer-read | The 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.4 | Low |
keep-awake | Keeping 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 off | High: a display kept awake keeps the screen from locking, and of a battery's cost |
config | The 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 check | Very high: a key written can change the program that a pane runs |
packages | The 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 check | Very high: a plugin that installs another runs code of its choice |
user-commands | Running 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.6 | Very high: pane.send-text types into the shell |
appearance-write | Previewing 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 do | Medium: 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.
- Commands: each has a category,
app,windows,tabs,panes,input,clipboard,edit,findorviewto start with, and the capabilities that its action needs, aspane.pasteneedsclipboard-readandpty-write. A plugin declares in its manifest the commands that it runs,[uses] commands, by name or by namespace, astabs.*: one that it did not declare fails withdenied, 301, and one whose capabilities it lacks withdenied, 302. The commands run by hand, through the keys, the menus or a plugin withuser-commands, as the palette, and the plugin's own need no declaration. Withoutuser-commands, a plugin reads the commands' names, titles, categories and parameters, not their plugins. Each command of Lokyr's own, the app's and its plugins', takes the capabilities of what it does:tabs.close,splits.split,window.newandapp.quittakeworkspace-write,tabs.renameandwindow.set-titlepane-view, the find bar's and the copy mode's commands what they read and draw,pane.search-webopenandterminal-read, andwindow.open-layout,pane.popupand the broadcast's commandspty-writetoo; the commands of the system and the integrations, such as Make Lokyr the Default Terminal, run ofuser-commandsalone · Since 1.5. - Declaration and consent:
- Capabilities are declared in the manifest. Sleip shows them at install time, with the commands that the plugin runs, grouped by category, and the capabilities that those need.
- The app asks at an installed plugin's first activation, one question, of the app's, of the capabilities that its manifest declares and that no decision grants or refuses yet, each told in the language shown with its risk, the default button refusing; its activation waits for the answer, and what its trigger brought meanwhile comes once it activates: its commands' runs, 16 at most, a run past them refused; its events, the one that woke it, if nothing else did before, and the last of each name and subject, as of each pane or command, 64 at most, of those that the capabilities granted let it subscribe to, as a tab's change that it cannot read is none; and its views. An answer leaves the capabilities decided in the file while the question showed, as the file says, and a refusal takes the others away. Refused, the plugin runs without them, its requests that need them
denied. A new version asks for its new capabilities alone.net:<host>andprocess-spawnare withheld before 1.0.0, never asked for. - Decisions are stored in
~/.config/lokyr/permissions.toml, beside the config file,[plugins."owner/name"]ofgrantedandrefused, which can be versioned with dotfiles and edited at any time: the app watches it, and a capability that it no longer grants stops a plugin that held it, until it is turned off and on again or the app's next start, as the notice of the plugins that stopped tells; one taken out of both lists is asked for again. A file that does not read, as of a typo, keeps the decisions in force, as a notice tells, once, a notice closed staying closed until the error changes, and no answer writes over it: the answer holds, and is written there once the file reads again, of the capabilities that the file leaves undecided alone, so that a question asked as it did not read, as at a start, never undoes a decision of the file's; an answer whose write fails waits so too; a plugin that a reload takes away or makes anew loses its open question, and its new version asks its own. - Each grant, refusal and revocation goes to the audit log,
audit.login the state's folder, a line each of the time, the plugin, its version and the capabilities.
- Enforcement:
- Every host function exists in every plugin. Without the capability it returns a
deniederror, so a plugin can treat a capability as optional and request it at the moment it's needed. - The VM itself reaches nothing outside the computation: it has no
io,osordebuglibrary, and itsrequirestays inside the package. Files, processes and the network exist only as host functions, limited to the granted paths and hosts.
- Every host function exists in every plugin. Without the capability it returns a
- The app as the plugins' gateway to the network, after 1.0.0, in F6; until then
net:<host>andprocess-spawnare refused with a notice:- A plugin has no network of its own: a request with
net:<host>goes to the app, which checks its capability and its host against the allowlist, and logs it. - The connection runs in a helper process started on demand,
sleip net-helper, of the Sleip that the bundle holds, which enforces the allowlist too, so that no response from the network is parsed in the process that sees what is typed. - Lokyr's own code contains no HTTP/TLS client; Sparkle's updater is the app's one network client.
- A plugin has no network of its own: a request with
- First-party plugins are trusted code, which holds every capability and runs any command, but they are still limited to the SDK. Each has a manifest,
plugin.toml, of the kindbuiltin, whose capabilities tell what it uses, which the build checks; the kernel adds it by its manifest's name, aslokyr/links. - Other plugins hold the capabilities that their manifest declares, and run their own commands, those that they registered, and those of their
[uses]: a request that needs another capability fails with 302, and a run of another command with 301, bothdenied. Each plugin's namespace, its name's after its owner, aslinksoflokyr/links, is its own: a second plugin of a namespace is refused; such a plugin registers commands of its namespace alone, which no other plugin's commands, nor the app's, have, and every plugin emits events of its own namespace alone.
Lifecycle
installed ──▶ resolved ──▶ consent ──▶ loaded ──▶ active
▲ │ error / deadline / panic
│ ▼
re-enabled ◀── disabled ◀── restart with backoff
- Installed plugins: the app reads
plugins.lock, beside the config file, and the store as it starts, and adds each plugin of Luau of its package, whose digest it checks, or of the folder thatsleip devlinks, of no digest, each on a thread of its own; a package changed since it was stored, a manifest that does not read or that names another plugin, and a plugin whoseapidoes not take the app's plugin API, whichlokyr --api-versionand the bundle'sapi-versiontell, are refused, as a notice tells. - Lazy activation through
activation.on, the app's start of none:startup;command:<command>orcommand:<namespace>.*, of the plugin's own namespace alone, as the first run of a command of the pattern, or of the manifest's commands, which show in the menus and the palette before, of their titles and categories, activates the plugin, then runs the command, after its activation on its thread, of the arguments that its own command checks, so that a key, a menu item or a call of arguments wakes it, its defaults given; such a command, as it waits, needs of another plugin's call every capability that its plugin declares, and the app's own commands never go to a plugin;event:<name>, as an event of the name comes, which the plugin hears as its activation subscribes to it, the app telling the events that cost wakeups, the pointer's and the views', while a plugin waits for them;slot:<name>, as a view of the slot first shows, which the plugin fills as it waits;page:<id>, of a page of its own, as the settings' window first shows it, of Lokyr's own plugins alone.osc:<number>comes with the OSC handlers, in F5: a plugin of it is refused before, as a notice tells. A menu's question of whether a command applies activates nothing. A plugin that waits makes no VM. - Zero cost without third-party plugins: no Luau VM exists until the first one activates.
- Backoff: after 3 failures within a minute, the plugin stays disabled until it is enabled again.
- Hot reload: the app watches
plugins.lock, the store and the folder of each plugin thatsleip devlinks, and, once a burst of changes settles, a quarter of a second after the last, takes the lockfile again, without IPC: a plugin installed comes and activates at its trigger, the app's start's at once, without a restart; one removed goes, asenabled = falsestops it; one updated, of another version, digest or source, or whose linked folder's manifest or sources changed, is made anew, a fresh VM, nothing compiled ahead, so that an editor's swap file,.git/ortests/make nothing anew; each package's digest is checked again, so that one changed in the store is refused; a plugin refused is told once while it stays so. The watches wake nothing while nothing changes; the config's folder is made as the app starts, so that they watch from a new account's first run, and the decisions' watch followspermissions.tomlas it becomes a link elsewhere, as GNU Stow makes it.
Limits and isolation
- One VM per plugin: plugins share no Lua state, so one plugin cannot see or change another's globals.
- Memory: a limit per VM, 64 MB, fixed in 1.0.0, of no key of the config; a key, if one is asked for, in F6. An allocation over the limit raises a memory error, which ends the call.
- CPU:
- A deadline per call type: 16 ms for
renderandapplies, 250 ms for commands, events and a view's events, a second for the activation, the entry's run included. Past it, the call fails and the plugin faults. - A watchdog thread installs Luau's interrupt only once the deadline has passed, so the check costs nothing until then. The interrupt then ends the call at the next loop iteration or function call, native code included, and again at each of them until the call ends, so that a
pcallthat catches the error ends at its own next loop or call. The time that the plugin's code waits for the host's answers, as a request of a plugin's thread waits for the main thread, is not the plugin's: the clock stops meanwhile. A single call of the libraries runs to its end, as Luau's table library checks no interrupt:table.sortof a table of millions of numbers runs some hundreds of milliseconds past a render's deadline, and the plugin faults after it. - The watchdog, a thread of each VM's, runs only while a plugin is executing: it sleeps on a condition variable otherwise, so there are no wakeups when idle.
- The watchdog writes the interrupt from another thread while the code reads it, as Luau's own command line writes it from a signal's handler at a Control-C: one aligned pointer, which a 64-bit CPU stores whole, of no patch to the vendored Luau.
- A deadline per call type: 16 ms for
- Failures: a failing plugin never affects the terminal. The plugin is disabled and a notification tells it; a Luau plugin's error is told of its first 4 KB, and a refusal of its values of their texts' first characters; a fault, a panic, a deadline passed or the memory's limit, of a plugin that the host can make anew, a built-in one of its registration or an installed one of its package, a fresh VM of it, starts it again after a second, two at the next fault, and the third within a minute turns it off until the app's next start, as the notification tells; what it left in the panes and the app goes, its decorations, its gutter's marks, the cursors that it held, its panels, its searches and its reads, its views showing as they were, taking no event. In native plugins,
catch_unwindat the boundary stops panics; a panic of the host's own, as it answers a request of a plugin's thread, disables that plugin and leaves the app running. - Bounded queues: what a plugin's calls leave for later is bounded, so that a plugin cannot grow the app's memory without end:
- a call's writes and its requests of the app's, which apply as it returns, 10 000 at most together, past which another fails;
- the panes that a plugin opens, by new tabs, splits, popups, windows and sessions together, 16 a call and 64 within a second of the host's time of its calls together, as each pane's shell is a process that the app forks, past which another fails · Since 1.6;
- its reads of rows, each on a thread of the host's, four under way at most;
- the searches that a call starts, each on a thread of the host's, 16 at most, a pane's ending the one before as the call returns; a look of
appliesstarts and ends none, and a call that fails ends those that it started, the ones that they would have ended running on; - the images of cells that a call renders, each on the main thread, of a GPU's texture and its PNG, 4 at most, of 1000 rows of 1000 columns, 16 384 pixels a side and 16 million pixels at most, of a scale lowered to fit, and of a plugin's budget of 32 million pixels at once, given back at 4 million a second, which each image takes, refused or drawn; a look of
appliesrenders none; the images that the host keeps of a plugin's, for its views' nodes, each a picture of the renderer's, 4 and 16 million pixels at most together, the oldest let go past them, and all as the plugin stops; - a plugin's temporary files, each written whole on the main thread, of no flush to the disk, as the start empties their folder: a text's of a known extension, 8 MiB a file, 16 files and 32 MiB together, and a budget of 32 MiB of writes at once, given back at 8 MiB a second, which each write takes, 256 KiB at least, so that a loop of writes waits; a look of
applieswrites none · Since 1.4; - a plugin's timers, 64 at most, past which another fails until one fires or is cancelled, of a delay of 10 ms at least, which a shorter one takes, so that a timer wakes the app 100 times a second at most, and a day at most; a timer that fired many times before its plugin heard of it owes it one event;
- the calls that wait for a plugin's thread while it makes one, its commands, renders and its views' events, 256 at most, and 10 000 events: past them, its thread, which took none of them, is taken for stuck, and its plugin disabled, as a notice tells;
- a chain of commands that run commands, 16 deep and 256 runs at most;
- a plugin's commands, keys and menu items, 4096 at most together; a key or an item that it declared already changes nothing, so that the keymap and the menus are not made anew, and
keys-changedcomes as the keymap changes alone.
- Numbers: a request's numbers are finite, as JSON holds them, its values', its arguments', a window's point, a share, a size, a fade, and an image's room and scale: a NaN or an infinity is refused, as
wrong-kind; a text's points, from 4 to 200, go to a quarter of one, and the interface keeps 32 faces of other sizes at most, as a plugin's text of a new size at each frame would keep one each. - Hostile plugins in CI: plugins of Luau of a third party's manifest run on the plugins' host against every build,
lokyr-kernel's testhostile, each stopped as its limit says, what it asked gone, and a plugin beside it running its command and hearing its events: a flood of images, held to its budget of pixels; a loop, faulted at its deadline, on the main thread and on a thread of its own, which the main thread never waits for; an allocation and a string that doubles, faulted at the memory's limit; a table a hundred thousand levels deep and one that holds itself, refused as they convert; a flood of writes, refused past a call's 10 000, then faulted at the deadline; a capability not granted, refused; arequireout of its package, which stops the activation; and a runaway recursion, whose call fails of a stack overflow. With F0's escape probes, so the sandbox stays closed.
Native code and the hardened runtime
- Compilation: when a plugin loads, Luau compiles its sources to bytecode, and its code generator turns the plugin's functions into native code. F4 measures this against the activation budget. If needed, the host caches the bytecode it compiled itself, keyed by the source hash and the Luau version, in a directory with 0700 permissions.
- Sources only: packages carry Luau sources, never bytecode. The host compiles every script itself, loading each file as text alone, so that a file of bytecode fails to compile rather than load as bytecode.
- macOS:
- The code generator maps its code with
MAP_JIT, so the app needs thecom.apple.security.cs.allow-jitentitlement, and no other hardened-runtime exception. - This was checked in F0, in a notarized app, launched as a download.
- Without the entitlement, Luau runs the same code in its interpreter, about 5× slower on loops.
- The code generator maps its code with
- Luau version: Luau comes from mlua's vendored sources. Its version is pinned and upgraded deliberately, with the hostile plugins and the conformance suite as the gate.
First-party plugins
| Plugin | Role | Phase |
|---|---|---|
core-actions | Copy, paste, select all, scrolling, font size, new windows | F2 |
links | ⌘-click opens a link, a URL or a path of the text, file:line in the editor; later hints and smart selection | F2, F5a, F5c |
tabs | iTerm2-style tab bar and tab commands | F3 |
splits | Split commands, dividers and interaction | F3 |
search | Find bar and search commands | F3 |
keymap-macos | Default macOS shortcuts, as iTerm2's: the keys of the app's commands and of the other plugins', which bind none of their own | F3 |
keymap-linux | Default Linux shortcuts | F7 |
command-palette | Command palette and theme picker | F3 |
settings | The 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 force | F3b |
plugin-manager | The 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 |
automation | What 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.6 | F5b |
blocks | Command + 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.4 | F5a |
quick-terminal | The 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-hotkey | F3 |
progress | The programs' progress (OSC 9;4), in the window-strip slot; the tab shows it with tabs | F3 |
command-header | The 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's | F3 |
copy-mode | The keyboard's selection over the screen and the scrollback, as tmux's and vim's | F3 |
tmux-cc, profiles | iTerm2 power features; the broadcast, since 1.5, and the triggers, of 1.7, are Lokyr's own, of no plugin | F5b |
images | Inline images | F5c |
Rules (details in ARCHITECTURE.md):
- depend only on
plugin-sdk; - use
#![forbid(unsafe_code)], with clippydisallowed-methodson, so they follow the same rules as Luau plugins; - pass the conformance suite.
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
- Generation:
cargo xtask gen-distreads everydist/*.toml, and writes, between its markers, each distribution as a feature oflokyr-app-coreand oflokyr-app,dist-<name>, of a feature of each of its plugins,plugin-<name>, which takes the plugin's crate, a dependency oflokyr-app-corethat is optional; andcrates/app-core/src/dist.rs, the build's plugins' registrations,export_plugin!'s, in the files' order,defaultfirst. The default distribution is the crates' default;just check-distchecks that what it would write is written, andjust build-minimalbuilds the minimal one, as CI does. - Minimal distribution:
dist/minimal.tomlcontains onlykeymap-macosandcore-actions, Alacritty-style. It proves the terminal works without any of the "visible" features:cargo xtask bundle --no-default-features --features dist-minimalbuilds its app. - The keys: the system's keymap plugin,
keymap-macoson the Mac, binds the default keys of every command, the app's and the other first-party plugins', which bind none of their own; it comes first, so that a plugin's binding after it wins, and the config's[keys]after all of them. A binding of a command that no plugin registers, as one of a plugin turned off, takes no key; with the keymap off, the menus keep the system's own keys alone, ⌘H, ⌥⌘H, ⌘M and ⌃⌘Space. - At runtime:
[plugins.<namespace>] enabled = falseturns off a first-party plugin, at once as the config is saved, andtrueturns it on again, a new one of it: its commands, its keys, its views, its panels and its decorations go as it stops. A built-in plugin whose manifest saysenabled-by-default = false, asblocks, starts off where its section has noenabled, untiltrueturns it on, and the Plugins page writestrueto turn it on and takes the key away to turn it off; a plugin of the registry runs once installed, andsleip checkrefuses the key in its manifest · Since 1.4.- A plugin that another's manifest names in
[plugin] replacesis off while that one stands in, as its section turns it on and its faults have not turned it off until the app's next start, of no key written: it starts again, a new one of it, as that one is turned off, removed or turned off by its faults. A replacement is a capability,replaces:<plugin>, which a third-party plugin asks for with the others, the replaced plugin running until the answer, and Lokyr's own plugins hold; a decision changed inpermissions.toml, a replacement granted or revoked, or the replacer stopped of a capability revoked, turns the replaced plugin off or on again at once. A plugin that is itself replaced replaces nothing, so that a chain goes as far as the first that runs; the plugins of a cycle replace none of each other, of a notice; no plugin replaceslokyr/plugin-manager. A replaced plugin's section that holds keys tells nothing as the config applies, as a section kept for the plugin's return is no mistake: the settings' sections tell its replacer,replaced_by, which the Settings page shows over its keys · Since 1.4. - For single-provider slots (
tab-bar,pane-header), the config's[slots]picks the provider, the first that fills it by default, so a third-party plugin can replace our tab bar.