Apps
Declared tools
A site can say which of its actions are tools: a form, a live load, a click, or something an in-page island does. A declaration is data in the site document. toolsOf turns a page's declarations into a list with a JSON Schema for each input.
Nothing here reaches a built page, unless tools are on and a listed plug-in supplies a tool script. Without both, the compiler writes nothing of agents, tool, acts or a field's description, so every page, script, island module and header file of a built site is byte-identical with and without them (
packages/tools/__browser__/tools.spec.ts); the one difference is the build identity in culm-manifest.json, which is a hash of the document. With both, a page whose tool is drawn carries the tool table, the marks and the script's tag, loads in full on a swap site; when at least one page carries a table, every page's policy names the script. The one plug-in in this repository that supplies a tool script is @culmjs/webmcp; its README says how to set it up and what each tool does when called.
The data
All keys are optional and live in the site document at schema version 2.
Where
Key
Holds
Where
The site
Key
agents: { tools: true }
Holds
The site's switch. Absent: tools are off
Where
A node
Key
tool: { name, description, confirm? }
Holds
One tool. confirm: "visitor" is for a form's tool only; absent, a form submits when the tool is called
Where
An island node
Key
acts: ["name", …]
Holds
Which of the island's declared acts the page offers
Where
A field
Key
props.description
Holds
The description of its parameter
Where
An island
Key
acts: [{ name, description, class, input? }]
Holds
The acts it has, in its descriptor (islands.md)
A name is 1 to 128 characters from A-Z, a-z, 0-9, _, - and the full stop. A description is plain text: not empty after trimming, with no < and no >. Culm sets no length limit on a description, no limit on how many tools a page has, and does not refuse control characters in it.
acts is not called actions, because a block's setting actions already have that name.
What can carry a tool
A tool needs exactly one of these origins. An island node carries acts and no tool.
Origin
The declaration is on
Parameters
Class
Origin
Live form (live.load: "submit")
The declaration is on
The form
Parameters
One for each visible field its send reads, named as send names it
Class
send
Origin
Static form (posts to the deploy host's form address)
The declaration is on
The form
Parameters
One for each visible field, by the name it posts under
Class
send
Origin
Trigger-loaded live node (live.load: "trigger")
The declaration is on
The live node
Parameters
One for each visible field its send reads, named as send names it
Class
read or send
Origin
Click trigger doing set, toggle, step or scrollTo
The declaration is on
The node with the trigger
Parameters
None
Class
page
Origin
Click trigger doing open or close of a layer, on a button with no command of its own
The declaration is on
The button
Parameters
None
Class
page
Origin
An act of an in-page island
The declaration is on
The island node, in acts
Parameters
The act's declared inputs
Class
As declared
A trigger-loaded tool is class read when its live source is read with GET (the default) and none of the node's then or else replies stores a value, clears one or navigates. Otherwise it is send.
A trigger-loaded live node needs exactly one firing node: one other node whose click or submit trigger does load of it. toolsOf reports it as fire.
A trigger-loaded tool has parameters only when the live node is itself a form, because only a form can send a field. A form cannot also be the list that draws the rows, so today no document can both send a field's value and draw what comes back.
Visible field. A field is visible when it is not hidden on every one of the three layouts (desktop, tablet, phone). The form's trap input (website) and a static form's hidden form input are never parameters. A live-form field with no key cannot be named by send, so it is never a parameter.
Names are unique on a page. Tools and offered acts share one namespace, counted over the page, the header and the footer.
A tool on a node hidden on some layouts is listed like any other. One hidden on every layout is refused.
The input table
input is a JSON Schema object: { type: "object", properties, required? }. A field's type comes from its name and input props, read top to bottom; the same table is INPUT_TABLE in packages/core/src/document/tools.ts.
Field
Schema type
Field
input is password
Schema type
none: the tool is refused
Field
name is message
Schema type
string
Field
input is number
Schema type
number
Field
anything else
Schema type
string
Island setting type (an act's input)
Schema type
Island setting type (an act's input)
number
Schema type
number
Island setting type (an act's input)
switch
Schema type
boolean
Island setting type (an act's input)
select, text, textarea, color, asset
Schema type
string
Island setting type (an act's input)
link
Schema type
no row: it cannot be an act input
A field parameter's description is the field's description, else its label, else its placeholder; a field with none of the three is refused. A field whose required prop is on is listed in required. A static form posts a field under email, message, subject, and otherwise name. An act's parameter takes the setting's key and label, and none is listed as required.
What a built page carries
A page carries something only when all of these hold: the build is of a published page (not an editing or measuring build), the site's tools are on, a listed plug-in supplies a tool script, and at least one of the page's tools has an element that was drawn.
Marks. data-t="<name>" on a tool's element (several acts of one island are separated by spaces) and data-tf="<name>" on the firing element of a trigger-loaded tool. A tool whose element is not drawn, or whose firing element is not, is left out.
The table. One inert
<script type="application/json" id="culm-tools">with one entry for each tool: n name, d description, i input schema, c class (r, p or s), k kind (c click, f form, t trigger-loaded, a island act); w: 1 when a form waits for the visitor; l: 1 for a live form or a trigger-loaded tool; p, each parameter's name to its field's data-key (live) or posted name (static); s, the state a click changes. The table and the marks are experimental.
The script.
<script defer src="/_culm/agent.js">with an integrity hash, which the site policy lists (policy.md).
Full loads. On a swap site a page with a table is loaded in full, not changed in place.
toolsOf
toolsOf(doc: SiteDocument, registry: Registry, pageId: string): ToolEntry[]
type ToolEntry = {
name: string
description: string
input: JsonSchema // empty `properties` for a click trigger
class: 'read' | 'page' | 'send'
node: string // the node that carries the declaration
fire?: string // the node whose trigger loads a live node
confirm?: 'visitor'
}It is exported by @culmjs/core (the code is
packages/core/src/validate/origins.ts) and needs no browser and no I/O. It walks the header, the page and the footer with components unrolled, so a part of a component has the id <use>.<part>. It lists the declarations whether or not agents is on, so a person can see what would be exposed before anything is. It never throws; a declaration with no single origin is left out, and validateSite says why. It expects a validated document.
What validation refuses
With INVALID_NODE:
a tool on a node with no origin, or with more than one;
a click that does something else than the table says, or a node that also does more: a second click trigger, a link, or a command of its own;
a live form with a submit trigger;
a static form that a script intercepts (it has a submit trigger, or a live node at or inside it);
a trigger-loaded node with no firing node or more than one;
a firing node that does more than load: a second trigger on that event, a link, a command, or its own live load on submit;
a firing node inside a repeating node, or hidden on every layout (by itself or by something around it; a component part is judged where its use puts it);
two visible fields of a static form that post under one name;
a parameter with no description, label or placeholder;
a declaration inside a repeating node, inside a component used more than once on the page, on a component use itself, or on a node hidden on every layout;
a tool with a key other than name, description and confirm; a name outside the grammar above; a description that is empty or not plain text; confirm on anything but a form's tool;
two tools or acts of one name on a page;
acts on a node that is not an in-page island, beside a tool, empty, or naming an act the island does not declare.
With POLICY_VIOLATION:
a tool on or inside a form that holds a password field, or run through a firing node on or inside such a form.
A key this version does not know is refused as everywhere else.
Turning tools on
agents going from absent to { "tools": true } is the one guarded change. Declaring a tool, even one that sends without the visitor, is open to an agent, and so is turning tools off.
toolsOnGuard, exported by @culmjs/tools beside protect, refuses (POLICY_VIOLATION, rule agents) a setAgents that turns tools on, and a restore to a revision that has them on when the site now has not. protect does not cover this.
culm mcp on a folder chains protect, then toolsOnGuard unless the project allows it, then the package lock. A project allows it in culm.json:
{ "agents": { "mayTurnToolsOn": true } }It is on only when the whole file parses and holds the literal true. A missing or unreadable file, a parse error or any other value is off. The file is read only when the guard would refuse, so a person's edit takes effect without restarting the server. No MCP tool, flag or environment variable changes it.
A server your product builds must chain both guards itself. It never reads the setting, so a remote caller cannot turn tools on. One that passes protect alone has no guard on turning tools on:
import { createMcpServer, protect, toolsOnGuard } from '@culmjs/tools'
createMcpServer({
// …
allow: (op, doc, head) =>
protect(op, doc, head) ?? toolsOnGuard(op, doc, head),
})The command line
culm agents on prints every declared tool and a count, then asks for the site's name, typed. With input or output not a terminal it exits 2 and changes nothing. The change is a recorded revision. If the site changes while the question is open, nothing is turned on.
culm agents off asks nothing and needs no terminal.
culm check prints, for each page that declares one, each tool's name, class, whether it waits for the visitor, and description, on or off, and says which. It does not change the exit code. Long texts are cut and unprintable characters are shown as \u{hex}.
culm approve lists the acts a package's islands declare (packages.md).
Over MCP, find returns a node's tool entry with its input schema, and update and insert set a tool (mcp.md).
After a person edits culm.json, site.json or a page, piece or block file while culm mcp runs, the server's next commit is refused once with REVISION_CONFLICT, as after any hand edit. Sent again from the new revision, it passes.
Previous