Menu
Sign inDownload

Add-on API reference

Every manifest key, permission, hook and call, and which version each arrived in.

The contract for add-ons. Comms Array is an endpoint hub: it provides game data and a few actions; add-ons do the work. Each add-on runs in its own process, talks to Comms Array over a local socket, and gets only what the user allowed. This is the only add-on format: Comms Array never loads add-on code into itself.

This is the spec; Make an add-on is the short way in. Every object both halves of an add-on get, field by field, with the names we use inside Comms Array: Add-on objects. Each game's tags, values and panels by id: Games.

The zip

Players install it from the Add-ons tab, signed in (a free account).

manifest.json
my_package/__init__.py         create(api) -> your add-on object
my_package/pad_my.js           optional: the pad side
{"name": "hello", "package": "ca_hello", "version": "2.0.0", "title": "Hello",
 "description": "...", "author": "you",
 "api": 1,
 "permissions": ["pad.widgets", "events.game"],
 "widgets": ["hello_counter"], "pad_js": "pad_hello.js",
 "depends": {"other_addon": ">=1.0"},
 "provides": ["count"]}

Every key is checked: a key not in this table, or a value of the wrong type, and the zip is refused (the hub refuses it on publish too). A typo never passes silently.

FieldMeaning
namerequired. Lowercase letters, digits, _ (2-31). Used in URLs (/api/pad/mod/<name>)
packagerequired. Your package folder's name; must not clash with anything Comms Array already has
versionrequired. Your version, e.g. "1.2.0" (depends compares these)
titlerequired. Shown on the Add-ons tab (60 characters)
description, authortext, optional
apirequired: 1. A zip without it is in the older format and is refused
api_versionoptional, "1.N" (default "1.0"): the v1 features you use. A Comms Array with an older 1.x refuses you with "needs a newer Comms Array" (see "Versions and stability")
permissionswhat you ask for (below). The user ticks what they allow; you can only get what you list
widgetspad widget types you register in your pad script
pad_jsyour pad script, in the package folder
pages1.2. Ready-made pad pages the player adds in one tap (see "Ready-made pages" below)
dependsother add-ons you need: ">=1.2", "==1.2.0" or "1.2" (= >=). Installing you from the hub installs (or updates) them from the hub too. Comms Array won't start you without them and stops you when they stop
providesfunctions other add-ons may call on you (they need uses.<you>.<fn>)
requires"account": you start only while the PC is signed in (free, Discord); signed out the panel says "sign in to use" and your widgets stay in layouts. Nothing is paid
tierignored: the hub's tier for your add-on (unverified / verified / official) is Comms Array's call, signed into each download
gamesthe game ids you support, e.g. ["starcitizen", "elite"]. Without it you support only the first game. You run only while a game you support is active; permissions are granted per game (official add-ons get their first grants in every game they list)

Permissions

Permissions decide what you get from Comms Array: game data, game actions, key presses, the pad. Your add-on is still a program on the player's PC, and outside Comms Array it can do what any program can (files, the network). Comms Array doesn't control that and says so to the player (Add-ons tab, commsarray.com/addons); the trust tier (official, verified, or "your own · unreviewed") is how they decide whom to trust. Say clearly what your add-on does.

