Contents

Create panel

panel_create · Tools · Workspace

Save a new panel

Parameters

NameTypeRequiredDescription
descriptionstringNoWhat the panel is for, in one sentence.
htmlstringNoThe main HTML document, stored as index.html. At most 262144 bytes. Left out, the panel starts with a short starter document.
namestringYesWhat the panel is called, such as `Lights`.
tablesstring[]NoThe tables the panel may read every row and column of with verdalia.api.queryTable, each by its id or its slug as list_tables gives them. Each is stored as the id it names; one naming no table is refused.
vendorsstring[]NoThe vendor identifiers the panel may resolve, such as `verdalia-ui.js` or `verdalia-preact.js`.
workflowsstring[]NoThe workflows the panel may call with verdalia.api.executeWorkflow, each by its id or its slug. Each is stored as the id it names; one naming no workflow is refused.

Panel Create Tool#

panel_create saves a new panel: an HTML page people open from the navigation, such as a dashboard with buttons that run workflows. Its HTML becomes index.html, the main asset of the panel's first version, which people see at once. To add the panel to the navigation, add a page showing it with create_page and its panel parameter.

When to Use#

The agent uses it when the user wants a page of their own to see or control something: lights, a queue, a status board. The work a button does is a workflow; the panel shows its result.

Parameters#

Parameter Type Required Description
name string Yes What the panel is called, such as Lights
description string No What the panel is for
html string No The main HTML document, stored as index.html; at most 262,144 bytes. Left out, the panel starts with a short starter document
workflows array of strings No The workflows the panel may call, each by its id or its slug as list_workflows gives them; the slug aliases the id and either is accepted. Each is stored as the workflow's id
tables array of strings No The tables the panel may read with verdalia.api.queryTable, each by its id or its slug as list_tables gives them; the slug aliases the id and either is accepted. Each is stored as the table's id. The panel can read every row and column of each one
vendors array of strings No The vendor libraries the version may use, each by its identifier, such as verdalia-ui.js. Stored exactly as given: a vendor listed without one it imports is refused

What a panel can do#

A panel runs in a frame with no network access: no fetch, and nothing loaded from another site. Its scripts, stylesheets and SVG images are assets of its version, referenced from the HTML as asset:NAME:

<link rel="stylesheet" href="asset:verdalia-ui.css">
<div id="app"></div>
<script type="module" src="asset:app.js"></script>

A version's assets are added with panel_update files. Verdalia's vendor libraries are separate: they come with Verdalia, are never assets, and a version names the ones it may use with panel_update vendors or with vendors here. They are verdalia-kit-1.js, verdalia-kit-1.css, verdalia-preact.js, verdalia-preact-hooks.js, verdalia-preact-jsx-runtime.js, verdalia-htm.js, verdalia-ui.js, verdalia-ui.css, verdalia-uplot.js, verdalia-uplot.css and verdalia-iconify.js. A list names every library each of its vendors imports: verdalia-preact-hooks.js and verdalia-preact-jsx-runtime.js need verdalia-preact.js; verdalia-ui.js needs verdalia-preact.js, verdalia-preact-hooks.js and verdalia-htm.js. A module imports a vendor module by its bare specifier: preact, preact/hooks, preact/jsx-runtime, htm, @verdalia/ui, uplot or iconify-icon. verdalia-iconify.js defines <iconify-icon icon="ph:house">, which fetches icons of the ph, lucide, simple-icons and logos sets from Iconify; an icon of any other set renders empty. Raster images and fonts are data: URIs. The panel's way out is window.verdalia:

const result = await verdalia.api.executeWorkflow({
  workflow: "01JC4Z8Q2V6M3K9T1R5X7B0N4D", // one of the panel's workflows
  startNode: "input-2",                  // the id (not the label) of one of its Input nodes; needed when it has several
  input: { room: "office" },             // becomes that Input node's value
  wait: true,                            // default; waits up to 5 minutes
  onProgress: (event) => {},             // {type: 'started' | 'node' | 'waiting', …}
});
// { status: "succeeded", jobId, output }

wait: false resolves at once to { status: "started", jobId }. The call runs as the person viewing the panel, and a workflow that is not on the list of the panel's current version is refused with the code not_allowed. A failure rejects with { code, message, jobId? }. A workflow that declines what it was asked returns the output { ok: false, error: { code, message } }, and the panel checks for it.

The panel also has verdalia.api.queryTable for the tables in tables, verdalia.api.onEvent, verdalia.app.open, params, setParams, onParamsChange, copy and badge, verdalia.context and verdalia.ready; the Panels page of the docs, get_docs("panels"), describes each one, the UI kit, and how to match Verdalia's look. Its page always declares the app's colors, corner sizes and shadows as --verdalia-* CSS variables, each best used with a fallback; get_docs("panel-colors") lists every one with its value.

verdalia.api.onEvent(key, (event) => {}) calls the listener with { key, payload, sentAt } for each event a workflow's Send User Event step sends on that exact key with "Send to listening clients" on, and returns a function that stops listening; it needs no grant. A panel that should show changes made elsewhere listens and reads again when an event names what it shows, rather than polling: the payload carries only an id or a small status, never the data itself.

Returns#

Field Type Description
id string The new panel's id
revision integer Its settings revision, 1
page_urls array of strings The full URL of every navigation page that shows the panel; empty when none does
editor_url string The full URL of the panel's editor in Settings

Example Scenario#

{
  "name": "Lights",
  "description": "Switch the office lights",
  "html": "<h1>Lights</h1><button id=on>On</button><script>document.getElementById('on').onclick = () => verdalia.api.executeWorkflow({ workflow: '01JC4Z8Q2V6M3K9T1R5X7B0N4D', input: { on: true } });</script>",
  "workflows": ["01JC4Z8Q2V6M3K9T1R5X7B0N4D"]
}

Notes#

  • The first version is what everyone who opens the panel sees. Each later change with panel_update or panel_push writes a new version from the current one, or from another one by id
  • A workflow that no id or slug names is refused, naming the reference
  • A table that no id or slug names is refused, naming the reference. A slug that names more than one table is refused the same way rather than picking one
  • A vendor identifier that is not one Verdalia ships is refused
  • A vendor list that leaves out a library one of its vendors imports is refused, naming both
  • HTML over 262,144 bytes is refused
  • To add the panel to the navigation, read the revision with list_pages, then call create_page with name, expected_revision and panel set to the returned id
  • Risk: write