GET /api/runs/{id} assembles a run's trail from rows already kept: the event
and trigger that started it, each workflow step, and each model and tool call
from the agent's journal. Investigations end by notifying their findings on
the composer, whose messages are read from a cursor with a live stream that
only says when to read. The binary serves its own SPA entry, archie.html,
calling only the new API. The investigate prompt now treats the event as a
claim to check against what it measures.
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
// Package dashboard serves the single binary's SPA: archie.html and its
|
|
// assets from the embedded build. Every other route belongs to a module.
|
|
package dashboard
|
|
|
|
import (
|
|
"io/fs"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/samcharles93/archie-core/internal/platform/httpjson"
|
|
)
|
|
|
|
const page = "archie.html"
|
|
|
|
// Routes serves the SPA from dist on mux. A path under /api/ that no module
|
|
// claimed is a JSON 404, never the page. With no build embedded, the page
|
|
// says how to build it.
|
|
func Routes(mux *http.ServeMux, dist fs.FS) {
|
|
mux.HandleFunc("/api/", func(w http.ResponseWriter, _ *http.Request) {
|
|
httpjson.Error(w, http.StatusNotFound, "no such route")
|
|
})
|
|
if dist == nil {
|
|
mux.HandleFunc("GET /", func(w http.ResponseWriter, _ *http.Request) {
|
|
http.Error(w, "this binary was built without the dashboard; run task ui and rebuild", http.StatusNotFound)
|
|
})
|
|
return
|
|
}
|
|
files := http.FileServerFS(dist)
|
|
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
|
name := strings.TrimPrefix(r.URL.Path, "/")
|
|
if name != "" && name != "index.html" && name != page {
|
|
if info, err := fs.Stat(dist, name); err == nil && !info.IsDir() {
|
|
if strings.HasPrefix(name, "assets/") {
|
|
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
|
|
}
|
|
files.ServeHTTP(w, r)
|
|
return
|
|
}
|
|
}
|
|
// Every other path is a route inside the SPA.
|
|
w.Header().Set("Cache-Control", "no-store")
|
|
http.ServeFileFS(w, r, dist, page)
|
|
})
|
|
}
|