Skip to main content
Every HTML app runs in a sandboxed frame with a window.runchat object already on the page. It is how the app talks to Runchat: running published tools, storing state, running the app’s commands, editing the scene and, in Rhino app tools, reaching the user’s Rhino. The same object is available in three places, so one HTML file works in all of them: Every method returns a Promise. Calls made before the host page is ready are queued and sent once it is, so you can call them as soon as your script runs.

Methods

Methods without a tick reject with UNSUPPORTED in that place.

runchat.ready

A Promise (not a function) that resolves when the host page answers:

runchat.user()

Who is using the app: { signed_in, id, handle, name }. Signed-out visitors get { signed_in: false }.

runchat.run()

Runs a published tool on Runchat’s servers and resolves when it finishes. Resolves with { status, outputs, error, credits }. status is "success" or "error", and outputs is keyed by the tool’s output names. The run is billed to the person using the app, so they must be signed in. On a published app, signed-out visitors are prompted to sign in and the call rejects with SIGNED_OUT.

runchat.upload()

Uploads a File or Blob and resolves with its hosted URL, ready to pass to runchat.run as an image or file input. Needs a signed-in user. The default timeout is 2 minutes; pass { timeout } as the second argument to change it.

State

State is a small key-value store for the app. Each call takes an optional { scope }:
In the canvas preview, "user" state is kept in your browser as test state and does not carry over when the app is published. "shared" state is the app node’s live state, saved with the workflow. Generated media URLs saved into state on a published app are copied to permanent storage, so they keep working after the provider’s temporary links expire.

runchat.state.apply()

Applies a list of changes to shared state in one step. Canvas only for now.

runchat.state.subscribe()

Calls fn with the whole shared state straight away and again on every change, whether it came from this page, another person or an agent. Returns a function that stops the updates. Canvas only for now.

Limits

  • Each key holds up to 256 KB. Split large documents across several keys.
  • Up to 1,000 keys per app, and up to 200 changes in one apply.

runchat.command()

Runs one of the app’s commands, defined in its commands.js, on Runchat’s servers. Resolves with the command’s result and applied, the state changes it made. The default timeout is 2 minutes. Canvas only for now. See Writing commands.

Scene

Canvas only for now. scene.subscribe(fn) calls fn with the objects in the workflow’s Scene, now and whenever they change. scene.edit(ops) edits the scene as the person using the app, with the same operations as the edit_scene tool, and resolves with one result per operation. Run runchat use_skill --name html-code for the full list of operations.

Rhino

runchat.rhino reaches the Rhino of the person using the app. It only works in a Rhino app tool that they have installed, while Rhino is open with the Runchat panel connected. Anywhere else, the calls reject with UNSUPPORTED. capture accepts view, display_mode, camera_location, camera_target, frame ("all", "selection" or object ids), width and height. The person’s own view is restored afterwards. runScript takes language: "python" (default) or "csharp". Set a runchat_result variable in the script to return data in output. Each run is one undo step in Rhino.

Canvas preview only

In the canvas preview, runchat.setNodeOutputs(outputs) writes values to the HTML Code node’s outputs, so an app can feed the rest of the workflow:

Errors

Failed calls reject with an Error whose code says why:
Calls that take longer than their timeout reject with a timed out message. The default is 15 seconds, except where noted above.