Dashboards

From SkillfulAgents/SuperAgent · View interactive version

Dashboards is an AI agent skill from the GitHub repository SkillfulAgents/SuperAgent. Create interactive web dashboards to visualize data and provide UI elements to the user

How to use this skill

Skill file

Creating Dashboards

You can create web dashboards that are served to the user through the Gamut UI. Dashboards are full web applications (HTML/JS/React/Svelte/etc.) that run as servers inside the container.

When to Build a Dashboard

Build one when the user needs a rich, reusable visual artifact rather than a chat reply or a static downloadable file — interactive charts, filters, or tables; a tracker, calculator, or data explorer; a multi-view report with controls; a visual interface over generated or fetched data. A one-off number or table belongs in the chat response instead.

Available Tools

Quick Start (React)

  1. Copy the template: cp -r /opt/gamut/plugin/skills/dashboards/templates/react-vite /workspace/artifacts/<slug>
  2. Update package.json with the dashboard's name and description
  3. Edit src/App.jsx to build the UI (add API routes in serve.js if needed). Build dashboard-scoped URLs with window.__GAMUT_DASHBOARD__.url('api/data').
  4. Use start_dashboard to build and start the server; inspect its screenshot and note the returned port
  5. Open http://localhost:<port> with browser_open(..., location="container"), exercise the important interactions, and check browser errors
  6. Iterate until both visual and functional checks pass; close the browser when validation is complete

Directory Structure

Dashboards live in /workspace/artifacts/<slug>/:

/workspace/artifacts/my-dashboard/
├── package.json        # Must have name, description, and start script
├── index.js            # Entry point (for plain dashboards)
├── tokens.css          # Design tokens (plain dashboards; see DESIGN.md)
└── dashboard.log       # Auto-generated stdout/stderr log

Requirements

Plain Dashboard Example (Bun.serve)

// index.js
const port = process.env.DASHBOARD_PORT || 3000;

const server = Bun.serve({
  port,
  fetch(req) {
    return new Response(`
      <!DOCTYPE html>
      <html>
        <body>
          <h1>My Dashboard</h1>
          <div id="chart"></div>
          <script>
            // Your interactive JavaScript here
          </script>
        </body>
      </html>
    `, { headers: { 'Content-Type': 'text/html' } });
  },
});

console.log(`Server running on port ${port}`);

React Dashboard (Recommended)

A pre-configured React + Vite template is available. To create a new React dashboard:

cp -r /opt/gamut/plugin/skills/dashboards/templates/react-vite /workspace/artifacts/<slug>

Then update package.json with the dashboard's name and description, and edit src/App.jsx to build the UI.

The template structure:

/workspace/artifacts/<slug>/
├── package.json        # Update name + description
├── gamut-dashboard.js  # Gamut base-path + Vite/HMR adapter
├── vite.config.js      # Uses the Gamut adapter
├── serve.js            # Static server with API route support
├── index.html
└── src/
    ├── main.jsx
    ├── tokens.css       # Design tokens (see DESIGN.md)
    └── App.jsx          # Edit this to build your dashboard

React dashboards are built to static files (vite build) and served via serve.js by default. The start script runs bun run build-if-needed.js && bun run serve.js — the build is skipped when no source file is newer than dist/ (container restarts reuse the previous build; set DASHBOARD_FORCE_BUILD=1 to force one). The included adapter also supports the Vite dev server and keeps HMR beneath the artifact mount.

CRITICAL: Keep gamutDashboard() in vite.config.js. The dashboard manager supplies DASHBOARD_BASE_PATH; in development the adapter applies it to Vite's entry modules and HMR client. Production assets, dynamic imports, CSS/worker URLs, fonts, and images remain relative, while serve.js and the injected runtime provide a stable document/router base. This keeps one production build relocatable.

Adding API routes to a React dashboard

Edit serve.js to add API routes inside the fetch handler, before the static file fallback:

// In serve.js, inside the fetch handler:
if (url.pathname === '/api/data') {
  const data = { items: [1, 2, 3] };
  return Response.json(data);
}

// Static files are served automatically for all other paths
return serveStatic(req, url.pathname);

URL Paths & Proxying

Dashboards are served through a proxy chain:

Browser → Main App (/api/agents/:id/artifacts/:slug/) → Container → Dashboard Server

Gamut always communicates the public artifact mount through DASHBOARD_BASE_PATH in the process and window.__GAMUT_DASHBOARD__ in browser HTML. The default stripped mode also sends X-Forwarded-Prefix on HTTP/WebSocket requests. The opt-in mounted mode retains the prefix in the upstream request path and omits that header on the final dashboard hop to avoid applying the prefix twice.

Use the injected helper for dashboard-owned URLs. It stays correct on nested client routes and when another trusted proxy adds its own prefix:

const { basePath, routerBasePath, url } = window.__GAMUT_DASHBOARD__;

fetch(url('api/data'));
image.src = url('assets/chart.png');

// React Router and similar SPA routers need the runtime router base, which is
// intentionally separate from Vite's build-time asset base.
// <BrowserRouter basename={routerBasePath}>...</BrowserRouter>

Root-relative application URLs such as /api/data still target the Gamut host and must not be used for dashboard-owned routes.

Third-party Vite apps and OpenSlide

Frameworks that accept a base at startup can consume the manager-provided value directly:

// open-slide.config.ts
import type { OpenSlideConfig } from '@open-slide/core';

const config: OpenSlideConfig = {
  // OpenSlide uses this value for both Vite assets and BrowserRouter.
  base: process.env.DASHBOARD_BASE_PATH || '/',
  port: Number(process.env.DASHBOARD_PORT) || 5173,
};

export default config;

OpenSlide's built-in Vite configuration cannot install Gamut's prefix-restoring

middleware. Opt its dashboard server into mounted upstream paths so HTTP modules

and HMR WebSockets both reach Vite beneath the same absolute base:

{
  "scripts": { "start": "open-slide dev" },
  "gamut": { "upstreamPath": "mounted" }
}

The default upstream-path mode is stripped, which keeps existing dashboard

servers receiving root-local paths such as /api/data. Use mounted only when

the framework requires inbound requests to retain DASHBOARD_BASE_PATH.

For an app-owned React Router, prefer the injected runtime value:

<BrowserRouter basename={window.__GAMUT_DASHBOARD__?.routerBasePath ?? '/'}>
  <App />
</BrowserRouter>

Do not patch generated bundles after Vite hashes them and do not add a query string to only one copy of an entry module. Both approaches violate module/cache identity and can leave stale router code or duplicate React instances.

Interactive Validation

Exposing a Widget

A dashboard can also expose a widget: a small glanceable card on the user's home screens that stands in for the dashboard's screenshot and opens the dashboard when tapped. It is a static widget.html rewritten by a widget.ts script (which can import this dashboard's own data helpers) — no server involved, refreshed by the platform when the snapshot's validUntil passes and the user looks. Call create_widget with this dashboard's slug and load the widgets skill for the contract (sizing, dark mode, widget.json validity, review checklist). Offer one whenever the dashboard has a headline number or a "what's next" the user would want at a glance.

Built-in APIs

The following APIs are automatically available in all dashboards (injected by the platform):

Storing Data

/workspace can be a network drive, where each file read is a network round trip. Synchronous reads (readFileSync, bun:sqlite) block every other request while they wait.

Best Practices

Design and Accessibility

Common Failure Causes

Clear logs before a fresh reproduction when old output makes diagnosis ambiguous.

Completion Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.