Visual Nerve Script is the language for Behaviors. A definition contains the source and its language version. A binding attaches an event-driven definition to a node and supplies that instance’s parameters. A manual workflow takes parameters when you run it. Lingo inspired the handler blocks and reusable Behaviors. Visual Nerve Script defines its own syntax, node types and kinds of work a script can request.
For setup, troubleshooting and editable templates, see the Behaviors guide .
Language versions and host support
| Version | Language support | Where it runs |
|---|---|---|
| 1 | Typed parameters, event handlers, conditions, target renaming, immediate messages and reserve requests | The local 2D editor and Process Simulator. |
| 2 | Version 1 features, plus else, typed locals, addition, instance properties, counted repeats, status changes and delayed messages |
The local 2D editor and Process Simulator. |
| 3 | Version 2 features, plus manual workflows, diagram settings, node creation, connections, drawing and presentation video | The same version 2 hosts. Workflow actions require a local editable 2D diagram without a simulation model. |
The production workspace enables the Behavior library by default. Staging and development use ?behaviors=1. Every saved source requires approval in the current open diagram before execution.
Every definition keeps its stored version. A version 1 definition continues to use version 1 syntax and behavior. You can inspect source saved under a version the current app cannot execute. Such a definition reports an unsupported-version diagnostic at line 1, column 1. The language version is independent of the native diagram or workspace backup format version.
Source and identifiers
Write one declaration, handler delimiter or statement per line. Indentation helps readability. The parser accepts LF, CRLF and CR line breaks. Blank lines are ignored. A # outside a quoted string starts a comment that runs through the end of the line.
Names and keywords are case-sensitive. Identifiers start with a Unicode letter or underscore and can continue with Unicode letters, numbers or underscores. Dots belong to the event fields listed below. A parameter, property or local name cannot use the language’s reserved words. Version 1 reserves the type names, plus parameter, as, on, end, if, then, and, rename, to, send, open, reserve, slot, using, true, false, event and queue. Version 2 also reserves local, else, set, property, repeat and after. Version 3 adds run, diagram, create, named, at, connect, draw, line, rectangle, from, color, width, export and video.
Types, literals and parameters
| Type | Values | Example |
|---|---|---|
text |
Double-quoted strings. JSON escapes represent a quote, backslash, newline or other Unicode character. | "Ready #2" |
number |
Decimal integers from −9,007,199,254,740,991 through 9,007,199,254,740,991. | -4, 15 |
boolean |
The exact literals true and false. |
true |
node |
A typed reference to a node, resolved by the host. | event.target or a node parameter such as receiver |
resource |
A typed reference to a simulation resource. | A resource parameter such as staffing |
Declare parameters before handlers with parameter NAME as TYPE. A text, number or boolean parameter can supply a literal default with = LITERAL. Configure a node or resource parameter on each binding by choosing the object. The stored value is its stable ID. A quoted label is a text value. If a required parameter has no default, enter a valid value before enabling the binding.
Each binding has its own values. Handler code can read parameters and event fields. The host checks a reference’s availability and compatibility when validating the binding.
Conditions, operators and scope
Start a condition with if CONDITION then and close it with end if. A condition is a boolean expression or a comparison. Join conditions with and. In version 2 or later, put an optional else on its own line before end if. The interpreter runs the selected branch. Both branches must be valid source.
Operators are listed from highest to lowest precedence.
| Operators | Versions | Evaluation |
|---|---|---|
+ |
2 and 3 | Adds safe integers from left to right. Each intermediate result must be a safe integer. |
==, !=, <, <=, >, >= |
1–3 | Equality and inequality compare values of the same type. Ordering comparisons require numbers. A comparison takes one expression on each side. |
and |
1–3 | Evaluates conditions left to right and stops at the first false result. |
Versions 2 and 3 support local NAME as TYPE = EXPRESSION and set NAME to EXPRESSION. A local can use any of the five types. Its name becomes usable after its initializer, in the rest of the block and its nested blocks. Branches and repeat bodies have separate scopes. A local cannot shadow an in-scope name. Declared locals initialize on each handler invocation and, inside a repeat, on each iteration. Assignment requires the value’s declared type.
In versions 2 and 3, repeat COUNT and end repeat form a counted loop. The interpreter evaluates COUNT once before entering the loop. It must be an integer from 0 to 32. Zero skips the body. The compiler checks the body in every case. The eight-block nesting limit counts if and repeat together.
Binding and execution lifecycle
A definition needs at least one handler. Start a handler with on EVENT and close it with end. Each named event and each exact quoted message name can occur once per definition. A definition can contain both editor and simulation handlers. On a given event, the host evaluates eligible, enabled bindings in their saved order and supplies the matching handler’s event fields.
In the 2D editor, a manually created connection evaluates eligible bindings on the source card. Accepted title and status changes form one undoable edit with the connection. When proposals disagree on a field, that field keeps its former value and the trace shows the conflict. Opening, importing, API graph writes, reconnecting an existing edge, undo and redo do not start a handler. Behaviors run in local diagrams outside active collaboration sessions.
The simulator captures active source, version, effective binding parameters and order, initial state, model and seed at the start of a run for replay. A scenario can override whether a binding participates and the values it receives. Unspecified values inherit from Baseline. Changing a definition or scenario affects later runs, while replay uses the original capture.
Versions 2 and 3 support property NAME as TYPE = LITERAL for simulation. Declare up to 16 properties before the handlers, using text, number or boolean initializers. A simulation handler reads the property by name and writes it with set. Each binding has independent state initialized at the start of each run. A successful handler commits its state before the host evaluates the proposed actions. A routine host denial, such as busy staff, retains the new state. An interpreter diagnostic discards that handler’s writes and proposals. Editor handlers cannot read or write properties.
Events and event fields
| Handler | Context | Compatible node | Readable fields |
|---|---|---|---|
on connectionAdded |
Editor | An editable source card for the new outgoing connection | event.edgeId (text), event.source (node), event.target (node) |
on queueChanged |
Simulation | A Work node whose waiting queue changed | queue.previousLength (number), queue.length (number) |
on "message name" |
Simulation | The Work node identified by the send action | event.source (node), event.target (node) |
on run |
Editor | Runs without a node binding | None |
Events expose only the fields listed in their row. The queue length counts waiting items. Queue fields describe the specific committed queue change, even if the simulator processes other events at that timestamp.
Actions
A successful handler returns proposals in source order. The host applies graph validation, resource rules and permissions to those proposals. Each proposal includes its source position for tracing.
| Action syntax | Versions | Events and context | Compatible target or resource |
|---|---|---|---|
rename target to title |
1–3 | connectionAdded in the editor |
The new connection’s target card in the editor host. The title is text. |
set status of target to status |
2 and 3 | connectionAdded in the editor |
The new connection’s target card. Choose planned, in-progress, blocked, done or empty text to clear. |
send "message name" to node target [after seconds] |
1–3 for immediate sends. Versions 2 and 3 also support after seconds. |
queueChanged and quoted message handlers in simulation |
A Work node referenced by its stable ID, including the sending Work node when explicitly selected. |
open reserve slot using resource staffing |
1–3 | queueChanged and quoted message handlers in simulation |
The Work node handling the queue change or message. The selected resource must satisfy its staffing configuration. |
set diagram setting to enabled |
3 | run and connectionAdded in the editor |
Set "grid", "snap" or "rulers" to a boolean. |
create node type named title at x y as result |
3 | run and connectionAdded in the editor |
Create an ordinary node using a type such as "note", a text title and diagram coordinates. result names a new node local for later statements in the block. |
connect source to target |
3 | run and connectionAdded in the editor |
Connect two different nodes from the same diagram. An existing equivalent connection is kept. |
draw line from x1 y1 to x2 y2 color ink width thickness |
3 | run and connectionAdded in the editor |
Draw a line between two different points on the drawing layer. |
draw rectangle from x1 y1 to x2 y2 color ink width thickness |
3 | run and connectionAdded in the editor |
Draw a rectangle from opposite corners with nonzero width and height. |
export video from source |
3 | run in the editor |
Export the configured presentation with "nodes" or "storyboard". |
Square brackets in the send row mark an optional clause. A reserve request opens one extra slot and tries to start the next waiting item using normal staffing allocation. Use Close reserve slot in the simulator to remove an idle slot immediately or let its current item finish before removing it. A saved run records when you close it so replay can reproduce the decision. The action supports one unit of one staffing resource, including shared pools, normal schedules and resource-side scaling. Work-side autoscaling and infrastructure staffing are outside its scope.
Run a manual workflow
In a local editable 2D diagram, open Behavior library, choose New behavior, and select language version 3. Add an on run handler and choose Activate source. For a saved or imported definition, review Saved source and choose Allow saved source. Then expand Manual workflow, supply any required parameters and choose Run workflow. Running uses the approved saved version and source in this tab. The workflow needs no node binding.
Coordinates are diagram units. Use hex colors such as "#334455" and a stroke width from 1 to 32. Created nodes and connections are normal diagram objects. Lines and rectangles are saved in the native drawing layer. The workflow saves diagram changes together as one undoable edit. When a node-bound connectionAdded handler adds workflow geometry, it joins the initiating connection edit. Script-created edges do not start more handlers.
Use one export video as the last executed action. Set up a node presentation or storyboard before running. The export starts after diagram changes are saved and uses the presentation’s existing order and timing, without narration or subtitles. Created nodes do not automatically join that order. Keep the diagram tab visible until the browser finishes the download. Cancel workflow can cancel the video. A cancelled or failed video leaves already saved diagram changes available to undo.
Messages, simulated time and order
A send names an explicit receiving node and a double-quoted message. Names match exactly, including case, and must contain non-whitespace content, exclude control characters and fit within 80 UTF-16 code units. A quoted handler receives only messages with that exact name.
Immediate sends are queued for the current simulated time. The simulator processes them after the current handler and normal dispatch. Equal-time Behavior work runs in engine sequence order. A receiver with no active matching handler is recorded in the trace.
In versions 2 and 3, after SECONDS accepts an integer from 0 through 86,400 in simulated seconds. Omitting after and using after 0 produce the same immediate proposal. Delayed deliveries follow due time, phase and enqueue sequence across senders. A normal run horizon includes messages due at the horizon. Drain mode continues into queued work and its follow-ups. Cancellation discards pending messages, and replay uses the same captured inputs to reproduce delivery order.
Running limits and diagnostics
| Limit | Value |
|---|---|
| Source length | 16,384 UTF-16 code units |
| Source lines | 256 |
| Parameters per definition | 16 |
| Identifier length | 200 UTF-16 code units |
| Nested blocks | 8 |
| Instructions per handler | 128 |
| Action proposals per handler | 32 |
| Message name length | 80 UTF-16 code units |
| Message hops per cause | 16 |
| Sends per originating timestamp | 128 |
| Sends per run | 4,096 |
| Properties in versions 2 and 3 | 16 |
| Repeat count in versions 2 and 3 | 0–32 |
| Delay in seconds in versions 2 and 3 | 0–86,400 |
Each executed statement and evaluated conjunct counts as one instruction. Versions 2 and 3 also count each addition after the first operand and each repeat iteration, including an empty one. The simulator budget counts all sends from a handler together. Delivery can reach depth 16. A handler reached at depth 16 can run without sending another message. The simulator also caps pending messages at 4,096, accepted enqueues at 4,096 per run and deliveries at 128 per due timestamp. These checks are separate from the interpreter’s send limits.
A diagnostic includes a readable message and a one-based line and column. The column counts UTF-16 code units. These are the diagnostic categories.
| Type | Where to look |
|---|---|
version |
The saved language version and the version supported by the host. |
syntax |
The marked token, missing delimiter or invalid placement. |
type |
The marked operand or value, including an unsafe integer result. |
context |
The event, field or action’s permitted host and handler. |
binding |
The parameter or property declaration and the instance’s saved values. A reference may be unavailable. |
limit |
The first source position or operation that exceeds a budget. |
Save unfinished source with Save draft. Use Activate source to save and allow a valid revision. For source already saved, review it and choose Allow saved source. This permission applies in the current tab while the diagram is open. A runtime rejection appears in the Behavior trace. An invalid simulation configuration can prevent run start. A resource decision such as busy staff is a host outcome recorded in the trace.
The Behavior library shows the language version and keeps the working draft separate from the active source. For supported versions, the source editor highlights syntax and suggests terms for the current handler. Use Suggestions or press Ctrl+Space in the source field. Use the arrow keys to move through suggestions, Enter or Tab to insert, and Escape to dismiss.
Select a diagnostic’s line and column to jump to the problem. A trace link opens the recorded source at that line. Saved simulation runs use the source and language version captured when the run started, even after you edit the definition. Opening captured source leaves replay approval unchanged.
Examples
The version on each example identifies the parser to use. For version 1 simulation examples, attach the two definitions to compatible Work nodes and choose the referenced node and staffing resource on their respective bindings.
Rename a connected card
Version 1 · Editor. Attach to the source card. Connect it to another card. The target becomes Quality check, or the binding’s value of nextName. Undo restores the previous title and removes the connection together.
# Bind to the source card.
parameter nextName as text = "Quality check"
on connectionAdded
rename event.target to nextName
end
Signal when a queue crosses a threshold
Version 1 · Process Simulator. With the default threshold of 15, a rise from 15 to 16 sends open checkout. A rise from 16 to 17 sends nothing. Select a Work node as receiver.
parameter threshold as number = 15
parameter receiver as node
on queueChanged
if queue.previousLength <= threshold and queue.length > threshold then
send "open checkout" to node receiver
end if
end
Request a reserve slot
Version 1 · Process Simulator. Attach to the receiving Work node and select its ordinary staffing resource. The message open checkout proposes one reserve opening. The simulator checks whether the Work node can start the next waiting item.
parameter staffing as resource
on "open checkout"
open reserve slot using resource staffing
end
Propose a title and status
Version 2 · Editor. A new connection sets Standard review and in-progress on the target. An urgent binding sets Priority review as its title. Undo restores both fields and removes the connection.
parameter urgent as boolean = false
parameter nextStatus as text = "in-progress"
on connectionAdded
local title as text = "Review"
if urgent then
set title to "Priority review"
else
set title to "Standard review"
end if
rename event.target to title
set status of event.target to nextStatus
end
Count queue increases and send later
Version 2 · Process Simulator. Each binding counts its own queue increases during a run. At the second increase it proposes open checkout for delivery three simulated seconds later. A falling queue leaves the count unchanged.
parameter receiver as node
parameter delay as number = 3
property increases as number = 0
on queueChanged
if queue.length > queue.previousLength then
set increases to increases + 1
if increases == 2 then
send "open checkout" to node receiver after delay
end if
end if
end
Propose a bounded batch of messages
Version 2 · Process Simulator. A batch ready message proposes two inspect item sends by default. A binding can choose any count from 0 to 32. A zero count proposes no sends.
parameter receiver as node
parameter count as number = 2
on "batch ready"
repeat count
send "inspect item" to node receiver
end repeat
end
Add a connected note and export the walkthrough
Version 3 · Manual workflow. Set up a node presentation first. In Manual workflow, select an existing card as anchor. The workflow shows the grid, adds a connected Follow up note and frames it with a rectangle. Its last action exports the configured node presentation.
parameter anchor as node
on run
set diagram "grid" to true
create node "note" named "Follow up" at 240 180 as followUp
connect anchor to followUp
draw rectangle from 220 160 to 470 320 color "#334455" width 3
export video from "nodes"
end