window.oniyanma
Once the app is open, window.oniyanma is available. From the browser's developer console, you can call the exact same command layer the UI uses.
[oniyanma] window.oniyanma ready — oniyanma.tools() / oniyanma.execute(name,args) / oniyanma.getState() / oniyanma.connectRelay(url,room)Edits issued from here are recorded with actor api (name: 'window.oniyanma'), and destructive commands go through the confirmation gate.
Commands
tools()
Returns an Anthropic tool-use-compatible list of tool definitions (ToolDef[]). An external agent can drive oniyanma just by reading this and calling execute().
oniyanma.tools()
// → [{ name: 'setColorMode', description: '…', input_schema: { … } }, …]commands()
An array of just the command names. Shorthand for tools().map(t => t.name).
oniyanma.commands()
// → ['setColorMode', 'setPointSize', …]execute(name, args?)
Executes a command. Returns a Promise.
await oniyanma.execute('setColorMode', { mode: 'elevation' }) // → { ok: true }
await oniyanma.execute('queryElevation', { bins: 8 })
await oniyanma.execute('deleteSelection', { confirm: true })An unknown command name, an argument type mismatch, or a surface violation throws. → Return values and error conventions
getState()
A snapshot of the current state. → State snapshot
oniyanma.getState()
// → { backend: 'webgpu', colorMode: 'elevation', sources: [...], alignedBounds: [...], … }Collaboration
joinRoom(url, room?, name?)
Joins a collaboration room. room defaults to your own room (an unguessable UUID), and name defaults to 'guest'.
oniyanma.joinRoom('wss://oniyanma-demo.pages.dev/collab', undefined, 'Yamada')inviteLink(server?)
Returns the invite URL for the current room. Anyone who opens this link joins the same room automatically.
oniyanma.inviteLink()
// → 'https://…/?collab=wss://…&room=<uuid>&name=…'The sync server rides along even without passing server. Without ?collab=, the recipient wouldn't auto-join, producing the confusing failure of "I sent the link but they never showed up".
leaveRoom()
Leaves the room.
showPeerMarkers(visible)
Toggles the display of other participants' viewpoint/selection markers.
oniyanma.showPeerMarkers(false)MCP relay
connectRelay(url, room?)
Connects to the command relay coordinator as a viewer. This is what lets an MCP client operate this browser. room defaults to 'oniyanma'.
oniyanma.connectRelay('ws://localhost:8787', 'bridge1')
// → 'connecting to ws://localhost:8787 room=bridge1'disconnectRelay()
Disconnects the relay.
Debugging
debugInput()
Returns a snapshot of input state. Meant for narrowing down "rendering works but input alone isn't responding".
oniyanma.debugInput()Usage examples
Select the top 20% slab, check the count, then delete it:
const { alignedBounds: b } = oniyanma.getState()
const zTop = b[5] - (b[5] - b[2]) * 0.2
await oniyanma.execute('selectBox', { min: [b[0], b[1], zTop], max: [b[3], b[4], b[5]] })
await oniyanma.execute('deleteSelection') // → preview: only the count comes back
await oniyanma.execute('deleteSelection', { confirm: true })Count points per classification:
await oniyanma.execute('queryClasses')
// → { total: 1234567, counts: { '0': 1200000, '2': 34567 } }File and publish a finding:
const { id } = await oniyanma.execute('createFinding', {
typeId: 'damage',
fields: { kind: 'ひび割れ', grade: 'c' },
pin: [x, y, z],
})
await oniyanma.execute('publishFinding', { id })