Skip to main content
API reference for the @enclave-vm/broker package - the orchestration layer for EnclaveJS.

Installation

EnclaveBroker Class

The main broker class for session management and tool orchestration.

Constructor

BrokerOptions

Methods

listen(port)

Start the HTTP server.
Example:

close()

Stop the server and clean up.

execute(code, options?)

Execute code and return a stream.
Options:
Example:

getSession(sessionId)

Get session information.

submitToolResult(sessionId, callId, result)

Submit a tool call result.

HTTP API Endpoints

POST /execute

Execute code with streaming response. Request:
Response: NDJSON stream of events Example:

GET /sessions/:sessionId

Get session status. Response:

POST /sessions/:sessionId/tool-result

Submit tool execution result. Request:
Response:

GET /code/actions

Returns the current action catalog derived from connected OpenAPI sources. Response:
Version semantics: The version field is a deterministic hash of all source spec hashes. It changes whenever an OpenAPI spec is polled with additions or removals. Consumers can compare version strings to detect catalog changes. Example:
Wiring: Use CatalogHandler to register this route:
The types CatalogAction, CatalogService, CatalogResponse, and CatalogHandler are all exported from the @enclave-vm/broker package.

GET /health

Health check endpoint. Response:

ToolRegistry Class

Registry for managing tools.

Constructor

Methods

register(tool)

Register a tool.
Example:

get(name)

Get a tool by name.

list()

List all registered tools.

getDocumentation()

Get tool documentation for LLM prompts.

RuntimePoolOptions

Authentication

Example:

Rate Limiting

Example:

Events

BrokerEvents

Complete Example