Skip to main content

Crate nyx_agent_ui

Crate nyx_agent_ui 

Source
Expand description

Embedded single-page UI for the nyx-agent daemon.

This crate is published so the nyx-agent binary can be installed from crates.io with versioned internal dependencies. It is an implementation detail of Nyx Agent, not a stable public API.

build.rs prepares the asset directory under OUT_DIR:

  • release builds from a repository checkout run the Vite pipeline;
  • release builds from crates.io use the packaged prebuilt dist/;
  • debug builds use a tiny stub page.

Consumers wire spa_handler as the Axum fallback so any path outside /api/v1/... resolves to either the matching asset or the SPA’s index.html (for client-side routing).

Structs§

UiAssets
UiBootstrap
Bootstrap context passed into the SPA at request time. Currently carries the bearer token the API middleware expects on every non-/setup request. The fallback handler rewrites index.html to embed it before sending the response; the SPA reads it from window.__NYX_AGENT_BOOTSTRAP__.
UiResponse

Functions§

resolve
Resolve the given URI path against the embedded asset tree. Returns None if no asset (including index.html) is available for that path.
resolve_with
resolve with bootstrap context. When the resolved asset is index.html and bootstrap.auth_token is set, the response body has a <script> tag injected at the start of <head> so the SPA has the token before any API call fires.
spa_handler
Axum-compatible fallback handler. Pass to Router::fallback.
spa_handler_stateful
Stateful Axum handler bound to a clonable UiBootstrap. Used as the daemon’s fallback so every served index.html carries the live auth token.
spa_handler_with