Skip to content
Moku Labs
@moku-labs/editor pages

agent

The editor-agent core on the game page: registry, channel, perf, recorder, overlay, and the opt-in bridge and capture.

On this page

What it is

@moku-labs/editor/agent is the editor-agent core. It runs on the game page, or headless in Bun. It is the only place the editor touches the game's doors. A debug build on a phone carries the same core.

PluginSetTierPurpose
registrydefaultComplexWraps the game's doors, .dev modules and editor.* commands into entries; builds the Manifest.
channeldefaultStandardThe in-process EditorChannel.
perfdefaultComplexThe performance read model: a 6 s frame window and the cause of each spike.
recorderdefaultComplexThe performance log on the device, off until someone starts it.
overlaydefaultComplexThe editor's window over the game: hidden, pill or card.
bridgeopt-inComplexThe websocket from the game page to the hub.
captureopt-inStandardScreenshots on demand, never on its own.

bridgePlugin and capturePlugin are opt-in: a dev entry adds them in plugins. The engine's page agent, @moku-labs/editor/agent/page, starts the core with both. Options are on Configuration.

registry

The only place the editor touches the game's doors. It wraps doors, .dev modules and editor.* commands into entries, and builds the Manifest with the page's build and every command's allowed, reason and overlay marker. It emits registry:command for every run, with who ran it (via). It owns the runtime-free protocol the root entry exports.

APIWhat it does
manifest()The manifest: sources, commands, the build.
source(id), command(id)One entry, or undefined.
add(entry)Adds an editor command or source. Call it in onInit.
envelope()Where the game stands now: { path, frame, tainted }.
clock(), game(), build()The clock, the game app, the page's build.

channel

The in-process EditorChannel: an immediate read on watch, runs off the frame loop, and a timer heartbeat that beats while the game is paused.

API: read, watch, run, status, heartbeat, onHeartbeat.

perf

Reads the engine monitor's frame ring four times a second into a 6 s window, ranks the causes of every spike, and serves the overlay and Mission control's feeds. It is off, with its reason, when the game has no monitor.

KindNames
APIstatus, readWindow, second, spikes, spike, monitor
Sourceseditor.perf.second, editor.perf.window, editor.perf.spikes, editor.perf.spike, editor.spikes, editor.perf.frames, editor.perf.events, editor.perf.passes, editor.perf.detail
Commandeditor.perf.sections

recorder

The performance log on the device. Nothing records until the phone, the tools page or an agent starts it, and startedBy says who. It keeps every monitor line for hours, in OPFS chunks or in memory, rotates at maxLogMb, shares a finished log, and keeps an outbox the bridge ships. It also writes the editor's devtools, command and recorder events.

KindNames
APIstart, stop, mark, status, files, share, remove, unsentRun, ack
Commandseditor.record { on?, label?, mark? }, editor.mark
Sourceeditor.recorder, with the last 32 marks

overlay

The editor's window over the game, on a phone or a dev page: hidden, a pill, or a card with the tabs Frames, Game, Record and Link. It sets globalThis.__MOKU_GAME_OVERLAY__ for the engine's app.debug.overlay. See On a phone.

KindNames
APIopen, close, toggle, isOpen, mode, commands
Commandeditor.overlay { mode }

bridge

Opt-in. The websocket from the game page to the hub: hello, requests, throttled values, a backoff reconnect, and the checkpoint across Bun's reload. It runs each hub run with who sent it. On a phone it is the device link: it dials the hub's device listener, pairs by a code and ships the recorder's log.

KindNames
APIstatus, session, link, connect
Commandseditor.reload, editor.clock

capture

Opt-in. Screenshots on demand, never on its own. JPEG by default; format and quality change it.

Commands: editor.capture, editor.series, editor.seriesStop, editor.sheet.

Events

EventKindEmitted byHooked by
bridge:statusglobalbridgeoverlay
overlay:changedglobaloverlayrecorder
overlay:connectglobaloverlaybridge
registry:commandper-pluginregistryrecorder
recorder:statusper-pluginrecorderoverlay, bridge

Payloads are on Events.

  • registry.game is required. onInit throws without it.
  • The bridge and capture are opt-in. Without the bridge the page never reaches the server.
  • The overlay lists only the game's commands. A game marks its own .dev commands overlay: "button" or "toggle".