Skip to content

system.gateway.http

system.gateway.http (provided by @open-matrix/system-gateway-http) is the HTTP gateway. It serves Director's static assets, handles the browser bootstrap, and proxies the WebSocket-NATS connection. Director has no direct adapter calls into gateway actors — its relationship is entirely as an HTTP client of the gateway plus a NATS-WS consumer.

What the gateway provides Director

  1. Static asset serving. Director's dist/ is published at /apps/director/. The Vite config (vite.config.ts:12) sets base: '/apps/director/' so produced assets reference paths the gateway already maps.
  2. Bootstrap. When the page loads, <matrix-dsl-host bootstrap-mode="hosted" url-params> (src/index.html:50-55) requests bootstrap data from the gateway. The response provides the WebSocket-NATS endpoint, authority root, address root, runtime target root, and credentials for that browser session.
  3. WebSocket transport. After bootstrap, <matrix-dsl-host> opens wss://<gateway>/nats-ws and uses it as the NATS transport. All RequestReply.execute calls Director makes ride this transport.
  4. Dev proxy paths. In vite dev, the local Vite server proxies /.matrix, /api, /auth, /login, /logout, /healthz, and /nats-ws to MATRIX_DAEMON_ORIGIN (default http://127.0.0.1:3100). See vite.config.ts:46-55.

What Director does not call

Director does not call system.gateway.http for any business logic:

  • No gateway.routes.list or similar reflective calls.
  • No gateway.bootstrap.invalidate.
  • No upload/file API.
  • No auth.* calls.

Auth lives in system-auth. The gateway is a transport-and-routing layer, not a Director adapter target.

Bootstrap envelope (consumed values)

Director's directorReadiness (src/index.ts:81-114) reads three values from the <matrix-dsl-host> element after bootstrap completes:

Source attributePurpose
host.getAttribute('root')The page's primary mount-path root for the topology view.
host.dataset.addressRootAuthenticated authority root.
host.dataset.runtimeTargetRootWhere to send runtime-targeted RequestReply calls.

If any are missing, Director never declares ready. That's the "loading" screen you see when the gateway responds slowly or the bootstrap response was incomplete.

Implications

Because Director is gateway-agnostic at the actor level, swapping gateway implementations (or running Director against a different gateway in dev) only requires producing a compatible bootstrap response and a working /nats-ws upgrade. Director itself doesn't need any code changes.

For developer ergonomics, MATRIX_DAEMON_ORIGIN lets you run Director against an arbitrary host (e.g., a remote dev box) without touching code:

bash
MATRIX_DAEMON_ORIGIN=http://192.168.1.10:3100 pnpm --filter @open-matrix/director dev

See also

Source: projects/matrix-3/packages/director/src/index.html, src/index.ts:74-114, vite.config.ts.