Skip to main content
Build real-time interfaces that show code execution as it happens. The client talks to an @enclave-vm/broker over HTTP. Tools run on the broker; the client is told about each tool call and gets the result of the script. The examples below assume a broker at http://localhost:3001 with the tools users:list and users:process registered.

Basic Streaming

execute() resolves with the result; a session that fails is not a rejected promise. executeStream() returns a handle at once (sessionId, wait(), cancel(), getEvents(), isActive()), and onEvent receives every event.
The broker emits no stdout events, and a script cannot use console in the broker’s sandbox unless the broker is configured for it. Show progress with the tool-call events, as below. To stream console output, see Streaming with your own endpoint.

React Streaming Hook

@enclave-vm/react has a ready-made hook, useEnclaveSession (see @enclave-vm/react). This one is built on the client directly, to show what such a hook does:

Streaming Console Component

Tool Call Timeline

Complete Streaming UI

Streaming with your own endpoint

Without the broker, an endpoint of your own can stream what a script does with @enclave-vm/core directly. This one uses Server-Sent Events and the consoleHandler option, which hands the script’s console lines to the host:
This endpoint runs whatever code it is sent: put your authentication in front of it, and bound the size of the request body.

Progress Indicators

Next Steps