plugins
What the plugin host loaded, and the one way to call a plugin.
require("@builtin::modules.api.engine.plugins") -- plugins (also available as global 'plugins')
The plugins namespace: 16 functions.
globals/plugins/awaitingPerson
plugins.awaitingPerson(plugin: string) -> boolean
Whether a call to this plugin is waiting on a person to answer the engine's consent dialog.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.
Returns boolean — True while a dialog for this plugin is unanswered.
if plugins.awaitingPerson(PLUGIN) then print("waiting for you") end
globals/plugins/call
plugins.call(plugin: string, method: string, ...: any?) -> any
Call a method the plugin at plugin exposes.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL: the same stringasset.identityanswers for it (motionfor a plugin in this world,@publisher::path.namefor one in a library), or its path. A computed identity is refused: runtime code has no dynamic requires and a plugin is no exception, because a name the reference deriver cannot read at authoring time is a dependency that never enters the graph.methodstring— A method the plugin'splugin.yamlexposes. One it does not is not callable, whatever the component carries....any(optional) — The call's arguments: numbers, strings, booleans, nil, buffers and tables of them. A whole number arrives as an integer. One call's arguments hold at most 16,384 values (a table held by several entries counted at each) and 64 MiB of strings and buffers; a call past that, or holding a table inside itself, is refused by name. Bulk data crosses as a buffer.
Returns any — A promise of the plugin's answer, as a value: a table as a table, a number as a number. A refusal raises where it is awaited.
local agents = await(plugins.call("@builtin/plugins/dotbot.plugin", "agents"))
globals/plugins/isLoaded
plugins.isLoaded(plugin: string) -> boolean
Whether the plugin is loaded and answering calls.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL.
Returns boolean — True while it is loaded. Never raises: a caller asking is usually waiting for a plugin that is still loading.
while not plugins.isLoaded("motion") do task.wait(0.1) end
globals/plugins/off
plugins.off(plugin: string, id: number) -> boolean
Stop a listener plugins.on started.
Parameters
pluginstring— The same identity the listener was started with.idnumber— The idplugins.onanswered.
Returns boolean — Whether a listener was removed.
globals/plugins/on
plugins.on(plugin: string, listener: (string, any) -> ()) -> number
Listen to the events a plugin raises.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.listener(string, any) -> ()—function(eventType, payload)—payloadis the event's decoded JSON.
Returns number — The subscription id, for plugins.off.
local id = plugins.on("@builtin/plugins/dotbot.plugin", function(kind, body) end)
globals/plugins/openUrl
plugins.openUrl(plugin: string, url: string) -> any
Ask the person to open one of the plugin's own pages.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.urlstring— An https URL whose host the plugin declared undernetwork.hosts. Anywhere else is refused — otherwise this would be an unbounded way to put an address in front of somebody.
Returns any — A promise: true when it opened, or the refusal.
await(plugins.openUrl("@builtin/plugins/dotbot.plugin", "https://claude.ai/login"))
globals/plugins/state
plugins.state(plugin: string) -> { state: string, reason: string? }
Where the plugin asset at plugin stands, so a caller can tell a
plugin that is still loading from one that failed to load.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL.
Returns { state: string, reason: string? } — { state, reason }. state is loaded (answering calls), loading (its component is compiling and starting), failed (its most recent load settled without a plugin), stopped (the plugin stopped on its own) or none (no load of it has started). reason says why for failed and stopped. Never raises.
local s = plugins.state("motion")
if s.state == "failed" then print("motion did not load: " .. s.reason) end
globals/plugins/status
plugins.status() -> { [string]: any }
What the plugin host loaded, and what refused to load.
Returns { [string]: any } — started is whether the host has run; plugins lists each one with loaded, and the error that refused it where there is one. Once the host has run, execution states how plugin code runs: native (compiled to the CPU's own instructions, the desktop build), interpreted (wasmtime's Pulley interpreter, every Android build) or browser (the browser's own WebAssembly engine). On the web build it also carries what the browser offers of JavaScript Promise Integration, which every plugin's host calls are lowered onto.
local report = plugins.status()
print(report.started, #report.plugins)
typed/builtin//modules/api/engine/plugins/plugins/awaitingPerson
plugins.awaitingPerson(plugin: string) -> boolean
Whether a call to this plugin is waiting on a person to answer the engine's consent dialog.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.
Returns boolean — True while a dialog for this plugin is unanswered.
if plugins.awaitingPerson(PLUGIN) then print("waiting for you") end
typed/builtin//modules/api/engine/plugins/plugins/call
plugins.call(plugin: string, method: string, ...: any?) -> any
Call a method the plugin at plugin exposes.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL: the same stringasset.identityanswers for it (motionfor a plugin in this world,@publisher::path.namefor one in a library), or its path. A computed identity is refused: runtime code has no dynamic requires and a plugin is no exception, because a name the reference deriver cannot read at authoring time is a dependency that never enters the graph.methodstring— A method the plugin'splugin.yamlexposes. One it does not is not callable, whatever the component carries....any(optional) — The call's arguments: numbers, strings, booleans, nil, buffers and tables of them. A whole number arrives as an integer. One call's arguments hold at most 16,384 values (a table held by several entries counted at each) and 64 MiB of strings and buffers; a call past that, or holding a table inside itself, is refused by name. Bulk data crosses as a buffer.
Returns any — A promise of the plugin's answer, as a value: a table as a table, a number as a number. A refusal raises where it is awaited.
local agents = await(plugins.call("@builtin/plugins/dotbot.plugin", "agents"))
typed/builtin//modules/api/engine/plugins/plugins/isLoaded
plugins.isLoaded(plugin: string) -> boolean
Whether the plugin is loaded and answering calls.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL.
Returns boolean — True while it is loaded. Never raises: a caller asking is usually waiting for a plugin that is still loading.
while not plugins.isLoaded("motion") do task.wait(0.1) end
typed/builtin//modules/api/engine/plugins/plugins/off
plugins.off(plugin: string, id: number) -> boolean
Stop a listener plugins.on started.
Parameters
pluginstring— The same identity the listener was started with.idnumber— The idplugins.onanswered.
Returns boolean — Whether a listener was removed.
typed/builtin//modules/api/engine/plugins/plugins/on
plugins.on(plugin: string, listener: (string, any) -> ()) -> number
Listen to the events a plugin raises.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.listener(string, any) -> ()—function(eventType, payload)—payloadis the event's decoded JSON.
Returns number — The subscription id, for plugins.off.
local id = plugins.on("@builtin/plugins/dotbot.plugin", function(kind, body) end)
typed/builtin//modules/api/engine/plugins/plugins/openUrl
plugins.openUrl(plugin: string, url: string) -> any
Ask the person to open one of the plugin's own pages.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.urlstring— An https URL whose host the plugin declared undernetwork.hosts. Anywhere else is refused — otherwise this would be an unbounded way to put an address in front of somebody.
Returns any — A promise: true when it opened, or the refusal.
await(plugins.openUrl("@builtin/plugins/dotbot.plugin", "https://claude.ai/login"))
typed/builtin//modules/api/engine/plugins/plugins/state
plugins.state(plugin: string) -> { state: string, reason: string? }
Where the plugin asset at plugin stands, so a caller can tell a
plugin that is still loading from one that failed to load.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL.
Returns { state: string, reason: string? } — { state, reason }. state is loaded (answering calls), loading (its component is compiling and starting), failed (its most recent load settled without a plugin), stopped (the plugin stopped on its own) or none (no load of it has started). reason says why for failed and stopped. Never raises.
local s = plugins.state("motion")
if s.state == "failed" then print("motion did not load: " .. s.reason) end
typed/builtin//modules/api/engine/plugins/plugins/status
plugins.status() -> { [string]: any }
What the plugin host loaded, and what refused to load.
Returns { [string]: any } — started is whether the host has run; plugins lists each one with loaded, and the error that refused it where there is one. Once the host has run, execution states how plugin code runs: native (compiled to the CPU's own instructions, the desktop build), interpreted (wasmtime's Pulley interpreter, every Android build) or browser (the browser's own WebAssembly engine). On the web build it also carries what the browser offers of JavaScript Promise Integration, which every plugin's host calls are lowered onto.
local report = plugins.status()
print(report.started, #report.plugins)