Script and meta
This section is the normative definition of a Rundown action script, contract v1. Every host
follows it: the iPhone and Mac apps, rundown-cli and the companion server. The TypeScript
declarations in sdk/rundown.d.ts describe the same contract in machine-checkable form, and
actions/examples/ holds working references.
File format
Section titled “File format”An action is one JavaScript file (ES2022) that exports a class extending Action:
// @ts-check/// <reference path="../../sdk/rundown.d.ts" />module.exports = class MyAction extends Action { static meta = { apiVersion: 1, id: "com.example.my-action", name: "My action", version: 1 }; async run(ctx) { /* … */ } onNotify(previous, current, ctx) { /* … */ } summary(current, ctx) { /* … */ }};- The export uses CommonJS (
module.exports = …);exports.default = …is also accepted. ES moduleimport/exportsyntax is not supported. - There is no
require, no filesystem, nofetchand no DOM. A script can only use JavaScript built-ins and what the runtime provides:ctx(see The ctx object)consolesetTimeoutandclearTimeoutActionandNotImplementedError
- Top-level code runs once per run, when the script is loaded. It cannot perform I/O and must finish within 5 s.
- A fresh, isolated context is created for every run. Nothing survives between runs except the state and the store (see Lifecycle and state).
The class
Section titled “The class”| Member | Required | Network | Description |
|---|---|---|---|
static meta |
yes | — | Metadata (below). |
run(ctx) |
yes | yes | Fetches and computes. Returns the new state: any JSON-serializable value, where undefined becomes null. |
onNotify(previous, current, ctx) |
yes | no | Decides what to notify about. Returns a notification, an array of notifications, or nothing (null, undefined, false or []). |
summary(current, ctx) |
yes | no | Returns the feed card (Summary and blocks). |
validate(ctx) |
no | yes | Called by Test Run in the item settings to check inputs such as credentials. To fail, throw an error with a readable message. |
Any method may be async. The loader rejects a script that doesn’t extend Action, doesn’t
override all three required methods, or has invalid meta. It reports every problem it finds, with
line numbers for script errors.
| Field | Type | Default | Notes |
|---|---|---|---|
apiVersion |
1 |
required | The contract version. |
id |
string | required | Reverse-DNS style identity (letters, digits, ., -, _; at most 100 characters). It must stay stable across versions. |
name |
string | required | At most 60 characters. |
version |
integer ≥ 1 | required | Importing a higher version of the same id is an update. |
description |
string | — | At most 500 characters. |
icon |
{ symbol } or { emoji } |
— | symbol is an SF Symbol name. |
schedule |
"manual" or { every, min? } |
{ every: "1h" } |
every is the default interval and must be at least 1m. min (default: every or 5m, whichever is shorter) is the shortest interval a user may set. |
timeout |
duration | "20s" |
Time limit for run(), from 1s to 60s. In the background it is also capped by the time iOS has left. |
permissions.hosts |
string[] | [] (no network) |
See Network permissions. |
inputs |
object | {} |
Keyed by input name, in form order (below). |
notifications |
object | {} |
Keyed by notification type (below). |
Unknown fields are errors, so typos surface at import time. Durations are strings made of
number+unit segments: ms, s, m, h or d, for example "90s", "15m" or "1h30m".
Inputs
Section titled “Inputs”Input names must be identifiers. Every input spec has type and label, and may have
description, placeholder and required (default false).
type |
Value in ctx.inputs |
Extra fields |
|---|---|---|
string, text (multiline), url (http(s) only) |
string | default |
secret |
string | none; secrets have no default |
number |
number | default, min, max, step |
boolean |
boolean | default |
choice |
string (an option value) | options: (string | { value, label })[] (required), default |
list |
string[] | default |
Before running, the host resolves inputs:
- It applies defaults.
- It checks types and ranges.
- It fails with an
inputserror if a required input is missing.
Optional inputs without a value are absent from ctx.inputs, not null. Secrets are stored in the
Keychain and are never exported. Their values are masked (••••) wherever they appear in logs,
error messages, summaries and notifications. A secret copied into the returned state or into
ctx.store is masked in the saved copy too, and a warning is logged: read secrets from
ctx.inputs on every run instead of keeping them.
If a required input has no value (for example a new required input added by an update, or a secret that was never entered), the item needs setup. It is not run, and no failure is recorded, until the user fills it in.
Notification types
Section titled “Notification types”Each type has label (required), description, default (on for new items; default true) and
level. level is "passive", "active" (the default) or "timeSensitive". Users can switch each
type on or off per item. Notifications of undeclared types are dropped with a warning.
Installing and updating
Section titled “Installing and updating”Scripts come in from a file, an https link, pasted text, the bundled examples, the on-device editor
or the Actions folder. Every path shows a preview first — what the script is, the network access it
asks for (any-host entries such as * or *:993, and unencrypted ones such as http:// or
tcp://, are flagged), the settings it needs and the notifications it can send — and nothing is
installed until the user confirms.
- The action’s identity is
meta.id. Importing a script with an installed id replaces that action; its items keep their settings, secrets, state and store. - The preview says whether the script is an update (higher
version), a replacement (same version, different code), older, or identical (nothing to do). - For updates it lists what changes: new or removed network access, new required settings (and how many items will need setup), removed or retyped settings, notification types, and the schedule.
- Links:
https://…only (http://localhostis accepted for development). A link that returns a web page is rejected with a hint to use the raw file. Scripts are at most 1 MB. rundown://import?url=<percent-encoded link>opens the same preview from anywhere.
The Actions folder installs changes that ask for nothing new without the preview.
Versioning
Section titled “Versioning”apiVersion changes only for breaking changes. Within v1, additions are backwards compatible: new
optional ctx members, new block types (older apps skip them), and new optional fields.