PermissionGives you
state.livelive game state: on_state(state) up to 10/s (a change inside that window arrives when it ends), api.latest_state (the game's own shape), api.latest_pad and (await api.state())["pad"] (game-neutral: {"tags": [...on], "metrics": {id: value}, "lamps": {action: lamp}}, each value as the pad shows it, see "Values" below; descriptions in api.active_game). 1.5: lamps is what lights the pad's buttons, by action id ("on", "off", "busy"; {} when the game isn't live), and api.lamp(action) reads one, None when the game doesn't report it: an LED on your own hardware follows the game as a pad button does
events.gameon_event(event): downed, dead, respawn, ship destroyed, missile warning, ... (each game's list: docs/dev/events.md)
events.journalon_journal(event): the game's raw log events (for Star Citizen: Game.log missions, ships destroyed / lost, med beds, jurisdictions). Never chat or other players' names: the game engine drops chat and social events and strips name fields first
actions.pressawait api.press(action, hold_ms=None): game actions, same rules as the pad. 1.5: at most 10 presses a second, 20 at once, per add-on, counted with your key taps and holds (input.keys); past that, AddonError 429 rate_limited. With this or input.keys, await api.catalog(q=, subject=, ids=, limit=200): the game's actions as the pad's widget picker lists them (subjects, one row per thing with its Toggle / On / Off variants, key, api, lit, holdable, dangerous, where), so your setup screen can map an input to an action. 1.5: await api.button(action, op="tap", hold_id=None) presses the way the pad's Button does: a tap on an action the game offers goes through the game (this permission); any other action, and a hold ("down", then "up" with its hold_id), goes by its current key (input.keys). await api.set(action, "on" | "off") leaves a lit thing in a state (a physical toggle switch, one call per direction): it presses the form that sets that state (Deploy / Retract) when the game has it, else the Toggle only when the lamp says the state differs ({"already": true} when it doesn't), else 409 unknown_state with where to bind the form
actions.dangerousthe actions the game engine marks dangerous: api.press(action, confirm=True). Off unless the user ticks it
input.keysawait api.keys(op, ...): key presses into the game window, with the same rails as the pad's buttons that press keys (only if the player switched key presses on for the game, only while the game window has focus; holds let go when you stop). release_all lets go of your own holds only. op: tap / down / up / alive / release_all with keys="ctrl+q" or action="..." (a game action, pressed with its current key), lookup (an action's current key), actions (search the game's bindings, q=), check (combos=[...] normalised, "" if not a real key), status. Key names are US QWERTY places; a letter follows the player's Letters mean choice (its place, or the key that types it on their layout, with Shift / AltGr if that layout needs them), digits and symbols (` `, -, [ ...) are always that place. **1.5:** tap and down count towards the press limit above; taps of one key take turns (never merging into one longer press), at most 10 waiting, else 429 busy; a hold you make with down stays down until your up` (Comms Array keeps it alive for you)
keys.read1.7. The game's key bindings, read only: await api.keys("lookup", action=...) (an action's current key), api.keys("actions", q=...) (search the bindings), api.keys("check", ...) and api.keys("status"), and await api.catalog(...) with every row's key (as actions.press gives it). It presses nothing: tap, down, api.button, api.set and api.press still need their own permissions. For an add-on that shows or checks keys (an overlay warning that the game already uses a key) without pressing them. Your companion program's login gets the same (docs/pad-api.md)
pad.widgetsyour pad script runs (sandboxed) on the user's pads; handle_pad gets its requests
devices.loginawait api.device_login(name) -> a paired-device token for your own companion program (e.g. an overlay), api.device_revoke(id). The program gets what a paired pad gets (docs/pad-api.md), except: the party only if you also have party.read (1.1); game actions only with actions.press, key presses only with input.keys, dangerous ones also actions.dangerous (your grants, live). It can never answer the pad's "is this you?" question. Your logins are revoked when you're removed or devices.login is unticked
devices.login (1.6)also await api.pad_info() -> {"url", "on"}: where a program on this PC opens the pad (http://127.0.0.1:<port>/pad?local) and whether phone & tablet control is serving. See "Companion programs"
account.statusawait api.account() -> {signed_in, account} (never the login); account = the PC holds a valid license, so account-only features work
party.read1.1. Your active party, as the pad's party tile shows it: await api.party(), api.latest_party, on_party(party) when it changes (at most once a second), and CA.party in your pad widgets. See "The party" below. Never granted on install, even to official add-ons: the player ticks it
game.infoawait api.game() -> {engine, game, ...}: the active telemetry engine's id and status, plus what that engine says about where the game is (Star Citizen: channel_dir, game_log)
uses.<addon>.<fn>await api.call(addon, fn, body): a function another add-on provides

Anything you weren't granted raises AddonError with .code == 403 and .body["permission"]. Ungranted endpoints are not "hidden", they are refused by Comms Array for every call.

Your object

create(api) returns an object with any of these (all optional, sync or async):

async start() / async stop()
on_state(state)                       # state.live
on_event(event)                       # events.game: {"type", "data", "ts"}
on_journal(event)                     # events.journal
on_party(party)                       # party.read (1.1): the party changed; None when the player unticked it
on_game(game)                         # the active game changed (no permission): {id, engine_version, name, status,
                                      #   tags, metrics (the value descriptions)}; also api.active_game
async handle_pad(device, body) -> (dict, int)        # pad.widgets: POST /api/pad/mod/<name> from a paired pad
async handle_call(fn, caller, body) -> (dict, int)   # another add-on calling one of your `provides`
device_gone(device_id)                # a pad disconnected: let go of anything you held for it

api also has: name, permissions, data_dir (your own folder for settings), set_status(dict) (handed to your pad frames as CA.pad.status), log (goes into Comms Array's log, labelled with your name). Every field, call, return value and error, field by field: Add-on objects.

Pad side

Your pad_js never runs in the pad page. Each of your widgets gets its own sandboxed frame (/pad/sandbox.html: an opaque origin with no network, no storage, no cookies, no popups); the pad hands your script to the frame as text, with the widget's settings and the live state, and checks every message the frame sends back. You can draw; you can't reach the pad page, the player's login or anything else on the device.

CA.widget("hello_counter", {
  add: { label: "Tap counter", desc: "…", size: [1, 1], props: () => ({ label: "Taps" }) },  // the Add widget list
  settings: [                                         // drawn by the pad in edit mode; values land on the widget
    { key: "label", type: "text", label: "Label", max: 40 },          // text | number | select | checkbox | value
    { key: "metric", type: "value", kind: "gauge", label: "Shows" },  // one of the game's values (the pad's picker)
    { type: "panel", panel: "editor", label: "Open the editor…" },    // a button that opens one of your panels
  ],
  tile(root, w, { editing }) {                        // draw into root (pad.css classes work: "w b", "sub", "lamp"…)
    root.innerHTML = `<div class="w b"><span>${CA.esc(w.label)}</span><span class="sub"></span></div>`;
    const sub = root.querySelector(".sub");
    return { update(state) { sub.textContent = CA.value(w.metric).t; } };   // every live update
  },
  panels: { editor(root, w) { CA.sheet(`<h3><span>Editor</span><button id="x">Done</button></h3>`,
                                       (r) => r.querySelector("#x").onclick = () => CA.close()); } },
});

In the frame: await CA.call(body) (your handle_pad JSON, or {status: "offline"}; your own add-on only), CA.toast(text), CA.buzz(ms), CA.openPanel(name) (only right after the player tapped your tile), CA.close(), await CA.pickAction() (1.5, with actions.press or input.keys, right after a tap: the pad's own action picker over your frame; the chosen catalogue row, or null), CA.sheet(html, wire), CA.share(data) / CA.onShare(fn) (between your own frames, e.g. the editor telling the tiles), CA.onState(fn), CA.state, CA.pad (profiles, profile_groups, glossary, your add-on's status), CA.esc, CA.clamp, CA.flash(el, ok), CA.party (1.1, with party.read: the party, else null). A frame that floods messages or navigates away is removed. If you need another add-on, call it from Python through uses.*. Each member, the settings field types, the widget's fields, the live state, the pad.css classes you can use and every limit: Add-on objects, "The pad side".

A widget can show any of the game's values, exactly as the built-in widgets do: keep the value's id on the widget (a value setting, as above), then CA.value(id) in your update(state) gives the presented value (below; t: "—" when the game doesn't have it), CA.describe(id) its description, and CA.values("gauge" | "readout" | "parts") the ids a widget of that kind can show.

Button packs

1.3. When the player's layout uses a button pack (its cockpit-hardware style, Button packs), your widgets blend in without knowing anything about packs:

  • The plate. Your tile sits on the pack's own plate, as the pad's gauges and readouts do; your frame is inset to the plate's face, on a clear background. A kind that draws edge to edge (a map, a camera) says so with add: { plate: false } and keeps the whole tile.
  • The colours. On the plate, the pad's CSS variables in your frame are the pack's: --text, --dim, --ok, --warn, --bad, --off, --accent, plus --pk-lamp, --pk-accent, --pk-well, --pk-edge, --pk-face. pad.css classes ("w b", sub) and anything you colour with these follow the pack with no code: a "w b" box goes clear so the plate shows. CA.plated says whether this tile is on a plate.
  • **CA.pack**, in every frame (tiles and panels): {name, face, accent, lamp, ok, warn, bad, off, well, edge, text, dim, round, segmented}, or null without a pack. Use it where the variables don't reach (a canvas, an SVG you build). Panels and plate: false tiles get it as data only, since their background isn't the plate (a light pack's dark text would vanish on the pad's dark sheet).

fine is the pack's lamp colour; warning is amber and bad red in every pack. When the player switches packs, your frames are drawn again with the new one. Every part of a pack by the name we use for it (plate, rim, pinline, face, decorations, lamp, glow, track, knob, grip...), its states, how it stretches and how to draw with its colours: Button packs. The pack's own parts (its lamps, bars, rings and screens, drawn for you by class name) arrived in 1.4: see "Your widget in the pack's parts" there.

Ready-made pages

1.2. A tool that wants a whole screen (a trade planner, a mining dashboard) ships it as a page: your widgets laid out with the pad's own (buttons, gauges, readouts, labels, the party). In edit mode the player taps + Page (or Add a page in the Page sheet) and picks yours from the list, under its title and "from" your add-on's title. It's added to their layout in one tap, and from then on it's their page: they move, resize, delete or add anything, and you never change it again. Split your screen into widgets that make sense on their own (the list, the detail, the action) and let them talk with CA.share / CA.onShare: the player can then keep the parts they want. Use the pad's buttons for game actions rather than drawing your own: they follow the player's keybinds and button pack.

"api_version": "1.2",
"widgets": ["trade_routes", "trade_run"],
"pages": [{"title": "Trade run", "desc": "Routes, loops and the run you picked", "cols": 6,
           "when": ["landed"], "priority": 10,
           "widgets": [{"type": "trade_routes", "x": 0, "y": 0, "w": 4, "h": 6},
                       {"type": "trade_run", "x": 4, "y": 0, "w": 2, "h": 4},
                       {"type": "button", "action": "v_toggle_landing_system", "label": "Gear", "x": 4, "y": 4, "w": 2, "h": 1}]}]
Page fieldMeaning
titlerequired, 24 characters. A title the layout already has gets a number ("Trade run 2")
descoptional, 120 characters: one line under the title in the list
colsthe grid you drew it for, 2-32 (default 4; the built-in Tablet has 24 columns, the Phone 12). Cells are square, so on a layout with another number of columns the page is scaled to it (places and sizes alike) and keeps its look
when, priorityoptional: switch to the page by itself in these situations (the same tags and numbers as the pad's Page sheet)
widgets1-80, each type, x, y, w (up to cols), h (1-40), plus the type's own fields, as in a saved layout (docs/pad-api.md). type is one of the pad's (button, gauge, readout, parts, light, panel, label, spacer, party) or one of your own widgets, never another add-on's. (key, the old Key press, still installs and is read as a button)

Up to 8 pages. The manifest's shape is checked on install and on the hub when you publish; each widget's fields are then cleaned as a saved layout's are, so one the game doesn't have (a value or panel from another game) is left out, and a page left empty isn't offered. Pages need pad.widgets like your widgets do.

Buttons on your page

A button on your page is the pad's own Button, exactly as a player adds one: you name what it presses, and the pad works out how on each player's PC. It presses a game action through the game when the game offers it (Star Citizen 5.0), and otherwise with the key the player has bound to it right now (their rebind, else the game's default), so your page follows every player's own keybinds. It lights from the game's state when the game reports that action's state (the engine's lit_actions), and has no lamp otherwise. If the player hasn't bound the action, the button says where to bind it in the game's own menu. You never ship keys.

{"type": "button", "action": "v_toggle_landing_system", "label": "Gear", "x": 0, "y": 0, "w": 4, "h": 2},
{"type": "button", "action": "v_deploy_landing_system", "label": "Gear down", "x": 4, "y": 0, "w": 4, "h": 2},
{"type": "button", "action": "moveforward", "label": "Auto-walk", "mode": "toggle", "x": 0, "y": 2, "w": 4, "h": 2},
{"type": "button", "keys": "lalt+n", "label": "Voice", "x": 4, "y": 2, "w": 4, "h": 2}
Button fieldMeaning
actionthe game's own action id (v_toggle_landing_system, emote_rude, Elite's LandingGearToggle). A toggle's other forms are actions of their own (v_deploy_landing_system / v_retract_landing_system)
keysinstead of action: a fixed key or combination, up to 4 joined with + (n, lalt+n, f5, num1). Pressed as it is, whatever the game binds to it; no lamp. Use an action whenever the game has one
modetap (default), hold (held while the finger is down) or toggle (tap to hold down, tap again to let go: auto-walk). Hold and Toggle always go by key, so the action needs a key bound
labelup to 40 characters; without one, the action's name
colorblue, green, amber, red, purple, grey, or ""
lampauto (default: lit from the game's state when the game reports it), none, or a situation tag (lit while it's true)
hold_msfor an action the game holds itself: how long, 0-10000
look, iconwith a button pack: push, lamp, slide, vertical, square and one of the pack's icons (docs/dev/packs.md). A look that shows a state (lamp, slide, vertical) needs a button that lights, else it's a push button

Getting the ids right: build it on the pad first. Lay your page out in the designer on your own pad, with the widget picker (its subjects, search and the game's own names make finding an action easy), then Layout → Export and copy that page's widgets into your manifest. Export writes every button's action and the rest exactly as above. Action ids are the game's own, so a page with buttons is for one game: list it in games.

Dangerous actions (eject, self-destruct) are only pressed where the player allows them for phones, and always with a press-and-hold to confirm, by key as through the game.

The party

1.1, permission party.read. The player's parties, whole: nothing is trimmed for you. What each member shares is decided by that member's own sharing switches on their PC; that you see it is decided by this permission. The same everywhere you get it (api.party(), api.latest_party, on_party, CA.party):

{"active": null | {"party": {...the party record}, "name", "status", "playing": n,
                   "members": [...], "help": [...members who need help, longest first],
                   "events": [...every party event Comms Array holds (the last 50), newest last]},
 "active_id": party id | null,
 "parties": [{"id", "name", "role", "invite_code"?, ...}]   the parties this PC can switch to, whole
                                                            (invite_code: a party you lead)}

Each member is their whole record as the hub sends it (member_id, name, role, presence, game, in_game_name, last_seen_day, ...) with summary: everything they share, in their game's own shape (for Star Citizen player, vehicle, ...) plus summary.show, their game's finished texts (show.lines says which texts make each line). On top, for convenience: you, status (their presence, or their game's status while playing: ok, downed, dead, ...), badge, lines (each of the game's lines as text) and line (the first), help (downed or dead while playing), for_s (how long, as this PC saw it), game_name. The active party's labels names each game's show texts (game -> {key: name}, from its engine.json show_labels). Each event is whole too (type, data, message, severity, ts, ...) with key (stable), you, age_s and recent (the last five minutes).

active is null with no active party or while the hub connection is down (never a stale list shown as live). Without party.read, api.party() raises AddonError 403, on_party is never called, and your pad widgets' state has no party at all. Unticking it takes effect at once: you get on_party(None) and nothing more. What you do with other people's names is on you: say clearly in your description why you need the party.

Which game

Every add-on knows the active game without asking: api.active_game (from the start) and on_game(game) on every switch and when the game's engine starts: {"id", "engine", "engine_version", "name", "status", "tags", "metrics"} (id is the game's, whichever engine serves it; engine is that engine's id). Write game-neutral add-ons against tags / metrics (api.latest_pad); api.latest_state is the game's own shape.

Values

Every game describes its values (the full format is in docs/engine-api.md, "Described values"): active_game["metrics"][id] = {label, group, type, range?, unit?, format?, levels?, values?, of?, items?}, with type one of number, bool, enum, text, list. Each game keeps its own ids; nothing promises that two games share one.

Live, each value arrives already formatted and coloured from its description (the same object the pad's widgets draw):

{"v": value, "t": "80%", "level": "ok" | "warn" | "bad" | "off" | "", "pos": 0..1 | null,
 "fresh": "live" | "last_known" | "unknown", "age": seconds | null, "parts": [...] (lists)}

t is the game's own text when it sent one (it says more than the number), else the value formatted from its description. pos is where a number is in its range (a gauge's fill). A list value has parts: [{"label", "v", "t", "level", "pos"}].

Hardware add-ons

1.5. Physical panels (buttons, toggle switches, rotary encoders, LEDs on a Teensy, an Arduino or anything else that plugs into the PC) join Comms Array through an add-on: yours. Comms Array never opens a device itself.

What's yours: the device code, your protocol, your firmware, finding the device and coming back when it's unplugged and plugged in again. Your add-on has Python's whole standard library ("What you can import" in Make an add-on): a USB serial port is CreateFileW / ReadFile / WriteFile through ctypes, raw HID is hid.dll and setupapi.dll the same way, and you can vendor pure-Python code (pyserial's Windows backend is pure Python) inside your package. Run blocking reads in a thread (asyncio.to_thread) so your add-on keeps answering.

What Comms Array gives you:

You wantUsePermission
A button that presses a game action, as a pad button doesawait api.button(action) (a tap); api.button(action, "down", hold_id=...) then "up" for a button held downactions.press for an action the game presses itself, input.keys for the rest and every hold
A toggle switch that puts the game in its positionawait api.set(action, "on") / "off" (below)as the press it makes
An LED that follows the game, as a pad button's lamp doesapi.lamp(action): "on", "off", "busy" (moving: blink it) or None; read it in on_statestate.live
An LED for a situation or a valueapi.latest_pad["tags"] (on while a tag is), api.latest_pad["metrics"][id]["level"] (warn, bad)state.live
A setup screen that maps "button 3" to an actiona pad panel of yours, with await CA.pickAction() (the pad's own picker) or await api.catalog(q=...) through your handle_padpad.widgets, plus actions.press or input.keys
Mappings per gameapi.active_game["id"] and on_game: save a mapping per game id in api.data_dir. Action ids belong to one game; list your games in gamesnone

Toggle switches. Nothing in the game (outside axes) is built for a key held down for as long as a switch stays up. Have your firmware send a momentary press when the switch moves, one per direction ("switch 2 up", "switch 2 down"), never its position as a held input. Map each direction to the state it means, api.set(gear, "on") up and api.set(gear, "off") down, never Toggle on both: a Toggle drifts as soon as one press is missed (the game wasn't focused, the gear was still moving). api.set presses the form that sets the state (Deploy / Retract) where the game has one, so pressing it twice changes nothing; where the game has only a Toggle, it presses it only when the lamp says the state differs and answers {"already": true} otherwise. When the game can't tell (409 unknown_state), its where says where the player can bind Deploy / Retract in the game's own menu: show it on your setup screen. Because only a movement sends anything, plugging the panel in or boarding a ship with the switch down changes nothing in the game; if the switch and the game disagree (gear switch down, gear up), show it on the switch's LED and the next flip puts it right. That's advice, not a rule: it's your add-on.

Encoders and fast inputs. Your add-on may press 10 times a second, 20 at once (every api.press, api.button, api.set and key tap or hold counts); past that you get 429 rate_limited. Taps of one key take turns (two at once would merge into one longer press, and the game would see one step); one that can't start within 2 s is dropped as busy, never pressed late. So count an encoder's detents and send steps at a pace the game takes (about 8 a second for one key), and drop a backlog rather than replay it a second late: a step lost is better than a step pressed after the player stopped turning.

Rules a hardware add-on follows (and what we check before an add-on is verified):

  • Let go of everything you hold when the device is unplugged and when you stop (api.keys("release_all")). Comms Array keeps your holds alive while you hold them and lets go when your process stops, but a button held while its cable was pulled is yours to release. release_all also drops your taps and sets still waiting their turn, and when your add-on stops, nothing it asked for happens afterwards.
  • Don't write to a port or device until you know it's yours: a COM port can be someone's 3D printer. Match the USB ids you expect, or a hello your firmware answers, before you send anything else.
  • Pace your presses as above; treat 429 as "drop this one", never retry in a loop.
  • Dangerous actions (eject, self-destruct) only with actions.dangerous, as everywhere: the player ticks it.
  • Say in your description what hardware you talk to, and where the firmware is.

A device can also be a joystick. A Teensy (and most boards) can present itself as a USB joystick at the same time. If a player would rather bind its buttons in the game's own menu (no Comms Array in the input path, no focus rules for key presses), your add-on can drive only the LEDs: the lamps and values work the same either way.

A sketch of the Python side (the device code and the line protocol are illustrative only; Comms Array doesn't define either):

import asyncio, json, os

class Panel:
    def __init__(self, api):
        self.api, self.leds, self.mapping = api, {}, {}

    async def start(self):
        self.load(self.api.active_game.get("id"))
        asyncio.get_running_loop().create_task(self.read_device())

    def on_game(self, game):                       # a mapping per game: action ids belong to one game
        self.load(game.get("id"))

    def load(self, game):
        path = os.path.join(self.api.data_dir, f"{game}.json")
        self.mapping = json.load(open(path)) if game and os.path.exists(path) else {}

    async def read_device(self):
        async for line in device_lines():          # yours: the serial port, hot-plug, reconnect
            kind, n, what = line.split()           # "BTN 3 DOWN", "SW 2 UP", ...
            m = self.mapping.get(f"{kind} {n}") or {}
            try:
                if kind == "SW" and m.get("action"):
                    await self.api.set(m["action"], "on" if what == "UP" else "off")
                elif kind == "BTN" and m.get("action") and what == "DOWN":
                    await self.api.button(m["action"])
            except Exception as e:                 # AddonError: 429, unknown_state, not focused...
                self.api.log.info("%s: %s", line, e)

    def on_state(self, state):                     # LEDs follow the lamps; write only what changed
        for led, action in (self.mapping.get("leds") or {}).items():
            lamp = self.api.lamp(action)
            if self.leds.get(led) != lamp:
                self.leds[led] = lamp
                device_write(f"LED {led} {'BLINK' if lamp == 'busy' else 'ON' if lamp == 'on' else 'OFF'}")

def create(api):
    return Panel(api)

Companion programs (1.6)

Your add-on is Python with no GUI toolkit, so a window of your own (an overlay, a second screen) is a separate program you ship. With devices.login it signs in like a paired pad and shows the real pad page ("Hosting the pad" in docs/pad-api.md): your widgets and every other installed add-on's, laid out by the player.

  • Ship it in your zip (50 MB in all) and, at start(), copy it to a folder of its version under api.data_dir and run it from there. Never run it from your package folder: updates replace that folder.
  • Sign it in: await api.pad_info() (where the pad is, and whether phone & tablet control is on: say so if it's off) and await api.device_login(name). Keep the login (in data_dir) and reuse it: an add-on has at most 3. Hand the token over on its standard input or in its environment, not on its command line.
  • Stop it with you. Comms Array ends your add-on's own process, not programs you start: end yours in stop(), and make the program exit when your process does (its standard input closing is a good signal).
  • It does what you may. The login presses game actions only with your actions.press, keys only with your input.keys, sees the party only with your party.read. It is revoked when you're removed or devices.login is unticked.
  • Too big for the zip? Link a download in your description and have the add-on only sign it in. Say plainly what the player installs.

Over a game, from what we've tested (Star Citizen, borderless): an always-on-top window that is see-through per pixel and click-through works. Some games swallow the system's hotkeys while they have focus: read keys with raw input or the key state instead, act on them only while the game or your window has the focus, and go back to click-through when the focus leaves. Give the focus back to the game with SetForegroundWindow. Exclusive full screen hides any window.

Rules of the road

  • Your process lives exactly as long as Comms Array: it starts you, restarts you after a crash (a few times), and stops you when it closes or the user switches you off.
  • Updating your add-on restarts your process; Comms Array itself keeps running.
  • Unticking a permission takes effect at once; your pad widgets stay in the user's layouts while you can't use them.
  • What runs on the user's PC outside Comms Array (files, the network) is not something Comms Array controls; say clearly what your add-on does, including any outside service it talks to.

Versions and stability

"api": 1 is the major version; this document is v1.

  • v1 only grows. New permissions, hooks, manifest keys, pad calls and fields can be added. Nothing in v1 is renamed, removed or changes meaning. A change that would break a v1 add-on is v2 ("api": 2), with its own ADR.
  • Each addition says which 1.N it arrived in. Set api_version to the highest 1.N whose features you use; an older Comms Array then refuses to install you instead of failing while running. Everything in this document without a version note is 1.0. This Comms Array serves 1.6 (addons.API_VERSION).
  • 1.1 (28 Nov 2026): party.read (api.party(), api.latest_party, on_party, CA.party). Before 1.1 every add-on's pad widgets received the pad's party in their live state, with no permission; from 1.1 only party.read gets it.
  • 1.2 (28 Nov 2026): pages, ready-made pad pages (above). A manifest with pages and an older api_version is refused.
  • 1.3 (28 Nov 2026): button packs reach your widgets (above): the plate (add.plate: false to opt out), the pack's colours in pad.css's variables, CA.pack and CA.plated.
  • 1.4 (29 Nov 2026): your widgets draw with the pack's parts by class name (pk-tabs, pk-toggle, pk-btn, pk-led, pk-screen, pk-table), CA.lamp, CA.table, CA.fitTable, and the two looks: add.look, CA.look, the player's pick per widget. The pad's grid is square cells, and a ready-made page is scaled to the player's columns.
  • 1.5 (1 Dec 2026): ready for custom hardware ("Hardware add-ons" above): lamps in the live state and api.lamp(action), api.catalog(...) for add-ons that press, add-on presses limited to 10 a second (20 at once), taps of one key taking turns, holds kept alive by Comms Array, and a state change inside the 10-a-second window delivered when it ends. api.button(action, op) (press like the pad's Button), api.set(action, "on" | "off") (a toggle switch that never drifts), CA.pickAction() (the pad's picker for your setup screen).
  • 1.6 (1 Dec 2026): companion programs ("Companion programs" above): api.pad_info(), zips up to 50 MB, and the pad hosted by your program (?bare, window.CAPad in docs/pad-api.md). A layout holds 32 pages. A layout can be Clear (no tile backgrounds or plates, outlined text: for an overlay); your tiles see it as CA.clear.
  • 1.7 (1 Dec 2026): keys.read, the game's key bindings without pressing anything: api.keys lookup / actions / check / status and api.catalog(...). A companion program's login reads the bindings only when its add-on has keys.read, input.keys or actions.press; without one, its catalogue's keys are blank.
  • Read what you don't know as "not there". New fields can appear in messages and values; ignore ones you don't use.
  • The older format is gone. Add-ons without "api": 1 (loaded inside Comms Array, handed the whole app) stopped loading in the build after 26 Nov 2026. One already installed is listed as "made for an older Comms Array" and never starts; its author needs to move it to this API.

Example

Four, from the bones up (all published on commsarray.com/dev):

  • Hello (examples/hello_addon, commsarray.com/dev/addons/example): the bones. A widget that calls its add-on on the PC, a game event, the pack's parts (tabs, a screen, the table, a lamp button), a ready-made page.
  • Landing checklist (examples/landing_checklist, commsarray.com/dev/addons/example-landing): the pad's own buttons on a ready-made page, every way to use them (a game action, a toggle's Deploy form, Hold, Toggle, a fixed key, lit buttons), lights, readouts and a gauge, and one widget that reads the game's live state in its frame.
  • UEX data (our published connector, commsarray.com/dev/addons/example-uex): add-ons sharing data. One add-on owns a web API (UEX's trade data): its cache, one request budget for everyone, one key, back-off; it provides questions (search, offers, places, distances, a cached get) answered inside an add-on call's 256 KB and 10 s. Other add-ons declare "depends": {"uex": ">=1.0"} and uses.uex.<fn> and never talk to the web API themselves; installing one from the hub brings it along.
  • Where to buy (our published add-on, commsarray.com/dev/addons/example-where-to-buy): a real consumer of UEX data. The pack's own colours, a small tile and a big one, a ready-made page, and the game's location with a fallback when the game doesn't give one.

Hello and Landing checklist are tested with every build. Every object field by field: docs/dev/reference.md. Each game's tags, values and panels: docs/dev/games.md. Each game's events: docs/dev/events.md. Button packs: docs/dev/packs.md. What each version added: docs/dev/changelog.md.

From the Comms Array source, commsarray-agent d615c4d.