Minimal standalone runtime host for StateFlowX.
This project demonstrates how to host the StateFlowX Runtime outside of the main monorepo using the published npm packages.
- External npm package consumption
- HTTP JSON-RPC hosting
- WebSocket JSON-RPC hosting
- Multi-transport runtime
- Runtime lifecycle management
- Runtime initialization
- Runtime startup
- Runtime event streaming
- Pluggable provider registration
- Pluggable agent registration
- Realtime observability foundation
npm installCreate a .env file:
GEMINI_API_KEY=your_google_gemini_api_key
OPENAI_API_KEY=your_openai_api_keynode main.mjsThe runtime starts on:
HTTP JSON-RPC
http://localhost:3000/rpc
WebSocket JSON-RPC
ws://localhost:3001
import 'dotenv/config';
import {
bootstrapRuntime,
createRuntime,
RuntimeInitializeApp,
GeminiProvider,
OpenAIProvider,
MockProvider,
} from '@stateflowx/runtime';
const runtime = createRuntime({
providers: [
{
name: 'gemini',
provider: new GeminiProvider(),
},
{
name: 'openai',
provider: new OpenAIProvider(),
},
{
name: 'mock',
provider: new MockProvider(),
},
],
services: [],
execution: {
enabled: true,
events: {
enabled: true,
},
},
});
bootstrapRuntime(
[new RuntimeInitializeApp()],
runtime
);
await runtime.initialize();
await runtime.start();Create Runtime
│
Register Event Dispatchers
│
Bootstrap Applications
│
Initialize Runtime
│
Start Runtime
│
Accept Client Connections
Client
│
▼
HTTP / WebSocket
│
▼
JSON-RPC Protocol
│
▼
StateFlowX Runtime
│
┌────────┴────────┐
│ │
Providers Services
│ │
└────────┬────────┘
│
Runtime Events
│
▼
WebSocket Stream
- StateFlowX Runtime
- StateFlowX Client
- StateFlowX Client Demo
StateFlowX Runtime is experimental and under active development.
The runtime provides a configurable execution engine capable of hosting AI providers, services, transports, protocols, and realtime runtime events. Client applications dynamically register workflows during runtime initialization.