Skip to content

Script API Reference

All functions and objects available in the Muxit script sandbox.

Device Access

APIDescription
connector(name)Get a device proxy by name
device(name)Alias for connector()
javascript
const psu = connector("psu");
await psu.voltage()          // read property
await psu.voltage(12)        // write property
await psu.reset()            // execute action
await psu.rampTo(24)         // call custom method

Logging

APIDescription
log.info(msg)Info-level log
log.warn(msg)Warning-level log
log.error(msg)Error-level log
log.debug(msg)Debug-level log
console.log(msg)Alias for log.info()

Events

APIDescription
emit(event, data)Publish event (namespaced as script:<event>)
on(event, handler)Subscribe to events (auto-cleaned on stop)
stream(connector, stream, data)Emit stream data to dashboards

Timing

APIDescription
delay(ms)Async sleep (abortable on stop)
timestamp()Current ISO 8601 UTC string

AI

APIDescription
ai(prompt)Single-shot LLM call, returns string
ai(prompt, image)LLM call with vision (image analysis)
say(text)Send message to Chat Panel (spoken via TTS)

Script Lifecycle

APIDescription
script.runningtrue while active, false after stop
script.nameThis script's filename (without .js)

Standard Globals

Math, JSON, Date, parseInt, parseFloat, isNaN, isFinite, Number, String, Boolean, Array, Object, Map, Set, Promise

Not Available

require, import, fs, process, net, http, child_process, eval, Proxy, Reflect, global, globalThis


For detailed explanations and examples, see the Script Guide.

Muxit — Hardware Orchestration Platform