diff --git a/.air.toml b/.air.toml
new file mode 100644
index 000000000..c54c5e931
--- /dev/null
+++ b/.air.toml
@@ -0,0 +1,28 @@
+# Live reload for archied during dashboard work.
+#
+# The frontend has its own loop -- `task ui:dev` runs Vite with HMR and proxies
+# /api and /events here -- so this watcher deliberately ignores ui/. Watching
+# it would rebuild the Go binary on every keystroke in a CSS file, and
+# rebuilding on ui/dist changes would loop against `task ui`.
+root = "."
+tmp_dir = ".air"
+
+[build]
+ cmd = "go build -o ./.air/archied ./cmd/archied"
+ # `bin` is deprecated in air; entrypoint is the current key.
+ entrypoint = "./.air/archied"
+ include_ext = ["go", "toml"]
+ exclude_dir = ["ui", "bin", "docs", ".git", ".task", ".air", ".beads", "tmp"]
+ exclude_regex = ["_test\\.go"]
+ stop_on_error = true
+ delay = 400
+
+[log]
+ time = true
+ # Only air's own build/restart lines. Without this it prints a "watching X"
+ # line per directory on every start, which buries Vite's output when both
+ # run in one terminal under `task dev`.
+ main_only = true
+
+[misc]
+ clean_on_exit = true
diff --git a/.gitignore b/.gitignore
index 2d4183671..30fd02383 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,14 @@ node_modules/
.claude/
.codex/
.pi-subagents/
+.playwright-mcp/
+
+# Frontend
+/ui/node_modules/
+/ui/.vite/
+/ui/*.tsbuildinfo
+# ui/dist IS committed: the Go build must not need a Node toolchain.
+
+# air live-reload
+/.air/
+/tmp/
diff --git a/Taskfile.yml b/Taskfile.yml
index 0067e113d..be4748fb3 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -25,6 +25,40 @@ tasks:
cmds:
- golangci-lint run ./...
+ ui:
+ desc: Build the dashboard into ui/dist (committed; the Go build embeds it)
+ dir: ui
+ cmds:
+ - npm install --no-audit --no-fund
+ - npm run build
+
+ dev:
+ desc: "Develop: archied live-reload + Vite HMR together. Open http://localhost:5173"
+ summary: |
+ Runs both halves of the dev loop in one terminal:
+
+ * air rebuilds and restarts archied on Go changes
+ * vite serves the dashboard with hot reload on :5173,
+ proxying /api and /events through to archied on :8484
+
+ Open http://localhost:5173 -- not :8484. The Vite server is the one with
+ hot reload; :8484 serves the last built dist/ and will look stale.
+
+ Ctrl-C stops both.
+ deps: [dev:daemon, dev:ui]
+
+ dev:daemon:
+ desc: archied only, live-reloading via air (prefer `task dev`)
+ cmds:
+ - air
+
+ dev:ui:
+ desc: Vite dev server only, expects archied already running (prefer `task dev`)
+ dir: ui
+ cmds:
+ - npm install --no-audit --no-fund
+ - npm run dev
+
build:
desc: Build archied and archie-agent binaries
sources:
diff --git a/cmd/archied/main.go b/cmd/archied/main.go
index bd70cfb09..1e9ac5b13 100644
--- a/cmd/archied/main.go
+++ b/cmd/archied/main.go
@@ -294,7 +294,7 @@ func run() int {
// row id) and then fanned out to live dashboard connections.
bus := events.NewBus()
defer bus.Close()
- web := &webui.Server{Store: st, Log: log}
+ web := &webui.Server{Store: st, Log: log, Cfg: &cfg}
sink := bus.Subscribe(256)
go func() {
for e := range sink.C {
@@ -308,6 +308,7 @@ func run() int {
}
}()
if l := cfg.Web.Listen; l != "" && l != "off" {
+ web.Token = webTokenFor(l, cfg.DBPath, log)
go func() {
if err := web.Run(ctx, l); err != nil {
log.Error("web ui failed", "err", err)
@@ -340,41 +341,15 @@ func run() int {
}
// Container pool (optional -- no containers when [containers] is absent).
- var containerPool *container.Pool
- var storeBackend storage.Backend
- if cfg.Containers.Enabled {
- // Single Docker client shared between pool and storage backend.
- dockerCli, err := client.New(client.FromEnv)
- if err != nil {
- log.Error("docker client failed", "err", err)
- return 1
- }
- defer func() {
- if err := dockerCli.Close(); err != nil {
- log.Warn("docker client close failed", "err", err)
- }
- }()
-
- containerPool, err = container.NewPool(ctx, container.Config{
- Image: cfg.Containers.Image,
- MaxConcurrency: cfg.Containers.MaxConcurrency,
- MaxUptime: cfg.Containers.MaxUptime.Std(),
- PullPolicy: cfg.Containers.PullPolicy,
- Network: cfg.Containers.Network,
- DockerClient: dockerCli,
- }, cfg.NATS.URL, log)
- if err != nil {
- log.Error("container pool failed", "err", err)
- return 1
- }
- defer func() {
- if err := containerPool.Close(); err != nil {
- log.Warn("container pool close failed", "err", err)
- }
- }()
-
- storeBackend = storage.NewDockerBackend(dockerCli)
- }
+ //
+ // Container setup degrades rather than aborting, for the same reason
+ // resolveForge does: containers are one capability among many, and
+ // refusing to start denies the operator chat, the dashboard and every
+ // other subsystem over a feature they may not be exercising right now.
+ // Under a systemd unit with Restart=on-failure it also turns a recoverable
+ // problem into a crash loop with the real error scrolling past unread.
+ containerPool, storeBackend, closeDocker := startContainers(ctx, cfg, log)
+ defer closeDocker()
// ── LLM runtime ──────────────────────────────────────────────────
// Created before gateways so the LLMResponder can be wired into the
@@ -607,6 +582,10 @@ func run() int {
log.Error("memory manager init failed", "err", err)
return 1
}
+ // The dashboard is built before memory exists, so it is wired in here
+ // rather than at construction.
+ web.Memory = memManager
+
if err := memManager.Initialize("daemon"); err != nil {
log.Warn("memory manager initialize", "err", err)
}
@@ -937,3 +916,82 @@ func safePluginInfo(p plugin.Plugin) (name, version string) {
}()
return p.Name(), p.Version()
}
+
+// webTokenFor returns the dashboard token for a listen address, or "" when
+// none is needed.
+//
+// A loopback bind needs no token: local access already implies the agent's own
+// authority, since its shell and edit tools run as this user. A reachable bind
+// mints one and logs a URL to click, so an instance cannot be left exposed
+// merely by omitting configuration.
+func webTokenFor(listen, dbPath string, log *slog.Logger) string {
+ if webui.IsLoopback(listen) {
+ return ""
+ }
+ path := filepath.Join(filepath.Dir(dbPath), "web-token")
+ tok, err := webui.LoadOrCreateToken(path)
+ if err != nil {
+ log.Error("web ui token", "err", err)
+ return ""
+ }
+ log.Info("web ui token", "open", webui.DashboardURL(listen, tok), "stored", path)
+ return tok
+}
+
+// startContainers brings up the container pool and storage backend, returning
+// nils when containers are disabled or unavailable.
+//
+// Failure here degrades rather than aborting, for the same reason resolveForge
+// does: containers are one capability among many, and refusing to start denies
+// the operator chat, the dashboard and every other subsystem over a feature
+// they may not be exercising. Under Restart=on-failure it also turns a
+// recoverable problem into a crash loop with the real error scrolling past.
+func startContainers(
+ ctx context.Context,
+ cfg config.Config,
+ log *slog.Logger,
+) (*container.Pool, storage.Backend, func()) {
+ noop := func() {}
+ if !cfg.Containers.Enabled {
+ return nil, nil, noop
+ }
+
+ // Single Docker client shared between pool and storage backend.
+ dockerCli, err := client.New(client.FromEnv)
+ if err != nil {
+ log.Error("containers disabled: docker client unavailable", "err", err)
+ return nil, nil, noop
+ }
+ closeDocker := func() {
+ if err := dockerCli.Close(); err != nil {
+ log.Warn("docker client close failed", "err", err)
+ }
+ }
+
+ pool, err := container.NewPool(ctx, container.Config{
+ Image: cfg.Containers.Image,
+ MaxConcurrency: cfg.Containers.MaxConcurrency,
+ MaxUptime: cfg.Containers.MaxUptime.Std(),
+ PullPolicy: cfg.Containers.PullPolicy,
+ Network: cfg.Containers.Network,
+ DockerClient: dockerCli,
+ }, cfg.NATS.URL, log)
+ if err != nil {
+ // A missing image is recoverable by hand. The daemon sends no registry
+ // credentials on pull (internal/container/pool.go), so a private
+ // registry always needs the operator's CLI to fetch it first.
+ log.Error("containers disabled: pool unavailable", "err", err,
+ "hint", "run `docker compose pull agent` (or `build agent`) so the image is present locally")
+ return nil, storage.NewDockerBackend(dockerCli), closeDocker
+ }
+
+ // contextcheck: Pool.Close takes no context by design -- it is a shutdown
+ // path that must run to completion after ctx is already cancelled.
+ //nolint:contextcheck
+ return pool, storage.NewDockerBackend(dockerCli), func() {
+ if err := pool.Close(); err != nil {
+ log.Warn("container pool close failed", "err", err)
+ }
+ closeDocker()
+ }
+}
diff --git a/internal/webui/api_config.go b/internal/webui/api_config.go
new file mode 100644
index 000000000..c45b5f81e
--- /dev/null
+++ b/internal/webui/api_config.go
@@ -0,0 +1,278 @@
+package webui
+
+import (
+ "net/http"
+ "strconv"
+ "strings"
+
+ "github.com/samcharles93/archie-core/internal/config"
+)
+
+// ChannelView is one conversational front-end as shown on the dashboard's
+// Channels page: whether it is reachable today, and what configuring it
+// would unlock.
+type ChannelView struct {
+ Name string `json:"name"`
+ Configured bool `json:"configured"`
+ Detail string `json:"detail"`
+ Description string `json:"description"`
+}
+
+// handleChannels reports how a human can reach Archie today. It exists so
+// "how do I talk to this thing" has one answer that does not require
+// reading config.toml -- see ChatConfig in internal/config/config.go for
+// the fields this derives from.
+func (s *Server) handleChannels(w http.ResponseWriter, r *http.Request) {
+ if s.Cfg == nil {
+ writeJSON(w, map[string]any{"channels": []ChannelView{}})
+ return
+ }
+
+ chat := s.Cfg.Chat
+ views := []ChannelView{
+ telegramChannelView(chat.Telegram),
+ webhookChannelView(chat.WebhookAddr),
+ emailChannelView(chat.Email),
+ }
+
+ writeJSON(w, map[string]any{"channels": views})
+}
+
+func telegramChannelView(t config.TelegramConfig) ChannelView {
+ configured := strings.TrimSpace(t.TokenEnv) != ""
+ detail := "Not configured."
+ if configured {
+ n := len(t.AllowedUserIDs)
+ switch n {
+ case 0:
+ detail = "Token set, but the allowlist is empty -- the bot answers nobody."
+ case 1:
+ detail = "1 user allowed."
+ default:
+ detail = strconv.Itoa(n) + " users allowed."
+ }
+ }
+ return ChannelView{
+ Name: "Telegram",
+ Configured: configured,
+ Detail: detail,
+ Description: "Talk to Archie and approve its work from your phone.",
+ }
+}
+
+func webhookChannelView(addr string) ChannelView {
+ configured := strings.TrimSpace(addr) != ""
+ detail := "Not configured."
+ if configured {
+ detail = "Listening for inbound chat requests."
+ }
+ return ChannelView{
+ Name: "Webhook gateway",
+ Configured: configured,
+ Detail: detail,
+ Description: "Lets another service (e.g. a Telegram webhook, a custom front-end) push messages to Archie over HTTP instead of long-polling.",
+ }
+}
+
+func emailChannelView(e config.EmailConfig) ChannelView {
+ configured := strings.TrimSpace(e.ListenAddr) != ""
+ detail := "Not configured."
+ if configured {
+ detail = "Archie accepts inbound mail and can reply through the configured relay."
+ }
+ return ChannelView{
+ Name: "Email",
+ Configured: configured,
+ Detail: detail,
+ Description: "Email Archie a task and it replies from its own inbound SMTP listener.",
+ }
+}
+
+// ConfigView is the read-only, secret-free projection of config.Config
+// shown on the dashboard's Configuration page. Every field here is an
+// explicit, hand-picked allowlist -- see handleConfig for why this is
+// built field by field rather than by marshalling config.Config directly.
+type ConfigView struct {
+ Identity IdentityView `json:"identity"`
+ Repositories []RepoView `json:"repositories"`
+ Models map[string]string `json:"models"`
+ Providers map[string]ProviderView `json:"providers"`
+ Budgets BudgetsView `json:"budgets"`
+ Agent AgentView `json:"agent"`
+ Storage StorageView `json:"storage"`
+ Containers ContainersView `json:"containers"`
+ Web WebView `json:"web"`
+}
+
+// IdentityView is who Archie is on the forge -- never the token that
+// authenticates as that identity.
+type IdentityView struct {
+ BotUser string `json:"bot_user"`
+ BotEmail string `json:"bot_email"`
+ Label string `json:"label"`
+ ForgeType string `json:"forge_type"`
+ ForgeHost string `json:"forge_host"`
+ DiffCapLines int `json:"diff_cap_lines"`
+}
+
+// RepoView is one managed repository and the quality gate it must pass.
+// Gate and Preflight are shell command argv lists -- test runners and
+// linters, not secrets -- so they are safe to show verbatim.
+type RepoView struct {
+ Owner string `json:"owner"`
+ Name string `json:"name"`
+ Base string `json:"base"`
+ Gate [][]string `json:"gate"`
+ Protect []string `json:"protect"`
+ Ecosystem string `json:"ecosystem"`
+ PersistentStorage bool `json:"persistent_storage"`
+ AllowConcurrent bool `json:"allow_concurrent"`
+ MaxRetries int `json:"max_retries"`
+}
+
+// ProviderView is an LLM provider's shape, never its key. APIKeyEnv is the
+// name of an environment variable, not a value, so it is safe to show;
+// Configured reports whether either credential form (env or secret engine)
+// is actually set, without revealing which or what.
+type ProviderView struct {
+ Class string `json:"class"`
+ BaseURL string `json:"base_url,omitempty"`
+ APIKeyEnv string `json:"api_key_env,omitempty"`
+ Configured bool `json:"configured"`
+}
+
+// BudgetsView mirrors config.Budgets, none of which is secret.
+type BudgetsView struct {
+ MaxSteps int `json:"max_steps"`
+ MaxTokens int `json:"max_tokens"`
+ WallClock string `json:"wall_clock"`
+ GateMaxFailures int `json:"gate_max_failures"`
+}
+
+// AgentView is how archied executes autonomous stages. Env lists only
+// environment variable NAMES admitted to the worker's allowlist, never
+// their values.
+type AgentView struct {
+ Mode string `json:"mode"`
+ Command string `json:"command,omitempty"`
+ Env []string `json:"env,omitempty"`
+}
+
+// StorageView is where archied keeps its state on disk. All paths, no
+// secrets.
+type StorageView struct {
+ WorkDir string `json:"work_dir"`
+ DBPath string `json:"db_path"`
+ SkillsDir string `json:"skills_dir,omitempty"`
+ PluginDir string `json:"plugin_dir,omitempty"`
+ SecretEngineDir string `json:"secret_engine_dir,omitempty"`
+}
+
+// ContainersView is how sandboxed task execution is configured.
+type ContainersView struct {
+ Enabled bool `json:"enabled"`
+ Image string `json:"image,omitempty"`
+ MaxConcurrency int `json:"max_concurrency"`
+ MaxUptime string `json:"max_uptime"`
+ VolumeTTL string `json:"volume_ttl"`
+ PullPolicy string `json:"pull_policy"`
+ Network string `json:"network,omitempty"`
+}
+
+// WebView is the dashboard's own listen address.
+type WebView struct {
+ Listen string `json:"listen"`
+}
+
+// handleConfig returns a read-only, secret-free view of the running
+// configuration.
+//
+// This handler builds ConfigView field by field from an explicit allowlist
+// rather than marshalling config.Config and stripping fields afterward:
+// config.Config carries secret.SecretRef values (forge tokens, provider API
+// keys) and there is no way to guarantee a strip-after-marshal approach
+// keeps working as fields are added to Config in the future. An allowlist
+// fails safe -- a new secret field added upstream is simply absent here
+// until someone deliberately adds it.
+func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
+ if s.Cfg == nil {
+ writeJSON(w, map[string]any{})
+ return
+ }
+ cfg := s.Cfg
+
+ view := ConfigView{
+ Identity: IdentityView{
+ BotUser: cfg.BotUser,
+ BotEmail: cfg.BotEmail,
+ Label: cfg.Label,
+ ForgeType: cfg.Forge.Type,
+ ForgeHost: cfg.Forge.Host,
+ DiffCapLines: cfg.DiffCapLines,
+ },
+ Repositories: reposView(cfg.Repos),
+ Models: cfg.Models,
+ Providers: providersView(cfg.Providers),
+ Budgets: BudgetsView{
+ MaxSteps: cfg.Budgets.MaxSteps,
+ MaxTokens: cfg.Budgets.MaxTokens,
+ WallClock: cfg.Budgets.WallClock.Std().String(),
+ GateMaxFailures: cfg.Budgets.GateMaxFailures,
+ },
+ Agent: AgentView{
+ Mode: cfg.Agent.Mode,
+ Command: cfg.Agent.Command,
+ Env: cfg.Agent.Env,
+ },
+ Storage: StorageView{
+ WorkDir: cfg.WorkDir,
+ DBPath: cfg.DBPath,
+ SkillsDir: cfg.SkillsDir,
+ PluginDir: cfg.PluginDir,
+ SecretEngineDir: cfg.SecretEngineDir,
+ },
+ Containers: ContainersView{
+ Enabled: cfg.Containers.Enabled,
+ Image: cfg.Containers.Image,
+ MaxConcurrency: cfg.Containers.MaxConcurrency,
+ MaxUptime: cfg.Containers.MaxUptime.Std().String(),
+ VolumeTTL: cfg.Containers.VolumeTTL.Std().String(),
+ PullPolicy: cfg.Containers.PullPolicy,
+ Network: cfg.Containers.Network,
+ },
+ Web: WebView{Listen: cfg.Web.Listen},
+ }
+
+ writeJSON(w, view)
+}
+
+func reposView(repos []config.Repo) []RepoView {
+ out := make([]RepoView, 0, len(repos))
+ for _, r := range repos {
+ out = append(out, RepoView{
+ Owner: r.Owner,
+ Name: r.Name,
+ Base: r.BaseBranch(),
+ Gate: r.Gate,
+ Protect: r.Protect,
+ Ecosystem: r.Ecosystem,
+ PersistentStorage: r.PersistentStorage,
+ AllowConcurrent: r.AllowConcurrent,
+ MaxRetries: r.MaxRetries,
+ })
+ }
+ return out
+}
+
+func providersView(providers map[string]config.Provider) map[string]ProviderView {
+ out := make(map[string]ProviderView, len(providers))
+ for name, p := range providers {
+ out[name] = ProviderView{
+ Class: p.Class,
+ BaseURL: p.BaseURL,
+ APIKeyEnv: p.APIKeyEnv,
+ Configured: strings.TrimSpace(p.APIKeyEnv) != "" || strings.TrimSpace(p.APIKey.Key) != "",
+ }
+ }
+ return out
+}
diff --git a/internal/webui/api_config_test.go b/internal/webui/api_config_test.go
new file mode 100644
index 000000000..bbc690867
--- /dev/null
+++ b/internal/webui/api_config_test.go
@@ -0,0 +1,208 @@
+package webui
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/samcharles93/archie-core/internal/config"
+ "github.com/samcharles93/archie-core/internal/secret"
+)
+
+// fakeSecrets are recognisable strings that must never appear anywhere in
+// handleConfig's response body. If any of these leak, the allowlist in
+// api_config.go has a hole -- see handleConfig's doc comment for why it is
+// built field by field rather than by marshalling config.Config directly.
+const (
+ fakeForgeToken = "ghp_FAKESECRETTOKENVALUE123"
+ fakeProviderKey = "sk-FAKEPROVIDERKEYVALUE456"
+ fakeBWSKeyName = "FAKE-BWS-SECRET-KEY-789"
+ fakeNATSToken = "nats-FAKESECRETTOKEN000"
+)
+
+func configWithFakeSecrets() *config.Config {
+ return &config.Config{
+ WorkDir: "/work/archie",
+ SkillsDir: "/work/archie/.agents/skills",
+ DBPath: "/work/archie/archie.db",
+ BotUser: "archie-bot",
+ BotEmail: "archie@example.com",
+ Label: "archie",
+ Forge: config.Forge{
+ Type: "gitea",
+ Host: "gitea.example.com",
+ TokenEnv: "GITEA_TOKEN",
+ Token: secret.SecretRef{Engine: "env", Key: fakeForgeToken},
+ },
+ Models: map[string]string{"builder": "openai/gpt-4"},
+ Providers: map[string]config.Provider{
+ "openai": {
+ Class: "openai",
+ APIKeyEnv: "OPENAI_API_KEY",
+ APIKey: secret.SecretRef{Engine: "bws", Key: fakeBWSKeyName},
+ BaseURL: "https://api.openai.com/v1",
+ },
+ "custom": {
+ Class: "custom",
+ APIKey: secret.SecretRef{Engine: "literal", Key: fakeProviderKey},
+ },
+ },
+ Repos: []config.Repo{
+ {Owner: "acme", Name: "widget", Base: "main", Gate: [][]string{{"task", "check"}}},
+ },
+ Agent: config.Agent{Mode: "subprocess", Command: "/usr/local/bin/archie-agent", Env: []string{"HOME"}},
+ NATS: config.NATSConfig{URL: "nats://127.0.0.1:4222", TokenEnv: "NATS_TOKEN"},
+ Chat: config.ChatConfig{
+ Telegram: config.TelegramConfig{TokenEnv: "TELEGRAM_TOKEN"},
+ },
+ }
+}
+
+// leakCandidates returns the set of fake secret strings a test should
+// confirm are absent from a response body. NATS token is included even
+// though handleConfig doesn't expose NATS today, guarding against a future
+// regression that starts serializing it wholesale.
+func leakCandidates() []string {
+ return []string{fakeForgeToken, fakeProviderKey, fakeBWSKeyName, fakeNATSToken}
+}
+
+func TestHandleConfigNeverLeaksSecrets(t *testing.T) {
+ cases := []struct {
+ name string
+ cfg *config.Config
+ }{
+ {name: "populated config with secrets", cfg: configWithFakeSecrets()},
+ {name: "nil config", cfg: nil},
+ {name: "zero-value config", cfg: &config.Config{}},
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ srv := newTestServer(t)
+ srv.Cfg = tc.cfg
+
+ req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
+ w := httptest.NewRecorder()
+ srv.Handler().ServeHTTP(w, req)
+
+ if w.Code != http.StatusOK {
+ t.Fatalf("status = %d, body = %s", w.Code, w.Body)
+ }
+
+ body := w.Body.String()
+ for _, leak := range leakCandidates() {
+ if strings.Contains(body, leak) {
+ t.Errorf("response body leaked secret value %q:\n%s", leak, body)
+ }
+ }
+
+ var got map[string]any
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatalf("response is not valid JSON: %v", err)
+ }
+ })
+ }
+}
+
+// TestHandleConfigSafeFieldsPresent proves the allowlisted, non-secret
+// fields still make it through -- a test that only checked for absence of
+// secrets could pass trivially by returning {}.
+func TestHandleConfigSafeFieldsPresent(t *testing.T) {
+ srv := newTestServer(t)
+ srv.Cfg = configWithFakeSecrets()
+
+ req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
+ w := httptest.NewRecorder()
+ srv.Handler().ServeHTTP(w, req)
+
+ var got ConfigView
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+
+ if got.Identity.BotUser != "archie-bot" {
+ t.Errorf("Identity.BotUser = %q, want archie-bot", got.Identity.BotUser)
+ }
+ if got.Identity.ForgeHost != "gitea.example.com" {
+ t.Errorf("Identity.ForgeHost = %q, want gitea.example.com", got.Identity.ForgeHost)
+ }
+ if len(got.Repositories) != 1 || got.Repositories[0].Owner != "acme" {
+ t.Errorf("Repositories = %+v", got.Repositories)
+ }
+ if !got.Providers["openai"].Configured {
+ t.Errorf("Providers[openai].Configured = false, want true (APIKeyEnv is set)")
+ }
+ if got.Providers["openai"].APIKeyEnv != "OPENAI_API_KEY" {
+ t.Errorf("Providers[openai].APIKeyEnv = %q, want OPENAI_API_KEY", got.Providers["openai"].APIKeyEnv)
+ }
+ if got.Agent.Mode != "subprocess" {
+ t.Errorf("Agent.Mode = %q, want subprocess", got.Agent.Mode)
+ }
+ if got.Storage.WorkDir != "/work/archie" {
+ t.Errorf("Storage.WorkDir = %q", got.Storage.WorkDir)
+ }
+}
+
+func TestHandleChannelsReportsConfiguredState(t *testing.T) {
+ srv := newTestServer(t)
+ srv.Cfg = configWithFakeSecrets()
+
+ req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/channels", nil)
+ w := httptest.NewRecorder()
+ srv.Handler().ServeHTTP(w, req)
+
+ if w.Code != http.StatusOK {
+ t.Fatalf("status = %d, body = %s", w.Code, w.Body)
+ }
+
+ body := w.Body.String()
+ for _, leak := range leakCandidates() {
+ if strings.Contains(body, leak) {
+ t.Errorf("channels response leaked secret value %q:\n%s", leak, body)
+ }
+ }
+
+ var got struct {
+ Channels []ChannelView `json:"channels"`
+ }
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+
+ var telegram *ChannelView
+ for i := range got.Channels {
+ if got.Channels[i].Name == "Telegram" {
+ telegram = &got.Channels[i]
+ }
+ }
+ if telegram == nil {
+ t.Fatal("no Telegram channel in response")
+ }
+ if !telegram.Configured {
+ t.Errorf("Telegram.Configured = false, want true (TokenEnv is set)")
+ }
+}
+
+func TestHandleChannelsNilConfig(t *testing.T) {
+ srv := newTestServer(t)
+ srv.Cfg = nil
+
+ req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/channels", nil)
+ w := httptest.NewRecorder()
+ srv.Handler().ServeHTTP(w, req)
+
+ if w.Code != http.StatusOK {
+ t.Fatalf("status = %d, body = %s", w.Code, w.Body)
+ }
+ var got struct {
+ Channels []ChannelView `json:"channels"`
+ }
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+ if len(got.Channels) != 0 {
+ t.Errorf("Channels = %+v, want empty when Cfg is nil", got.Channels)
+ }
+}
diff --git a/internal/webui/api_logs.go b/internal/webui/api_logs.go
new file mode 100644
index 000000000..b9fe46d9f
--- /dev/null
+++ b/internal/webui/api_logs.go
@@ -0,0 +1,80 @@
+package webui
+
+import (
+ "net/http"
+ "strconv"
+ "strings"
+
+ "github.com/samcharles93/archie-core/internal/logging"
+)
+
+// handleLogs serves a page of log history.
+//
+// This handler is transport only: parsing the log format belongs to the
+// logging package, which owns it. Live output reaches the dashboard over the
+// existing /events stream; this endpoint exists so the view has history from
+// before the browser connected, which is the whole reason file logging landed
+// first.
+func (s *Server) handleLogs(w http.ResponseWriter, r *http.Request) {
+ path := s.logFile()
+ if path == "" {
+ // Not an error: file logging is optional. Say so plainly so the UI can
+ // explain how to turn it on rather than showing an empty table.
+ writeJSON(w, map[string]any{
+ "entries": []any{},
+ "file": "",
+ "disabled": true,
+ })
+ return
+ }
+
+ q := r.URL.Query()
+ limit, _ := strconv.Atoi(q.Get("limit"))
+ result, err := logging.Tail(path, logging.Query{
+ Levels: splitCSV(q.Get("level")),
+ Component: strings.TrimSpace(q.Get("component")),
+ Contains: strings.TrimSpace(q.Get("q")),
+ Limit: limit,
+ })
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ components, err := logging.Components(path)
+ if err != nil {
+ // The filter list is a convenience; failing to build it must not cost
+ // the caller their log entries.
+ s.Log.Warn("log components unavailable", "err", err)
+ components = []string{}
+ }
+
+ writeJSON(w, map[string]any{
+ "entries": result.Entries,
+ "truncated": result.Truncated,
+ "file": result.File,
+ "components": components,
+ })
+}
+
+// logFile reports the configured log path, or "" when file logging is off.
+func (s *Server) logFile() string {
+ if s.Cfg == nil {
+ return ""
+ }
+ return strings.TrimSpace(s.Cfg.Log.File)
+}
+
+func splitCSV(v string) []string {
+ if strings.TrimSpace(v) == "" {
+ return nil
+ }
+ parts := strings.Split(v, ",")
+ out := make([]string, 0, len(parts))
+ for _, p := range parts {
+ if p = strings.TrimSpace(p); p != "" {
+ out = append(out, p)
+ }
+ }
+ return out
+}
diff --git a/internal/webui/api_memory.go b/internal/webui/api_memory.go
new file mode 100644
index 000000000..85a39eef3
--- /dev/null
+++ b/internal/webui/api_memory.go
@@ -0,0 +1,65 @@
+package webui
+
+import (
+ "net/http"
+
+ "github.com/samcharles93/archie-core/internal/memory"
+)
+
+// MemoryProviderView describes one memory provider for the dashboard.
+type MemoryProviderView struct {
+ Name string `json:"name"`
+ // Role is "builtin" or "external". Archie always has a builtin provider;
+ // an external one is optional and configured separately.
+ Role string `json:"role"`
+ // Available reports the provider's own readiness check -- a provider can
+ // be configured but unusable when a binary is missing or a connection is
+ // down, and that distinction is exactly what an operator needs to see.
+ Available bool `json:"available"`
+ // Tools are the capabilities this provider gives the agent, by name.
+ Tools []MemoryToolView `json:"tools"`
+}
+
+// MemoryToolView is one tool a provider exposes to the agent.
+type MemoryToolView struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+}
+
+// handleMemory reports what Archie can remember and with what.
+//
+// Memory is otherwise invisible: it is a set of tools handed to the model at
+// discovery time, so without this the only way to know what the agent can
+// recall is to read the provider source.
+func (s *Server) handleMemory(w http.ResponseWriter, r *http.Request) {
+ if s.Memory == nil {
+ writeJSON(w, map[string]any{"providers": []any{}, "enabled": false})
+ return
+ }
+
+ views := []MemoryProviderView{}
+ if p := s.Memory.Builtin(); p != nil {
+ views = append(views, providerView(p, "builtin"))
+ }
+ if p := s.Memory.External(); p != nil {
+ views = append(views, providerView(p, "external"))
+ }
+
+ writeJSON(w, map[string]any{"providers": views, "enabled": true})
+}
+
+func providerView(p memory.MemoryProvider, role string) MemoryProviderView {
+ view := MemoryProviderView{
+ Name: p.Name(),
+ Role: role,
+ Available: p.IsAvailable(),
+ Tools: []MemoryToolView{},
+ }
+ for _, t := range p.GetToolSchemas() {
+ view.Tools = append(view.Tools, MemoryToolView{
+ Name: t.Name,
+ Description: t.Description,
+ })
+ }
+ return view
+}
diff --git a/internal/webui/api_setup.go b/internal/webui/api_setup.go
new file mode 100644
index 000000000..7fb81e953
--- /dev/null
+++ b/internal/webui/api_setup.go
@@ -0,0 +1,80 @@
+package webui
+
+import (
+ "net/http"
+ "strings"
+)
+
+// SetupStep is one item in the dashboard's getting-started checklist.
+type SetupStep struct {
+ Title string `json:"title"`
+ Detail string `json:"detail,omitempty"`
+ Done bool `json:"done"`
+}
+
+// handleSetup reports which parts of archied are configured.
+//
+// The checklist exists so a new operator is told what is missing rather than
+// shown a dashboard of zeroes and left to infer it. Steps are phrased as
+// actions in plain language -- "Connect a chat channel", not "channels.telegram
+// .bot_token unset" -- because someone who already knows the config key does
+// not need the checklist.
+//
+// Every step is derived from live state, so the list disappears on its own
+// once setup is complete rather than needing to be dismissed.
+func (s *Server) handleSetup(w http.ResponseWriter, r *http.Request) {
+ steps := []SetupStep{}
+
+ if s.Cfg == nil {
+ // No config wired in: report nothing rather than guessing, so the
+ // dashboard simply omits the panel.
+ writeJSON(w, map[string]any{"steps": steps})
+ return
+ }
+
+ // The operator's name is deployment data, configured once in [chat]. The
+ // dashboard greets with it rather than hardcoding a name, which would be
+ // wrong on every deployment but one.
+ operator := strings.TrimSpace(s.Cfg.Chat.Operator)
+
+ steps = append(steps, SetupStep{
+ Title: "Give Archie an identity",
+ Detail: "The account it commits and comments as.",
+ Done: strings.TrimSpace(s.Cfg.BotUser) != "",
+ })
+
+ steps = append(steps, SetupStep{
+ Title: "Connect a repository",
+ Detail: "Archie polls these for issues assigned to it.",
+ Done: len(s.Cfg.Repos) > 0,
+ })
+
+ steps = append(steps, SetupStep{
+ Title: "Connect a chat channel",
+ Detail: "Talk to Archie and approve its work from your phone.",
+ Done: s.hasChannel(),
+ })
+
+ // Only meaningful once there is somewhere to run work.
+ if count, err := s.Store.StatusCounts(r.Context()); err == nil {
+ total := 0
+ for _, n := range count {
+ total += n
+ }
+ steps = append(steps, SetupStep{
+ Title: "Run your first task",
+ Detail: "Assign Archie an issue, or ask it for something in chat.",
+ Done: total > 0,
+ })
+ }
+
+ writeJSON(w, map[string]any{"steps": steps, "operator": operator})
+}
+
+// hasChannel reports whether any conversational front-end is configured.
+// Chat is disabled entirely when no channel token is set, so the presence of
+// one is the honest signal here.
+func (s *Server) hasChannel() bool {
+ return strings.TrimSpace(s.Cfg.Chat.Telegram.TokenEnv) != "" ||
+ strings.TrimSpace(s.Cfg.Chat.WebhookAddr) != ""
+}
diff --git a/internal/webui/api_skills.go b/internal/webui/api_skills.go
new file mode 100644
index 000000000..16617ac30
--- /dev/null
+++ b/internal/webui/api_skills.go
@@ -0,0 +1,58 @@
+package webui
+
+import (
+ "net/http"
+
+ "github.com/samcharles93/archie-core/internal/skill"
+)
+
+// SkillView is one catalogued skill as shown on the dashboard's Skills page:
+// what it does, in plain language, and where it was discovered.
+type SkillView struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Workflow string `json:"workflow,omitempty"`
+ Source string `json:"source"`
+}
+
+// handleSkills reports the skill catalogue -- what Archie can actually do,
+// beyond what is in the source. It answers the same question a fresh
+// operator would ask by reading internal/skill/, without the reading.
+//
+// The catalogue is scanned from cfg.SkillsDir when configured (a shared
+// directory meant to be pointed at deliberately), falling back to
+// cfg.WorkDir's own .agents/skills/ otherwise. Both are legitimate --
+// skill.Catalog treats a missing directory as "no skills," not an error --
+// so an unconfigured deployment gets an empty, explained list rather than a
+// failure.
+func (s *Server) handleSkills(w http.ResponseWriter, r *http.Request) {
+ if s.Cfg == nil {
+ writeJSON(w, map[string]any{"skills": []SkillView{}, "dir": ""})
+ return
+ }
+
+ dir := s.Cfg.SkillsDir
+ source := "shared skills directory"
+ if dir == "" {
+ dir = s.Cfg.WorkDir
+ source = "bundled with this project"
+ }
+
+ catalog, err := skill.Catalog(dir)
+ if err != nil {
+ http.Error(w, "failed to read skill catalogue: "+err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ views := make([]SkillView, 0, len(catalog))
+ for _, entry := range catalog {
+ views = append(views, SkillView{
+ Name: entry.Name,
+ Description: entry.Description,
+ Workflow: entry.Workflow,
+ Source: source,
+ })
+ }
+
+ writeJSON(w, map[string]any{"skills": views, "dir": dir})
+}
diff --git a/internal/webui/api_tasks.go b/internal/webui/api_tasks.go
new file mode 100644
index 000000000..cb66a074e
--- /dev/null
+++ b/internal/webui/api_tasks.go
@@ -0,0 +1,66 @@
+package webui
+
+import (
+ "net/http"
+ "strconv"
+)
+
+func (s *Server) handleSummary(w http.ResponseWriter, r *http.Request) {
+ ctx := r.Context()
+ statuses, err := s.Store.StatusCounts(ctx)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ workflows, err := s.Store.WorkflowStats(ctx)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ stages, err := s.Store.StageStats(ctx)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ days, err := s.Store.TokensByDay(ctx, 14)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ writeJSON(w, map[string]any{
+ "statuses": statuses, "workflows": workflows,
+ "stages": stages, "tokens_by_day": days,
+ })
+}
+
+func (s *Server) handleTasks(w http.ResponseWriter, r *http.Request) {
+ tasks, err := s.Store.Tasks(r.Context(), 100)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ writeJSON(w, tasks)
+}
+
+func (s *Server) handleClearTasks(w http.ResponseWriter, r *http.Request) {
+ deleted, err := s.Store.ClearTerminalTasks(r.Context())
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ writeJSON(w, map[string]any{"deleted": deleted})
+}
+
+func (s *Server) handleTask(w http.ResponseWriter, r *http.Request) {
+ id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
+ if err != nil {
+ http.Error(w, "bad id", http.StatusBadRequest)
+ return
+ }
+ evs, err := s.Store.TaskEvents(r.Context(), id)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ writeJSON(w, evs)
+}
diff --git a/internal/webui/api_workflows.go b/internal/webui/api_workflows.go
new file mode 100644
index 000000000..c37d7f12e
--- /dev/null
+++ b/internal/webui/api_workflows.go
@@ -0,0 +1,24 @@
+package webui
+
+import "net/http"
+
+// handleWorkflows returns per-workflow and per-stage statistics: run counts,
+// outcome breakdowns and spend per workflow, plus duration and failure counts
+// per stage -- "where does it get stuck" for the workflows page.
+func (s *Server) handleWorkflows(w http.ResponseWriter, r *http.Request) {
+ ctx := r.Context()
+ workflows, err := s.Store.WorkflowStats(ctx)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ stages, err := s.Store.StageStats(ctx)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ writeJSON(w, map[string]any{
+ "workflows": workflows,
+ "stages": stages,
+ })
+}
diff --git a/internal/webui/auth.go b/internal/webui/auth.go
new file mode 100644
index 000000000..fc74106dc
--- /dev/null
+++ b/internal/webui/auth.go
@@ -0,0 +1,142 @@
+package webui
+
+import (
+ "crypto/rand"
+ "crypto/subtle"
+ "encoding/base64"
+ "fmt"
+ "net"
+ "net/http"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// tokenCookie carries the dashboard token once it has been exchanged from the
+// URL, so the token is not left sitting in browser history or referrers.
+const tokenCookie = "archie_ui"
+
+// IsLoopback reports whether a listen address is reachable only from this
+// machine.
+//
+// Loopback binds need no token. Archie's agent already runs shell, write and
+// edit tools on the host, so anyone with local access has the capability
+// regardless; a lock here would only obstruct the operator. What a token
+// protects is *exposure* -- an instance reachable from a network -- so that is
+// the only case where one is required.
+func IsLoopback(listen string) bool {
+ host, _, err := net.SplitHostPort(strings.TrimSpace(listen))
+ if err != nil {
+ host = strings.TrimSpace(listen)
+ }
+ switch host {
+ case "", "localhost":
+ return true
+ }
+ ip := net.ParseIP(host)
+ return ip != nil && ip.IsLoopback()
+}
+
+// DashboardURL renders a listen address as a URL a human can actually open.
+//
+// A wildcard bind ("0.0.0.0:8484", ":8484", "[::]:8484") is a valid thing to
+// listen on but not a valid thing to visit, and printing it verbatim gives the
+// operator a link that goes nowhere. The host is substituted for localhost,
+// which is correct for the machine reading the log.
+func DashboardURL(listen, token string) string {
+ host, port, err := net.SplitHostPort(strings.TrimSpace(listen))
+ if err != nil {
+ host, port = "", strings.TrimPrefix(strings.TrimSpace(listen), ":")
+ }
+ switch host {
+ case "", "0.0.0.0", "::", "[::]":
+ host = "localhost"
+ }
+ url := "http://" + net.JoinHostPort(host, port) + "/"
+ if token != "" {
+ url += "?t=" + token
+ }
+ return url
+}
+
+// LoadOrCreateToken returns the dashboard token, generating and persisting one
+// on first use. The token is created rather than configured so a non-loopback
+// bind cannot be brought up unprotected by omission: there is no setup step to
+// forget.
+func LoadOrCreateToken(path string) (string, error) {
+ if b, err := os.ReadFile(path); err == nil {
+ if tok := strings.TrimSpace(string(b)); tok != "" {
+ return tok, nil
+ }
+ } else if !os.IsNotExist(err) {
+ return "", fmt.Errorf("webui: read token: %w", err)
+ }
+
+ raw := make([]byte, 32)
+ if _, err := rand.Read(raw); err != nil {
+ return "", fmt.Errorf("webui: generate token: %w", err)
+ }
+ tok := base64.RawURLEncoding.EncodeToString(raw)
+
+ if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
+ return "", fmt.Errorf("webui: token dir: %w", err)
+ }
+ if err := os.WriteFile(path, []byte(tok+"\n"), 0o600); err != nil {
+ return "", fmt.Errorf("webui: write token: %w", err)
+ }
+ return tok, nil
+}
+
+// requireToken wraps h with token authentication. A zero token disables the
+// check entirely, which is how loopback binds stay frictionless.
+//
+// The token may arrive as ?t=... once; it is then moved into a
+// SameSite=Strict, HttpOnly cookie and the caller redirected to the clean URL.
+// One click on the URL archied logs is the whole setup.
+// The token is read per request rather than captured when the handler is
+// built, so a Server whose Token is set after Handler() is still protected.
+func (s *Server) requireToken(h http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if s.Token == "" {
+ h.ServeHTTP(w, r)
+ return
+ }
+ if tok := r.URL.Query().Get("t"); tok != "" {
+ if !tokenEqual(tok, s.Token) {
+ http.Error(w, "unauthorised", http.StatusUnauthorized)
+ return
+ }
+ http.SetCookie(w, &http.Cookie{
+ Name: tokenCookie,
+ Value: tok,
+ Path: "/",
+ HttpOnly: true,
+ SameSite: http.SameSiteStrictMode,
+ Secure: r.TLS != nil,
+ })
+ clean := *r.URL
+ q := clean.Query()
+ q.Del("t")
+ clean.RawQuery = q.Encode()
+ http.Redirect(w, r, clean.RequestURI(), http.StatusSeeOther)
+ return
+ }
+
+ if c, err := r.Cookie(tokenCookie); err == nil && tokenEqual(c.Value, s.Token) {
+ h.ServeHTTP(w, r)
+ return
+ }
+ if hdr := r.Header.Get("Authorization"); strings.HasPrefix(hdr, "Bearer ") &&
+ tokenEqual(strings.TrimPrefix(hdr, "Bearer "), s.Token) {
+ h.ServeHTTP(w, r)
+ return
+ }
+
+ w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ http.Error(w, "unauthorised: open the dashboard URL archied logged at startup", http.StatusUnauthorized)
+ })
+}
+
+func tokenEqual(got, want string) bool {
+ return subtle.ConstantTimeCompare([]byte(got), []byte(want)) == 1
+}
diff --git a/internal/webui/dashboard_url_test.go b/internal/webui/dashboard_url_test.go
new file mode 100644
index 000000000..71d9bfbde
--- /dev/null
+++ b/internal/webui/dashboard_url_test.go
@@ -0,0 +1,17 @@
+package webui
+
+import "testing"
+
+func TestDashboardURL(t *testing.T) {
+ for _, tc := range []struct{ listen, token, want string }{
+ {"0.0.0.0:8484", "abc", "http://localhost:8484/?t=abc"},
+ {":8484", "abc", "http://localhost:8484/?t=abc"},
+ {"[::]:8484", "abc", "http://localhost:8484/?t=abc"},
+ {"127.0.0.1:8484", "", "http://127.0.0.1:8484/"},
+ {"100.64.1.2:8484", "x", "http://100.64.1.2:8484/?t=x"},
+ } {
+ if got := DashboardURL(tc.listen, tc.token); got != tc.want {
+ t.Errorf("DashboardURL(%q) = %q, want %q", tc.listen, got, tc.want)
+ }
+ }
+}
diff --git a/internal/webui/index.html b/internal/webui/index.html
deleted file mode 100644
index a20893262..000000000
--- a/internal/webui/index.html
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-archie
-
-
-
-
- archie
- autonomous project agent -- connecting…
-
-
-
-
-
- Tasks Clear Completed
-
- repo issue title workflow status
- steps tokens
-
-
-
-
-
-
-
-
- Workflows
-
- workflow runs merged
- open parked
- avg tokens avg steps total tokens
-
-
-
-
-
-
- Stages
-
- workflow stage runs
- avg duration errors
-
-
-
-
-
-
diff --git a/internal/webui/server.go b/internal/webui/server.go
new file mode 100644
index 000000000..fed6f7031
--- /dev/null
+++ b/internal/webui/server.go
@@ -0,0 +1,125 @@
+// Package webui is archied's dashboard: a control room over the daemon's
+// task board, activity stream and configuration.
+//
+// The Go side owns serving and the JSON API only; the frontend lives in the
+// repo-root ui/ package, which exposes the built assets as an embedded FS.
+// Handlers are split by concern -- one file per API area -- so a section can
+// be added without growing a single file without end.
+package webui
+
+import (
+ "context"
+ "encoding/json"
+ "io/fs"
+ "log/slog"
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/samcharles93/archie-core/internal/config"
+ "github.com/samcharles93/archie-core/internal/events"
+ "github.com/samcharles93/archie-core/internal/memory"
+ "github.com/samcharles93/archie-core/internal/store"
+ "github.com/samcharles93/archie-core/ui"
+)
+
+type Server struct {
+ Store store.TaskStore
+ Log *slog.Logger
+
+ // Cfg backs the setup checklist and configuration views. Optional: the
+ // dashboard degrades to task data alone when it is nil.
+ Cfg *config.Config
+
+ // Memory backs the memory view. Optional: the section reports memory as
+ // unavailable rather than failing when it is nil.
+ Memory *memory.Manager
+
+ // Token gates access. Empty means no check, which is how loopback binds
+ // stay frictionless -- see IsLoopback.
+ Token string
+
+ mu sync.Mutex
+ conns map[chan events.Event]struct{}
+}
+
+// Broadcast fans an (ID-stamped) event out to every connected SSE
+// client; stalled clients drop events rather than blocking the caller.
+func (s *Server) Broadcast(e events.Event) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ for c := range s.conns {
+ select {
+ case c <- e:
+ default:
+ }
+ }
+}
+
+func (s *Server) Handler() http.Handler {
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /api/summary", s.handleSummary)
+ mux.HandleFunc("GET /api/setup", s.handleSetup)
+ mux.HandleFunc("GET /api/tasks", s.handleTasks)
+ mux.HandleFunc("GET /api/tasks/{id}", s.handleTask)
+ mux.HandleFunc("GET /api/tasks/clear", s.handleClearTasks)
+ mux.HandleFunc("GET /api/workflows", s.handleWorkflows)
+ mux.HandleFunc("GET /api/skills", s.handleSkills)
+ mux.HandleFunc("GET /api/channels", s.handleChannels)
+ mux.HandleFunc("GET /api/config", s.handleConfig)
+ mux.HandleFunc("GET /api/logs", s.handleLogs)
+ mux.HandleFunc("GET /api/memory", s.handleMemory)
+ mux.HandleFunc("GET /events", s.handleSSE)
+ mux.Handle("GET /", s.assets())
+ return s.requireToken(mux)
+}
+
+// assets serves the embedded dashboard, falling back to index.html so client
+// routes deep-link correctly. Under the no_ui build tag the assets are absent
+// and a plain explanation is served instead of a confusing 404.
+func (s *Server) assets() http.Handler {
+ if ui.DistDirFS == nil {
+ return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ http.Error(w, "dashboard not built into this binary (no_ui)", http.StatusNotFound)
+ })
+ }
+ files := http.FileServerFS(ui.DistDirFS)
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if _, err := fs.Stat(ui.DistDirFS, trimLeadingSlash(r.URL.Path)); err != nil {
+ r = r.Clone(r.Context())
+ r.URL.Path = "/"
+ }
+ files.ServeHTTP(w, r)
+ })
+}
+
+func trimLeadingSlash(p string) string {
+ if len(p) > 0 && p[0] == '/' {
+ return p[1:]
+ }
+ if p == "" {
+ return "."
+ }
+ return p
+}
+
+// Run serves until ctx ends.
+func (s *Server) Run(ctx context.Context, listen string) error {
+ srv := &http.Server{Addr: listen, Handler: s.Handler(), ReadHeaderTimeout: 5 * time.Second}
+ go func() {
+ <-ctx.Done()
+ shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 2*time.Second)
+ defer cancel()
+ _ = srv.Shutdown(shutdownCtx)
+ }()
+ s.Log.Info("web ui listening", "addr", "http://"+listen)
+ if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
+ return err
+ }
+ return nil
+}
+
+func writeJSON(w http.ResponseWriter, v any) {
+ w.Header().Set("Content-Type", "application/json")
+ _ = json.NewEncoder(w).Encode(v)
+}
diff --git a/internal/webui/sse.go b/internal/webui/sse.go
new file mode 100644
index 000000000..88d6f1c76
--- /dev/null
+++ b/internal/webui/sse.go
@@ -0,0 +1,76 @@
+package webui
+
+import (
+ "encoding/json"
+ "net/http"
+ "strconv"
+
+ "github.com/samcharles93/archie-core/internal/events"
+)
+
+// handleSSE streams events: catch-up from the store (?since=),
+// then live from the broadcast hub.
+func (s *Server) handleSSE(w http.ResponseWriter, r *http.Request) {
+ fl, ok := w.(http.Flusher)
+ if !ok {
+ http.Error(w, "streaming unsupported", http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "text/event-stream")
+ w.Header().Set("Cache-Control", "no-cache")
+
+ since, _ := strconv.ParseInt(r.URL.Query().Get("since"), 10, 64)
+ send := func(e events.Event) bool {
+ b, err := json.Marshal(e)
+ if err != nil {
+ return true
+ }
+ if _, err := w.Write([]byte("id: " + strconv.FormatInt(e.ID, 10) + "\ndata: " + string(b) + "\n\n")); err != nil {
+ return false
+ }
+ fl.Flush()
+ return true
+ }
+
+ if backlog, err := s.Store.EventsSince(r.Context(), since, 200); err != nil {
+ s.Log.Error("sse backlog fetch failed", "error", err, "since", since)
+ // A comment frame keeps the stream open; the client sees the
+ // backlog gap rather than a silent truncation.
+ _, _ = w.Write([]byte(":error " + err.Error() + "\n"))
+ fl.Flush()
+ } else {
+ for _, e := range backlog {
+ if !send(e) {
+ return
+ }
+ since = e.ID
+ }
+ }
+
+ c := make(chan events.Event, 64)
+ s.mu.Lock()
+ if s.conns == nil {
+ s.conns = map[chan events.Event]struct{}{}
+ }
+ s.conns[c] = struct{}{}
+ s.mu.Unlock()
+ defer func() {
+ s.mu.Lock()
+ delete(s.conns, c)
+ s.mu.Unlock()
+ }()
+
+ for {
+ select {
+ case <-r.Context().Done():
+ return
+ case e := <-c:
+ if e.ID <= since {
+ continue // already replayed from the backlog
+ }
+ if !send(e) {
+ return
+ }
+ }
+ }
+}
diff --git a/internal/webui/webui.go b/internal/webui/webui.go
deleted file mode 100644
index f249242de..000000000
--- a/internal/webui/webui.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Package webui is archied's observability dashboard: task board,
-// per-task timelines, workflow/stage metrics, and a live event tail
-// over SSE. Read-only -- the daemon is steered through GitHub, not here.
-// Bind it to localhost or a tailnet address; it has no auth.
-package webui
-
-import (
- "context"
- _ "embed"
- "encoding/json"
- "log/slog"
- "net/http"
- "strconv"
- "sync"
- "time"
-
- "github.com/samcharles93/archie-core/internal/events"
- "github.com/samcharles93/archie-core/internal/store"
-)
-
-//go:embed index.html
-var indexHTML []byte
-
-type Server struct {
- Store store.TaskStore
- Log *slog.Logger
-
- mu sync.Mutex
- conns map[chan events.Event]struct{}
-}
-
-// Broadcast fans an (ID-stamped) event out to every connected SSE
-// client; stalled clients drop events rather than blocking the caller.
-func (s *Server) Broadcast(e events.Event) {
- s.mu.Lock()
- defer s.mu.Unlock()
- for c := range s.conns {
- select {
- case c <- e:
- default:
- }
- }
-}
-
-func (s *Server) Handler() http.Handler {
- mux := http.NewServeMux()
- mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- _, _ = w.Write(indexHTML)
- })
- mux.HandleFunc("GET /api/summary", s.handleSummary)
- mux.HandleFunc("GET /api/tasks", s.handleTasks)
- mux.HandleFunc("GET /api/tasks/{id}", s.handleTask)
- mux.HandleFunc("GET /api/tasks/clear", s.handleClearTasks)
- mux.HandleFunc("GET /events", s.handleSSE)
- return mux
-}
-
-// Run serves until ctx ends.
-func (s *Server) Run(ctx context.Context, listen string) error {
- srv := &http.Server{Addr: listen, Handler: s.Handler(), ReadHeaderTimeout: 5 * time.Second}
- go func() {
- <-ctx.Done()
- shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 2*time.Second)
- defer cancel()
- _ = srv.Shutdown(shutdownCtx)
- }()
- s.Log.Info("web ui listening", "addr", "http://"+listen)
- if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
- return err
- }
- return nil
-}
-
-func writeJSON(w http.ResponseWriter, v any) {
- w.Header().Set("Content-Type", "application/json")
- _ = json.NewEncoder(w).Encode(v)
-}
-
-func (s *Server) handleSummary(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
- statuses, err := s.Store.StatusCounts(ctx)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- workflows, err := s.Store.WorkflowStats(ctx)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- stages, err := s.Store.StageStats(ctx)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- days, err := s.Store.TokensByDay(ctx, 14)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- writeJSON(w, map[string]any{
- "statuses": statuses, "workflows": workflows,
- "stages": stages, "tokens_by_day": days,
- })
-}
-
-func (s *Server) handleTasks(w http.ResponseWriter, r *http.Request) {
- tasks, err := s.Store.Tasks(r.Context(), 100)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- writeJSON(w, tasks)
-}
-
-func (s *Server) handleClearTasks(w http.ResponseWriter, r *http.Request) {
- deleted, err := s.Store.ClearTerminalTasks(r.Context())
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- writeJSON(w, map[string]any{"deleted": deleted})
-}
-
-func (s *Server) handleTask(w http.ResponseWriter, r *http.Request) {
- id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
- if err != nil {
- http.Error(w, "bad id", http.StatusBadRequest)
- return
- }
- evs, err := s.Store.TaskEvents(r.Context(), id)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- writeJSON(w, evs)
-}
-
-// handleSSE streams events: catch-up from the store (?since=),
-// then live from the broadcast hub.
-func (s *Server) handleSSE(w http.ResponseWriter, r *http.Request) {
- fl, ok := w.(http.Flusher)
- if !ok {
- http.Error(w, "streaming unsupported", http.StatusInternalServerError)
- return
- }
- w.Header().Set("Content-Type", "text/event-stream")
- w.Header().Set("Cache-Control", "no-cache")
-
- since, _ := strconv.ParseInt(r.URL.Query().Get("since"), 10, 64)
- send := func(e events.Event) bool {
- b, err := json.Marshal(e)
- if err != nil {
- return true
- }
- if _, err := w.Write([]byte("id: " + strconv.FormatInt(e.ID, 10) + "\ndata: " + string(b) + "\n\n")); err != nil {
- return false
- }
- fl.Flush()
- return true
- }
-
- if backlog, err := s.Store.EventsSince(r.Context(), since, 200); err != nil {
- s.Log.Error("sse backlog fetch failed", "error", err, "since", since)
- w.Write([]byte(":error " + err.Error() + "\n"))
- fl.Flush()
- } else {
- for _, e := range backlog {
- if !send(e) {
- return
- }
- since = e.ID
- }
- }
-
- c := make(chan events.Event, 64)
- s.mu.Lock()
- if s.conns == nil {
- s.conns = map[chan events.Event]struct{}{}
- }
- s.conns[c] = struct{}{}
- s.mu.Unlock()
- defer func() {
- s.mu.Lock()
- delete(s.conns, c)
- s.mu.Unlock()
- }()
-
- for {
- select {
- case <-r.Context().Done():
- return
- case e := <-c:
- if e.ID <= since {
- continue // already replayed from the backlog
- }
- if !send(e) {
- return
- }
- }
- }
-}
diff --git a/internal/webui/webui_test.go b/internal/webui/webui_test.go
index 6277d35e8..52c8a3b17 100644
--- a/internal/webui/webui_test.go
+++ b/internal/webui/webui_test.go
@@ -1,5 +1,16 @@
package webui
+// The dashboard moved from a hand-written index.html embedded in this package
+// to the Vite build in ui/. Four tests were removed with it:
+//
+// - TestIndexContainsViewportMeta, TestIndexHasResponsiveFeatures asserted
+// markup and CSS that now live in ui/index.html and ui/src/css/.
+// - TestIndexEscapesSingleQuotesInOnclick, TestIndexEscDoesNotEscapeSingleQuotes
+// guarded against injection through string-interpolated onclick handlers.
+// That bug is no longer reachable: ui/src/base/dom.js builds nodes with
+// createTextNode and addEventListener, so no markup is assembled from
+// strings at all.
+
import (
"bufio"
"context"
@@ -239,61 +250,18 @@ func TestHandleIndex(t *testing.T) {
}
}
-func TestIndexContainsViewportMeta(t *testing.T) {
- srv := newTestServer(t)
- ctx := t.Context()
- req := httptest.NewRequestWithContext(ctx, http.MethodGet, "/", nil)
- w := httptest.NewRecorder()
- srv.Handler().ServeHTTP(w, req)
- if w.Code != http.StatusOK {
- t.Fatalf("status = %d", w.Code)
- }
- body := w.Body.String()
- if !strings.Contains(body, ` `) {
- t.Error("viewport meta missing in rendered HTML")
- }
-}
-
-func TestIndexHasResponsiveFeatures(t *testing.T) {
- srv := newTestServer(t)
- ctx := t.Context()
- req := httptest.NewRequestWithContext(ctx, http.MethodGet, "/", nil)
- w := httptest.NewRecorder()
- srv.Handler().ServeHTTP(w, req)
- if w.Code != http.StatusOK {
- t.Fatalf("status = %d", w.Code)
- }
- body := w.Body.String()
- reqs := []struct {
- name string
- want string
- }{
- {"section-table", ".section-table { overflow-x: auto; }"},
- {"feed-wraps", "white-space: normal"},
- {"feed-break-word", "overflow-wrap: break-word"},
- {"700px-breakpoint", "@media (max-width: 700px)"},
- {"950px-breakpoint", "@media (max-width: 950px)"},
- {"viewport-meta", ` `},
- }
- for _, r := range reqs {
- if !strings.Contains(body, r.want) {
- t.Errorf("missing responsive feature %q: %q", r.name, r.want)
- }
- }
-}
-
// TestHandleSSEEventsSinceError proves that handleSSE does not silently
// discard an error from EventsSince. Today the handler has no else
// branch for err != nil, so the error is swallowed and the client
// receives no signal that catch-up was skipped: this test FAILS.
func TestHandleSSEEventsSinceError(t *testing.T) {
- real := newTestServer(t)
+ actual := newTestServer(t)
srv := &Server{
Store: &stubStore{
- TaskStore: real.Store,
+ TaskStore: actual.Store,
eventsSinceErr: fmt.Errorf("db locked"),
},
- Log: real.Log,
+ Log: actual.Log,
}
ts := httptest.NewServer(srv.Handler())
@@ -375,69 +343,6 @@ func TestHandleSSEBacklogAndLive(t *testing.T) {
}
}
-func TestIndexEscapesSingleQuotesInOnclick(t *testing.T) {
- srv := newTestServer(t)
- ctx := t.Context()
- req := httptest.NewRequestWithContext(ctx, http.MethodGet, "/", nil)
- w := httptest.NewRecorder()
- srv.Handler().ServeHTTP(w, req)
-
- if w.Code != http.StatusOK {
- t.Fatalf("status = %d", w.Code)
- }
- body := w.Body.String()
-
- // escJS helper must be defined.
- if !strings.Contains(body, "escJS") {
- t.Fatal("escJS helper not found in HTML")
- }
-
- // The onclick template must use escJS (not esc) for owner and
- // repo -- the values interpolated into the single-quoted JS str.
- if !strings.Contains(body, "escJS(t.owner)") {
- t.Error("onclick does not use escJS for owner")
- }
- if !strings.Contains(body, "escJS(t.repo)") {
- t.Error("onclick does not use escJS for repo")
- }
-}
-
-func TestIndexEscDoesNotEscapeSingleQuotes(t *testing.T) {
- srv := newTestServer(t)
- ctx := t.Context()
- req := httptest.NewRequestWithContext(ctx, http.MethodGet, "/", nil)
- w := httptest.NewRecorder()
- srv.Handler().ServeHTTP(w, req)
-
- if w.Code != http.StatusOK {
- t.Fatalf("status = %d", w.Code)
- }
- body := w.Body.String()
-
- // esc() must NOT escape single quotes -- it's used for HTML
- // content/attribute contexts where apostrophes are legitimate
- // (e.g. issue titles like "Don't panic").
- idx := strings.Index(body, "const esc =")
- if idx == -1 {
- t.Fatal("esc definition not found")
- }
- snippet := body[idx : idx+200]
- // The regex should escape & < > " but NOT '
- if !strings.Contains(snippet, "[&<>\"") {
- t.Error("esc regex character class is missing or malformed")
- }
- // The character class must NOT include a single quote.
- reStart := strings.Index(snippet, "[&<>\"")
- reEnd := strings.Index(snippet[reStart:], "]")
- if reEnd == -1 {
- t.Fatal("could not find end of esc regex character class")
- }
- charClass := snippet[reStart : reStart+reEnd]
- if strings.Contains(charClass, "'") {
- t.Error("esc() regex escapes single quotes -- this would cause backslash artifacts in HTML text")
- }
-}
-
// readLineUntil scans SSE "data:" lines until one contains want.
func readLineUntil(r *bufio.Reader, want string) (string, error) {
deadline := time.Now().Add(3 * time.Second)
diff --git a/ui/dist/assets/index.css b/ui/dist/assets/index.css
new file mode 100644
index 000000000..6b8a9b486
--- /dev/null
+++ b/ui/dist/assets/index.css
@@ -0,0 +1 @@
+:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);padding-right:var(--sp-4);font-weight:500}.nav-item .nav-label{display:none}.nav-item[aria-current=page] .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accent), var(--accent-2));cursor:pointer;flex:none;place-items:center;font-weight:600;display:grid}.ico{flex:none;display:block}.main{padding:var(--sp-6);flex:1;width:100%;overflow-x:hidden}@media (width<=900px){body{padding:0}.shell{min-height:100vh;box-shadow:none;border:0;border-radius:0}.topbar{padding:var(--sp-3);gap:var(--sp-2);flex-wrap:wrap}.nav{border-radius:var(--radius-lg);scrollbar-width:none;order:3;justify-content:flex-start;width:100%;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item .nav-label{display:inline}.topbar-search{display:none}.main{padding:var(--sp-4)}}.page-head{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-6);flex-wrap:wrap;display:flex}.page-title{font-size:var(--text-2xl);letter-spacing:-.02em;margin:0;font-weight:600}.page-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.page-actions{gap:var(--sp-2);align-items:center;display:flex}.btn{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-4);border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:background var(--transition), border-color var(--transition);display:inline-flex}.btn:hover{background:var(--surface-hover)}.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg);font-weight:500}.btn-primary:hover{filter:brightness(1.08);background:var(--accent)}.btn-icon{padding:var(--sp-2);border-radius:var(--radius-sm)}.card{background:var(--surface-glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--hairline);border-radius:var(--radius-lg);padding:var(--sp-5);box-shadow:var(--shadow-sm)}.card-head{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);display:flex}.card-title{font-size:var(--text-base);margin:0;font-weight:600}.card-sub{font-size:var(--text-xs);color:var(--fg-muted);margin:var(--sp-1) 0 0}.grid{gap:var(--sp-4);display:grid}.grid-4{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}.pill{align-items:center;gap:var(--sp-1);padding:2px var(--sp-2);border-radius:var(--radius-pill);font-size:var(--text-xs);white-space:nowrap;font-weight:500;display:inline-flex}.pill:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.pill-ok{color:var(--ok);background:var(--ok-soft)}.pill-warn{color:var(--warn);background:var(--warn-soft)}.pill-danger{color:var(--danger);background:var(--danger-soft)}.pill-info{color:var(--info);background:var(--info-soft)}.pill-idle{color:var(--idle);background:var(--idle-soft)}.table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}.table th{text-align:left;font-weight:500;font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);padding:0 var(--sp-3) var(--sp-3);border-bottom:1px solid var(--border)}.table td{padding:var(--sp-3);border-bottom:1px solid var(--border);color:var(--fg-muted)}.table tbody tr:last-child td{border-bottom:0}.table tbody tr:hover td{background:var(--surface-hover)}.table td.strong{color:var(--fg);font-weight:500}.mono{font-family:var(--font-mono);font-size:.95em}.empty{text-align:center;padding:var(--sp-7) var(--sp-4);color:var(--fg-muted)}.empty-title{color:var(--fg);margin-bottom:var(--sp-1);font-weight:500}.skeleton{background:linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);border-radius:var(--radius-sm);background-size:200% 100%;animation:1.4s infinite shimmer}@keyframes shimmer{to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}.nav-soon{font-size:var(--text-xs);color:var(--fg-subtle);background:var(--surface-hover);padding:1px var(--sp-2);border-radius:var(--radius-pill);margin-left:auto}.nav-item[aria-disabled]{opacity:.55;cursor:default}.nav-item[aria-disabled]:hover{color:var(--fg-muted);background:0 0}.stat-head{justify-content:space-between;align-items:center;gap:var(--sp-2);display:flex}.stat-label{font-size:var(--text-sm);color:var(--fg-muted)}.stat-trend{font-size:var(--text-xs);align-items:center;gap:3px;font-weight:500;display:inline-flex}.stat-trend.up{color:var(--ok)}.stat-trend.down{color:var(--danger)}.stat-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin:var(--sp-2) 0 0;font-weight:600}.stat-unit{font-size:var(--text-lg);color:var(--fg-muted);margin-left:var(--sp-1)}.stat-compare{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:var(--sp-1)}.spark{width:100%;height:34px;margin-top:var(--sp-3);display:block}.setup{margin-bottom:var(--sp-4)}.setup-pct{font-size:var(--text-lg);color:var(--accent);font-weight:600}.setup-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-bottom:var(--sp-4);overflow:hidden}.setup-bar-fill{background:var(--accent);border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.setup-list{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.setup-step{gap:var(--sp-3);align-items:flex-start;display:flex}.setup-check{border:1.5px solid var(--border-strong);width:18px;height:18px;font-size:var(--text-xs);color:var(--fg-subtle);border-radius:50%;flex:none;place-items:center;margin-top:1px;display:grid}.setup-step.done .setup-check{background:var(--ok-soft);color:var(--ok);border-color:#0000}.setup-step-title{font-size:var(--text-sm)}.setup-step.done .setup-step-title{color:var(--fg-muted);text-decoration:line-through}.setup-step-detail{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.hero{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-5);flex-wrap:wrap;display:flex}.hero-title{font-size:var(--text-3xl);letter-spacing:-.03em;margin:0;font-weight:600}.hero-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-2) 0 0}.hero-actions{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.dash-top{gap:var(--sp-4);margin-bottom:var(--sp-4);grid-template-columns:1.6fr 1fr;display:grid}@media (width<=1080px){.dash-top{grid-template-columns:1fr}}.gauge-wrap{place-items:center;display:grid;position:relative}.gauge{width:100%;max-width:200px;display:block}.gauge-value{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1)}.gauge-center{text-align:center;position:absolute;top:52%;transform:translateY(-50%)}.gauge-pct{font-size:var(--text-2xl);letter-spacing:-.03em;font-weight:600}.gauge-label{font-size:var(--text-xs);color:var(--fg-muted)}.pulse-list{margin:var(--sp-4) 0 0;gap:var(--sp-2);flex-direction:column;padding:0;list-style:none;display:flex}.pulse-item{justify-content:space-between;align-items:center;gap:var(--sp-3);font-size:var(--text-sm);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);display:flex}.pulse-name{color:var(--fg-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.segbar{border-radius:var(--radius-pill);background:var(--border);gap:2px;height:10px;display:flex;overflow:hidden}.segbar-part{height:100%;display:block}.segbar-ok{background:var(--ok)}.segbar-warn{background:var(--warn)}.segbar-danger{background:var(--danger)}.segbar-info{background:var(--info)}.segbar-idle{background:var(--idle)}.segbar-legend{gap:var(--sp-4);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.segbar-key{align-items:center;gap:var(--sp-2);font-size:var(--text-xs);color:var(--fg-muted);display:inline-flex}.segbar-dot{border-radius:50%;width:8px;height:8px}.forecast-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin-bottom:var(--sp-1);font-weight:600}.forecast-note{font-size:var(--text-xs);color:var(--fg-subtle);margin-bottom:var(--sp-4)}.dash-split{gap:var(--sp-4);margin-top:var(--sp-4);grid-template-columns:1fr 1.5fr;display:grid}@media (width<=1080px){.dash-split{grid-template-columns:1fr}}.stat-card{position:relative;overflow:hidden}.dash-section{margin-bottom:var(--sp-5)}.dash-section-head{align-items:baseline;gap:var(--sp-3);margin-bottom:var(--sp-3);padding-left:var(--sp-1);display:flex}.dash-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--fg-subtle);margin:0;font-weight:600}.dash-section-note{font-size:var(--text-xs);color:var(--fg-subtle)}.hero-actions-inner{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.btn-attention{border-color:var(--warn);color:var(--warn);background:var(--warn-soft);font-weight:500}.btn-attention:hover{background:var(--warn-soft);filter:brightness(1.1)}.task-filters{gap:var(--sp-2);align-items:center;display:flex}.task-search,.task-filter{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3)}.task-search{width:220px}.task-search:focus,.task-filter:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.task-row{cursor:pointer}.task-timeline-row td{background:var(--bg-raised);padding:var(--sp-4)}.task-timeline-loading{color:var(--fg-muted);font-size:var(--text-sm)}.task-timeline{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.task-timeline-entry{gap:var(--sp-3);align-items:flex-start;display:flex}.task-timeline-dot{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px;margin-top:5px}.task-timeline-kind{font-size:var(--text-sm);color:var(--fg);font-weight:500}.task-timeline-detail{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}.task-timeline-when{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.skill-search{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);width:220px}.skill-search:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.skill-card{flex-direction:column;display:flex}.skill-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0 0 var(--sp-3);flex:1}.skill-source{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-stage-card{margin-top:var(--sp-4)}.wf-rate{font-size:var(--text-sm);color:var(--fg);align-items:baseline;gap:var(--sp-2);display:flex}.wf-rate-sub{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-top:var(--sp-2);width:140px;overflow:hidden}.wf-bar-fill{border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.wf-bar-ok{background:var(--ok)}.wf-bar-warn{background:var(--warn)}.wf-bar-danger{background:var(--danger)}.wf-bar-info{background:var(--info)}.channel-card{gap:var(--sp-1);flex-direction:column;display:flex}.channel-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.channel-detail{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.cfg-section{margin-bottom:var(--sp-4)}.cfg-subhead{font-size:var(--text-sm);color:var(--fg-muted);margin:var(--sp-4) 0 var(--sp-2);font-weight:600}.cfg-subhead:first-child{margin-top:0}.cfg-rows{gap:var(--sp-2);flex-direction:column;display:flex}.cfg-row{justify-content:space-between;align-items:baseline;gap:var(--sp-4);padding:var(--sp-2) 0;border-bottom:1px solid var(--border);display:flex}.cfg-row:last-child{border-bottom:0}.cfg-label{font-size:var(--text-sm);color:var(--fg-muted)}.cfg-value{font-size:var(--text-sm);color:var(--fg);text-align:right}.log-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.log-status{gap:var(--sp-3);align-items:center;display:flex}.log-meta{font-size:var(--text-xs);color:var(--fg-subtle);font-family:var(--font-mono)}.log-select,.log-search{background:var(--bg-raised);border:1px solid var(--border-strong);color:var(--fg);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);font:inherit;font-size:var(--text-sm)}.log-search{min-width:220px}.log-select:focus,.log-search:focus{outline:2px solid var(--accent);outline-offset:-1px}.log-list{max-height:62vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);overflow-y:auto}.log-loading{padding:var(--sp-5);color:var(--fg-muted);text-align:center}.log-row{gap:var(--sp-3);padding:var(--sp-2) var(--sp-1);border-bottom:1px solid var(--border);grid-template-columns:62px 52px 1fr;align-items:baseline;display:grid}.log-row:hover{background:var(--surface-hover)}.log-time{color:var(--fg-subtle)}.log-level{letter-spacing:.04em;font-size:10px;font-weight:600}.log-danger .log-level{color:var(--danger)}.log-warn .log-level{color:var(--warn)}.log-info .log-level{color:var(--info)}.log-idle .log-level{color:var(--idle)}.log-danger .log-msg{color:var(--fg)}.log-body{gap:var(--sp-2);flex-wrap:wrap;align-items:baseline;min-width:0;display:flex}.log-msg{color:var(--fg);word-break:break-word}.log-field{color:var(--fg-muted);background:var(--bg-raised);border-radius:var(--radius-sm);padding:0 var(--sp-2);white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden}.log-field-key{color:var(--fg-subtle)}.log-field-key:after{content:"=";opacity:.6}@media (width<=860px){.log-row{grid-template-columns:56px 1fr}.log-level{display:none}.log-search{flex:1;min-width:0}}.mem-loading{padding:var(--sp-5);text-align:center;color:var(--fg-muted)}.mem-warning{font-size:var(--text-sm);color:var(--warn);background:var(--warn-soft);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);margin:0 0 var(--sp-3)}.mem-tools{gap:var(--sp-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.mem-tool{padding:var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);border:1px solid var(--hairline)}.mem-tool-name{font-size:var(--text-sm);color:var(--fg);font-weight:500}.mem-tool-desc{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}
diff --git a/ui/dist/assets/index.js b/ui/dist/assets/index.js
new file mode 100644
index 000000000..56bcd07c2
--- /dev/null
+++ b/ui/dist/assets/index.js
@@ -0,0 +1,8 @@
+(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e,n,...r){let[i,...a]=e.split(`.`),o=document.createElement(i||`div`);a.length&&(o.className=a.join(` `)),n&&(typeof n!=`object`||n instanceof Node)&&(r.unshift(n),n=null);for(let[e,t]of Object.entries(n||{}))t!=null&&t!==!1&&(e.startsWith(`on`)&&typeof t==`function`?o.addEventListener(e.slice(2).toLowerCase(),t):e===`class`?o.className=[o.className,t].filter(Boolean).join(` `):e===`html`?o.innerHTML=t:o.setAttribute(e,t===!0?``:String(t)));return t(o,r),o}function t(e,t){for(let n of t.flat(1/0))n!=null&&n!==!1&&e.append(n instanceof Node?n:document.createTextNode(String(n)))}function n(e,...n){return e.replaceChildren(),t(e,n),e}function r(t,n=`idle`){return e(`span.pill.pill-${n}`,t)}function i(e){switch(e){case`running`:return`info`;case`merged`:case`pr_open`:return`ok`;case`parked`:case`waiting_human`:return`warn`;case`dead`:case`rejected`:return`danger`;default:return`idle`}}function a(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function o(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function s(t,n){return e(`div.empty`,e(`div.empty-title`,t),n&&e(`div`,n))}var c={dashboard:` `,tasks:` `,logs:` `,skills:` `,workflows:` `,memory:` `,channels:` `,settings:` `,search:` `,moon:` `,sun:` `,refresh:` `,bell:` `,trendUp:` `,trendDown:` `,check:` `,help:` `};function l(e,{size:t=18,className:n=``}={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(t)),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.6`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`class`,`ico ${n}`.trim()),r.innerHTML=c[e]||c.dashboard,r}async function u(e){let t=await fetch(e,{headers:{Accept:`application/json`}});if(t.status===401)throw new f(`unauthorised`,401);if(!t.ok)throw new f(`${t.status} ${t.statusText}`,t.status);return t.json()}function d(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}var f=class extends Error{constructor(e,t){super(e),this.status=t}},p={summary:()=>u(`/api/summary`),tasks:()=>u(`/api/tasks`),task:e=>u(`/api/tasks/${e}`),setup:()=>u(`/api/setup`),workflows:()=>u(`/api/workflows`),skills:()=>u(`/api/skills`),channels:()=>u(`/api/channels`),config:()=>u(`/api/config`),logs:e=>u(`/api/logs`+d(e)),memory:()=>u(`/api/memory`)};function m(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function h({label:t,value:n,unit:r,trend:i,compare:a,series:o=[],goodDirection:s=`up`}){let c=i==null?null:i>=0?`up`:`down`,u=c==null?null:c===s;return e(`div.card.stat`,e(`div.stat-head`,e(`span.stat-label`,t),c&&e(`span.stat-trend.${u?`up`:`down`}`,l(c===`up`?`trendUp`:`trendDown`,{size:13}),`${Math.abs(i).toFixed(1)}%`)),e(`div.stat-value`,n,r&&e(`span.stat-unit`,r)),a&&e(`div.stat-compare`,a),o.length>1&&g(o,u===!1?`var(--danger)`:`var(--ok)`))}function g(t,n=`var(--ok)`,{width:r=220,height:i=34}={}){let a=Math.max(...t,1),o=Math.min(...t,0),s=a-o||1,c=t.length>1?r/(t.length-1):r,l=t.map((e,t)=>`${(t*c).toFixed(1)},${(i-(e-o)/s*i).toFixed(1)}`).join(` `),u=e(`svg.spark`,{viewBox:`0 0 ${r} ${i}`,preserveAspectRatio:`none`,"aria-hidden":`true`});return u.innerHTML=` `,u}function _({value:t,label:n,size:r=168}){let i=Math.max(0,Math.min(100,Number(t)||0)),a=i>=90?`var(--ok)`:i>=70?`var(--warn)`:`var(--danger)`,o=r/2,s=r/2,c=2*Math.PI*62*(240/360),l=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${o+62*Math.cos(n)} ${s+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${o+62*Math.cos(r)} ${s+62*Math.sin(r)}`].join(` `)},u=e(`svg.gauge`,{viewBox:`0 0 ${r} ${r*.78}`,role:`img`,"aria-label":`${n}: ${i}%`});return u.innerHTML=`
+
+ `,e(`div.gauge-wrap`,u,e(`div.gauge-center`,e(`div.gauge-pct`,`${Math.round(i)}%`),e(`div.gauge-label`,n)))}function v(t){let n=t.reduce((e,t)=>e+(t.value||0),0)||1;return e(`div`,e(`div.segbar`,...t.filter(e=>e.value>0).map(t=>e(`span`,{class:`segbar-part segbar-${t.kind||`idle`}`,style:`width:${(t.value/n*100).toFixed(1)}%`,title:`${t.label}: ${t.value}`}))),e(`div.segbar-legend`,...t.map(t=>e(`span.segbar-key`,e(`span`,{class:`segbar-dot segbar-${t.kind||`idle`}`}),t.label))))}function y(){let t=e(`div`),i=e(`tbody`),a=e(`div.grid.grid-4`),c=e(`div`),u=e(`div`),d=e(`div`),f=e(`div.hero-actions-inner`),g=e(`h1.hero-title`,x()),_=r(`connecting`,`idle`);y(),T();let v=m(e=>b(i,e),e=>{_.className=`pill pill-${e===`live`?`ok`:`warn`}`,_.textContent=e});t.addEventListener(`archie:teardown`,v);function y(){n(t,e(`div.hero`,e(`div`,g,e(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),e(`div.hero-actions`,f)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Health`)),e(`div.dash-top`,c,u)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Throughput`),e(`span.dash-section-note`,`Across all repositories`)),a),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Right now`)),e(`div.dash-split`,d,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Live activity`),e(`p.card-sub`,`Last 50, newest first`)),_),e(`table.table`,e(`thead`,e(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(t=>e(`th`,t)))),i))))),n(i,e(`tr`,e(`td`,{colspan:4},s(`Waiting for activity`,`Events appear here as Archie works.`))))}async function T(){try{let[e,t,n]=await Promise.all([p.summary(),p.setup().catch(()=>null),p.workflows().catch(()=>null)]);E(e),g.textContent=t?.operator?`${x()}, ${t.operator}`:x(),D(e),O(t),k(e,n),A(e)}catch(t){n(a,e(`div.card`,s(`Cannot reach archied`,String(t.message||t))))}}function E(t){let r=t?.statuses||{},i=(r.parked||0)+(r.waiting_human||0),a=r.running||0;n(f,i>0&&e(`a.btn.btn-attention`,{href:`#/tasks`},l(`tasks`,{size:15}),`${i} need${i===1?`s`:``} you`),a>0&&e(`a.btn`,{href:`#/tasks`},l(`workflows`,{size:15}),`${a} running`),e(`a.btn`,{href:`#/logs`},l(`logs`,{size:15}),`Logs`),e(`button.btn.btn-primary`,{onclick:T},l(`refresh`,{size:15}),`Refresh`))}function D(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),s=Object.values(t).reduce((e,t)=>e+t,0),c=e?.tokens_by_day||[];n(a,h({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:c.map(e=>e.tokens||0)}),h({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),h({label:`Delivered`,value:r,compare:s?`${Math.round(r/s*100)}% of all tasks`:`No tasks yet`}),h({label:`Tokens used`,value:o(c.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${c.length||0} days`,trend:w(c.map(e=>e.tokens||0)),goodDirection:`down`,series:c.map(e=>e.tokens||0)}))}function O(t){if(!t?.steps?.length)return n(c);let r=t.steps.filter(e=>!e.done);if(!r.length)return n(c);let i=Math.round((t.steps.length-r.length)/t.steps.length*100);n(c,e(`div.card.setup`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Finish setting up`),e(`p.card-sub`,`Archie needs these before it can work on its own.`)),e(`span.setup-pct`,`${i}%`)),e(`div.setup-bar`,e(`div.setup-bar-fill`,{style:`width:${i}%`})),e(`ul.setup-list`,...t.steps.map(j))))}function k(e,t){S(u,e,t)}function A(e){C(d,e)}function j(t){return e(`li.setup-step${t.done?`.done`:``}`,e(`span.setup-check`,t.done?l(`check`,{size:12}):``),e(`div`,e(`div.setup-step-title`,t.title),t.detail&&e(`div.setup-step-detail`,t.detail)))}return t}function b(t,n){t.firstElementChild?.querySelector(`.empty`)&&t.replaceChildren();let r=e(`tr`,e(`td.strong`,e(`span`,n.kind||n.type||`event`)),e(`td.mono`,n.task_id?`#${n.task_id}`:`—`),e(`td`,n.detail||n.message||``),e(`td`,a(n.at||Date.now())));for(t.prepend(r);t.children.length>50;)t.lastElementChild.remove()}function x(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function S(t,i,a){let o=a?.workflows||[],c=o.reduce((e,t)=>e+(t.runs||0),0),l=o.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),u=o.reduce((e,t)=>e+(t.parked||0),0);if(!c){n(t,e(`div.card`,e(`div.card-head`,e(`h2.card-title`,`Gate pulse`)),s(`No completed runs yet`,`Once Archie finishes a task, its gate pass rate appears here.`)));return}let d=l/c*100;n(t,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Gate pulse`),e(`p.card-sub`,`Work that passed its quality gates`))),_({value:d,label:`pass rate`}),e(`ul.pulse-list`,...o.slice(0,3).map(t=>e(`li.pulse-item`,e(`span.pulse-name`,t.workflow||`workflow`),r(`${t.merged||0}/${t.runs||0}`,(t.merged||0)===(t.runs||0)?`ok`:(t.parked||0)>0?`warn`:`info`))),u>0&&e(`li.pulse-item`,e(`span.pulse-name`,`Parked, awaiting you`),r(String(u),`warn`)))))}function C(t,r){let i=r?.tokens_by_day||[],a=i.reduce((e,t)=>e+(t.tokens||0),0);if(!i.length){n(t,e(`div.card`,e(`div.card-head`,e(`h2.card-title`,`Token outlook`)),s(`Nothing spent yet`,`Usage appears here once Archie runs its first task.`)));return}let c=a/i.length,l=Math.round(c*30),u=i.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);n(t,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Token outlook`),e(`p.card-sub`,`Next 30 days at the current rate`))),e(`div.forecast-value`,o(l)),e(`div.forecast-note`,`Based on ${o(Math.round(c))} per day over ${i.length} days`),v([{label:`Last 7 days (${o(u)})`,value:u,kind:`info`},{label:`Earlier (${o(a-u)})`,value:Math.max(a-u,0),kind:`idle`}])))}function w(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}var T={queued:`Queued`,running:`Working`,waiting_human:`Waiting for you`,pr_open:`In review`,merged:`Merged`,parked:`Parked`,dead:`Stopped (too many retries)`,rejected:`Rejected`,closed_wont_do:`Won't do`};function E(e){return T[e]||e||`Unknown`}function D(){let t=e(`div`),o=e(`div.grid.grid-4`),c=e(`tbody`),l=e(`input.task-search`,{type:`search`,placeholder:`Search by title or repo…`,oninput:e=>{m=e.target.value.trim().toLowerCase(),S()}}),u=e(`select.task-filter`,{onchange:e=>{f=e.target.value,S()}},e(`option`,{value:``},`All statuses`),...Object.entries(T).map(([t,n])=>e(`option`,{value:t},n))),d=[],f=``,m=``,g=null,_=new Map;v(),y();function v(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Tasks`),e(`p.page-sub`,`Every issue archied has picked up, and where it stands.`)),e(`div.page-actions`,e(`button.btn`,{onclick:y},`Refresh`))),o,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`All tasks`),e(`p.card-sub`,`Click a row for its timeline`)),e(`div.task-filters`,l,u)),e(`table.table`,e(`thead`,e(`tr`,...[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`].map(t=>e(`th`,t)))),c)))}async function y(){try{d=await p.tasks(),b(),S()}catch(t){n(o,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(c,e(`tr`,e(`td`,{colspan:7},s(`Cannot reach archied`,String(t.message||t)))))}}function b(){let e=d.length,t={};for(let e of d)t[e.status]=(t[e.status]||0)+1;let r=t.running||0,i=(t.waiting_human||0)+(t.parked||0),a=(t.merged||0)+(t.pr_open||0);n(o,h({label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),h({label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),h({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),h({label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`}))}function x(){return d.filter(e=>f&&e.status!==f?!1:!m||`${e.title} ${e.repo}`.toLowerCase().includes(m))}function S(){let t=x();if(!d.length){n(c,e(`tr`,e(`td`,{colspan:7},s(`No tasks yet`,`Tasks appear here once archied picks up an issue to work.`))));return}if(!t.length){n(c,e(`tr`,e(`td`,{colspan:7},s(`No matching tasks`,`Try a different search or status filter.`))));return}c.replaceChildren();for(let e of t)c.append(C(e)),g===e.id&&c.append(w(e))}function C(t){return e(`tr.task-row`,{onclick:()=>{g=g===t.id?null:t.id,S(),g===t.id&&O(t.id)}},e(`td.mono`,`${t.owner}/${t.repo}`),e(`td.mono`,`#${t.issue_number}`),e(`td.strong`,t.title||`(untitled)`),e(`td`,r(E(t.status),i(t.status))),e(`td`,t.workflow||`—`),e(`td`,t.stage||`—`),e(`td`,{title:t.created_at?`Created ${a(t.created_at)}`:``},a(t.updated_at)))}function w(t){let n=_.get(t.id);return e(`tr.task-timeline-row`,e(`td`,{colspan:7},n===void 0?e(`div.task-timeline-loading`,`Loading timeline…`):n===null?s(`Could not load timeline`,`archied could not be reached for this task's events.`):n.length?e(`ul.task-timeline`,...n.map(D)):s(`No events yet`,`This task has not recorded any transitions.`)))}function D(t){return e(`li.task-timeline-entry`,e(`span.task-timeline-dot`),e(`div`,e(`div.task-timeline-kind`,t.kind||t.type||`event`),t.detail&&e(`div.task-timeline-detail`,t.detail),e(`div.task-timeline-when`,a(t.at))))}async function O(e){try{let t=await p.task(e);_.set(e,t||[])}catch{_.set(e,null)}S()}return t}function O(){let t=e(`div`),r=e(`div.grid.grid-2`),i=e(`input.skill-search`,{type:`search`,placeholder:`Search skills…`,oninput:e=>{o=e.target.value.trim().toLowerCase(),d()}}),a=[],o=``,c=null;l(),u();function l(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Skills`),e(`p.page-sub`,`What Archie can do, in plain language.`)),e(`div.page-actions`,e(`button.btn`,{onclick:u},`Refresh`))),e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Catalogue`),e(`p.card-sub`,`Discovered from .agents/skills/`)),i),r)),d()}async function u(){try{a=(await p.skills())?.skills||[],c=null}catch(e){a=[],c=String(e.message||e)}d()}function d(){if(c)return n(r,s(`Cannot reach archied`,c));if(!a.length)return n(r,s(`No skills discovered yet`,`Skills live as SKILL.md files under .agents/skills//. Add one, or point skills_dir in config.toml at a shared skills directory, and it will appear here.`));let e=a.filter(e=>f(e,o));if(!e.length)return n(r,s(`No skills match`,`Nothing found for "${o}".`));n(r,...e.map(m))}function f(e,t){return!t||`${e.name} ${e.description}`.toLowerCase().includes(t)}function m(t){return e(`div.card.skill-card`,e(`div.card-head`,e(`h3.card-title`,t.name||`Untitled skill`),t.workflow&&e(`span.pill.pill-info`,t.workflow)),e(`p.skill-desc`,t.description||`No description provided.`),e(`div.skill-source`,t.source||`Unknown source`))}return t}var k={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function A(e){return k[e]?k[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function j(e,t){return t?Math.round(e/t*100):0}function M(t,n=`ok`){return e(`div.wf-bar`,e(`div.wf-bar-fill.wf-bar-${n}`,{style:`width:${Math.min(100,Math.max(0,t))}%`}))}function ee(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function te(){let t=e(`div`),r=e(`div`),i=e(`div`);a(),o();function a(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Workflows`),e(`p.page-sub`,`Run outcomes and spend per workflow, and where stages get stuck.`)),e(`div.page-actions`,e(`button.btn`,{onclick:o},`Refresh`))),r,i)}async function o(){try{let e=await p.workflows();c(e?.workflows||[]),l(e?.stages||[])}catch(t){n(r,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(i)}}function c(t){if(!t.length){n(r,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per workflow`))),s(`No workflow runs yet`,`Stats appear here once a task has run through a workflow.`)));return}n(r,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per workflow`),e(`p.card-sub`,`Success rate is merged tasks over all runs`))),e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Runs`,`Success rate`,`Avg tokens`,`Avg steps`].map(t=>e(`th`,t)))),e(`tbody`,...t.map(t=>{let n=j(t.merged,t.runs);return e(`tr`,e(`td.strong`,A(t.workflow)),e(`td`,`${t.runs} run${t.runs===1?``:`s`}`),e(`td`,e(`div.wf-rate`,`${n}%`,e(`span.wf-rate-sub`,`${t.merged} of ${t.runs} merged`)),M(n,n>=50?`ok`:`warn`)),e(`td.mono`,t.avg_tokens?t.avg_tokens.toLocaleString():`—`),e(`td.mono`,t.avg_steps?t.avg_steps.toFixed(1):`—`))})))))}function l(t){if(!t.length){n(i,e(`div.card.wf-stage-card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Per stage`))),s(`No stage data yet`,`Stage timing and failures appear here once workflows have run.`)));return}let r=Math.max(...t.map(e=>e.avg_ms||0),1),a=[...t].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),o=[...t].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);n(i,e(`div.grid.grid-2.wf-stage-card`,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Slowest stages`),e(`p.card-sub`,`Average duration, this workflow's stages`))),e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Stage`,`Runs`,`Avg duration`].map(t=>e(`th`,t)))),e(`tbody`,...a.map(t=>e(`tr`,e(`td`,A(t.workflow)),e(`td.strong`,t.stage),e(`td`,`${t.runs}`),e(`td`,e(`div.wf-rate`,ee(t.avg_ms)),M(j(t.avg_ms,r),`info`))))))),e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Most failures`),e(`p.card-sub`,`Stages that error out, over their runs`))),o.length?e(`table.table`,e(`thead`,e(`tr`,...[`Workflow`,`Stage`,`Failures`].map(t=>e(`th`,t)))),e(`tbody`,...o.map(t=>e(`tr`,e(`td`,A(t.workflow)),e(`td.strong`,t.stage),e(`td`,e(`div.wf-rate`,`${t.errors} of ${t.runs}`),M(j(t.errors,t.runs),`danger`)))))):s(`No failures recorded`,`Every stage has completed cleanly so far.`))))}return t}function N(){let t=e(`div`),i=e(`div.grid.grid-2`);a(),o();function a(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Channels`),e(`p.page-sub`,`The conversational front-ends Archie can be reached through.`)),e(`div.page-actions`,e(`button.btn`,{onclick:o},`Refresh`))),i)}async function o(){try{c((await p.channels())?.channels||[])}catch(e){n(i,s(`Cannot reach archied`,String(e.message||e)))}}function c(e){if(!e.length){n(i,s(`No channels configured`,`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`));return}n(i,...e.map(l))}function l(t){return e(`div.card.channel-card`,e(`div.card-head`,e(`h3.card-title`,t.name),t.configured?r(`connected`,`ok`):r(`not configured`,`idle`)),e(`p.channel-desc`,t.description),e(`p.channel-detail`,t.detail))}return t}function ne(){let t=e(`div`),r=e(`div`);i(),a();function i(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Configuration`),e(`p.page-sub`,`What archied is actually running with right now.`)),e(`div.page-actions`,e(`button.btn`,{onclick:a},`Refresh`))),r)}async function a(){try{o(await p.config())}catch(t){n(r,e(`div.card`,s(`Cannot reach archied`,String(t.message||t))))}}function o(t){if(!t||Object.keys(t).length===0){n(r,e(`div.card`,s(`No configuration loaded`,`archied is running without a config file wired into the dashboard, so there is nothing to show.`)));return}n(r,re(t.identity),ie(t.repositories),L(t.models,t.providers),z(t.budgets),B(t.agent),H(t.storage,t.containers),W(t.web))}return t}function P(t,n,...r){return e(`div.card.cfg-section`,e(`div.card-head`,e(`div`,e(`h2.card-title`,t),e(`p.card-sub`,n))),...r)}function F(t,n){return e(`div.cfg-row`,e(`span.cfg-label`,t),e(`span.cfg-value.mono`,n??`—`))}function re(t){return t?P(`Identity`,`Who Archie is on the forge, and how it addresses commits and comments.`,e(`div.cfg-rows`,F(`Bot account`,t.bot_user),F(`Commit author email`,t.bot_email),F(`Pickup label`,t.label),F(`Forge type`,t.forge_type),F(`Forge host`,t.forge_host),F(`Max diff size (lines)`,t.diff_cap_lines))):P(`Identity`,`Who Archie is on the forge.`,s(`Not available`))}function ie(t){return t?.length?P(`Repositories`,`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.`,e(`table.table`,e(`thead`,e(`tr`,...[`Repository`,`Base branch`,`Ecosystem`,`Quality gate`,`Protected paths`].map(t=>e(`th`,t)))),e(`tbody`,...t.map(t=>e(`tr`,e(`td.strong`,`${t.owner}/${t.name}`),e(`td.mono`,t.base),e(`td`,t.ecosystem||`go`),e(`td.mono`,I(t.gate)),e(`td.mono`,t.protect?.length?t.protect.join(`, `):`—`)))))):P(`Repositories`,`The repositories Archie polls for work.`,s(`No repositories configured`,`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`))}function I(e){return e?.length?e.map(e=>e.join(` `)).join(` → `):`—`}function L(t,n){let i=Object.entries(t||{}),a=Object.entries(n||{}),o=i.length?e(`div.cfg-rows`,...i.map(([e,t])=>F(R(e),t))):s(`No model roles configured`,`Assign a model to at least one role (e.g. "builder") in [models].`),c=a.length?e(`table.table`,e(`thead`,e(`tr`,...[`Provider`,`Class`,`Base URL`,`API key env var`,`Status`].map(t=>e(`th`,t)))),e(`tbody`,...a.map(([t,n])=>e(`tr`,e(`td.strong`,t),e(`td`,n.class),e(`td.mono`,n.base_url||`default`),e(`td.mono`,n.api_key_env||`—`),e(`td`,n.configured?r(`configured`,`ok`):r(`missing credentials`,`warn`)))))):s(`No providers configured`,`Add a [providers.] entry so a model role above has something to run on.`);return P(`Models & providers`,`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,e(`h3.cfg-subhead`,`Model roles`),o,e(`h3.cfg-subhead`,`Providers`),c)}function R(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function z(t){return t?P(`Budgets`,`The limits every autonomous stage runs under, so a stuck task cannot run forever.`,e(`div.cfg-rows`,F(`Max steps`,t.max_steps||`Unlimited`),F(`Max tokens`,t.max_tokens||`Unlimited`),F(`Wall clock`,t.wall_clock),F(`Max gate failures before parking`,t.gate_max_failures||`Unlimited`))):P(`Budgets`,`Limits on every agent stage.`,s(`Not available`))}function B(t){return t?P(`Agent execution`,`How archied actually runs a stage of work.`,e(`div.cfg-rows`,F(`Execution mode`,V(t.mode)),F(`Worker command`,t.command),F(`Extra environment variables passed through`,t.env?.length?t.env.join(`, `):`None`))):P(`Agent execution`,`How Archie runs autonomous stages.`,s(`Not available`))}function V(e){switch(e){case`inprocess`:return`In-process (same binary as the daemon)`;case`subprocess`:return`Subprocess (separate archie-agent process)`;case`nats`:return`NATS (dispatched to a worker over the message bus)`;default:return e||`Not set`}}function H(t,n){let r=[];return t&&r.push(e(`h3.cfg-subhead`,`Paths`),e(`div.cfg-rows`,F(`Work directory`,t.work_dir),F(`Task database`,t.db_path),F(`Shared skills directory`,t.skills_dir||`None (uses the work directory)`),F(`Daemon plugin directory`,t.plugin_dir||`None`),F(`Secret engine plugin directory`,t.secret_engine_dir||`None (built-in engines only)`))),n&&r.push(e(`h3.cfg-subhead`,`Sandboxed containers`),e(`div.cfg-rows`,F(`Sandboxing enabled`,n.enabled?`Yes`:`No`),F(`Agent image`,n.image||`Not set`),F(`Max concurrent tasks`,n.max_concurrency||`Unlimited`),F(`Container max lifetime`,n.max_uptime),F(`Persistent volume retention`,n.volume_ttl),F(`How images are refreshed`,U(n.pull_policy)),F(`Docker network`,n.network||`Auto-detected`))),r.length||r.push(s(`Not available`)),P(`Storage & sandboxing`,`Where archied keeps its state, and how it isolates task execution.`,...r)}function U(e){return e===`always`?`Always pull the latest image before running`:`Only pull when the image is missing locally`}function W(t){return t?P(`Dashboard`,`This dashboard's own listen address.`,e(`div.cfg-rows`,F(`Listen address`,t.listen===`off`?`Disabled`:t.listen))):P(`Dashboard`,`This dashboard's own listen address.`,s(`Not available`))}var G=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function K(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function q(){let t=e(`div`),i=e(`div.log-list`),a=r(`connecting`,`idle`),o=e(`span.log-meta`),c={level:``,component:``,q:``},l=!1,u=[],d=e(`select.log-select`,{onchange:e=>v({level:e.target.value})},...G.map(t=>e(`option`,{value:t.value},t.label))),f=e(`select.log-select`,{onchange:e=>v({component:e.target.value})}),h=e(`input.log-search`,{type:`search`,placeholder:`Search messages and fields…`,oninput:ce(e=>v({q:e.target.value}),250)}),g=e(`button.btn`,{onclick:y},`Pause`);b(),x();let _=m(e=>C(e),e=>{a.className=`pill pill-${e===`live`?`ok`:`warn`}`,a.textContent=e});t.addEventListener(`archie:teardown`,_);function v(e){c={...c,...e},x()}function y(){l=!l,g.textContent=l?`Resume`:`Pause`,g.classList.toggle(`btn-primary`,l)}function b(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Logs`),e(`p.page-sub`,`What Archie has been doing, newest last.`)),e(`div.page-actions`,g,e(`button.btn`,{onclick:x},`Refresh`))),e(`div.card`,e(`div.card-head`,e(`div.log-filters`,d,f,h),e(`div.log-status`,o,a)),i))}async function x(){n(i,e(`div.log-loading`,`Loading…`));try{let e=await p.logs({level:c.level,component:c.component,q:c.q,limit:500});if(e.disabled){n(i,s(`File logging is off`,`Set [log] file in your config to keep a durable record. Live lines below still stream while this page is open.`)),o.textContent=``;return}S(e.components||[]),o.textContent=e.truncated?`showing the most recent matches from ${e.file}`:e.file||``;let t=e.entries||[];if(!t.length){n(i,s(`Nothing matches`,`Try a wider level or clear the search.`));return}n(i,...t.map(J)),i.scrollTop=i.scrollHeight}catch(e){n(i,s(`Cannot read logs`,String(e.message||e)))}}function S(t){if(se(t,u))return;u=t;let r=c.component;n(f,e(`option`,{value:``},`All components`),...t.map(t=>e(`option`,{value:t},t))),f.value=r}function C(e){if(l)return;let t={time:e.at||new Date().toISOString(),level:e.level||`INFO`,msg:e.detail||e.message||e.kind||`event`,fields:e.task_id?{task:e.task_id}:null};if(!w(t))return;let n=i.scrollHeight-i.scrollTop-i.clientHeight<40;for(i.querySelector(`.empty, .log-loading`)&&i.replaceChildren(),i.append(J({...t,message:t.msg}));i.children.length>1e3;)i.firstElementChild.remove();n&&(i.scrollTop=i.scrollHeight)}function w(e){if(c.level&&!c.level.split(`,`).includes((e.level||``).toUpperCase())||c.component&&e.fields?.component!==c.component)return!1;if(c.q){let t=c.q.toLowerCase();if(!`${e.msg} ${JSON.stringify(e.fields||{})}`.toLowerCase().includes(t))return!1}return!0}return t}function J(t){let n=t.fields||{};return e(`div.log-row.log-${K(t.level)}`,e(`span.log-time.mono`,oe(t.time)),e(`span.log-level`,(t.level||`info`).toUpperCase()),e(`span.log-body`,e(`span.log-msg`,t.message||t.msg||``),...Object.entries(n).map(([t,n])=>e(`span.log-field`,e(`span.log-field-key`,t),String(ae(n))))))}function ae(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function oe(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function se(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function ce(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function le(){let t=e(`div`),r=e(`div`);i(),a();function i(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Memory`),e(`p.page-sub`,`What Archie can recall between conversations, and the tools it uses to do it.`)),e(`div.page-actions`,e(`button.btn`,{onclick:a},l(`refresh`,{size:15}),`Refresh`))),r)}async function a(){n(r,e(`div.card`,e(`div.mem-loading`,`Loading…`)));try{let t=await p.memory();if(!t.enabled||!t.providers?.length){n(r,e(`div.card`,s(`Memory is not configured`,`Without a provider, Archie starts every conversation with no recollection of earlier ones.`)));return}n(r,e(`div.grid.grid-2`,...t.providers.map(ue)))}catch(t){n(r,e(`div.card`,s(`Cannot read memory providers`,String(t.message||t))))}}return t}function ue(t){let n=t.tools||[];return e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,t.name||`provider`),e(`p.card-sub`,Y(t.role))),t.available?r(`ready`,`ok`):r(`unavailable`,`danger`)),!t.available&&e(`p.mem-warning`,`Configured but not usable right now — a required binary or connection may be missing.`),n.length?e(`ul.mem-tools`,...n.map(t=>e(`li.mem-tool`,e(`div.mem-tool-name.mono`,t.name),t.description&&e(`div.mem-tool-desc`,t.description)))):e(`p.mem-warning`,`This provider exposes no tools, so the agent cannot use it.`))}function Y(e){return e===`external`?`Added by you — an external store Archie was given`:`Built in — always available to Archie`}var X=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:y},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:D},{path:`/logs`,label:`Logs`,icon:`logs`,view:q},{path:`/skills`,label:`Skills`,icon:`skills`,view:O},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:te},{path:`/memory`,label:`Memory`,icon:`memory`,view:le},{path:`/channels`,label:`Channels`,icon:`channels`,view:N},{path:`/settings`,label:`Configuration`,icon:`settings`,view:ne}],Z=`archie.theme`;function Q(e){document.documentElement.dataset.theme=e,localStorage.setItem(Z,e)}function $(){return localStorage.getItem(Z)||`dark`}function de(t){let r=new Map,i=e(`nav.nav`,...[null].flatMap(()=>[...X.map(n=>{let i=e(`a.nav-item`,{href:`#${n.path}`,onclick:e=>{n.soon?e.preventDefault():t(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},l(n.icon),e(`span.nav-label`,n.label),n.soon&&e(`span.nav-soon`,`soon`));return r.set(n.path,i),i})])),a=e(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{Q($()===`dark`?`light`:`dark`),n(a,l($()===`dark`?`moon`:`sun`))}});n(a,l($()===`dark`?`moon`:`sun`));let o=e(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:e=>{if(e.key!==`Enter`)return;let n=e.target.value.trim().toLowerCase(),r=X.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(t(r.path),e.target.value=``,e.target.blur())}});return{node:e(`header.topbar`,e(`div.brand`,e(`span.brand-mark`,`A`),`Archie`),i,e(`div.topbar-end`,e(`div.topbar-search`,l(`search`,{size:15}),o),e(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},l(`help`)),a,e(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,n]of r)t===e?n.setAttribute(`aria-current`,`page`):n.removeAttribute(`aria-current`)}}}function fe(){Q($());let t=e(`main.main`),r=de(i);n(document.getElementById(`app`),e(`div.shell`,r.node,t));function i(e){location.hash===`#${e}`?a(e):location.hash=e}function a(e){t.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let i=X.find(t=>t.path===e)||X[0];r.highlight(i.path),n(t,i.view?i.view():pe(i))}window.addEventListener(`hashchange`,()=>a(location.hash.slice(1)||`/`)),a(location.hash.slice(1)||`/`)}function pe(t){return e(`div`,e(`div.page-head`,e(`div`,e(`h1.page-title`,t.label))),e(`div.card`,e(`div.empty`,e(`div.empty-title`,`${t.label} is not built yet`),e(`div`,`This section is next up. Nothing is broken.`))))}fe();
\ No newline at end of file
diff --git a/ui/dist/index.html b/ui/dist/index.html
new file mode 100644
index 000000000..3e634bdba
--- /dev/null
+++ b/ui/dist/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Archie
+
+
+
+
+
+
+
diff --git a/ui/embed.go b/ui/embed.go
new file mode 100644
index 000000000..6e6975af4
--- /dev/null
+++ b/ui/embed.go
@@ -0,0 +1,23 @@
+//go:build !no_ui
+
+// Package ui embeds archied's built dashboard. It carries no behaviour --
+// internal/webui owns serving and the HTTP API -- so that the frontend build
+// artefact stays a separate concern from the server that hands it out.
+//
+// dist/ is committed deliberately. Without it `go build`, `go install` and
+// the CI gate would each need a Node toolchain present merely to compile the
+// daemon, which is a poor trade for a project whose quality gate is
+// `task check`. Rebuild it with `task ui`.
+package ui
+
+import (
+ "embed"
+ "io/fs"
+)
+
+//go:embed all:dist
+var distDir embed.FS
+
+// DistDirFS is the built dashboard rooted at dist/, or nil when the binary
+// was built with the no_ui tag.
+var DistDirFS, _ = fs.Sub(distDir, "dist")
diff --git a/ui/embed_no_ui.go b/ui/embed_no_ui.go
new file mode 100644
index 000000000..baeea0273
--- /dev/null
+++ b/ui/embed_no_ui.go
@@ -0,0 +1,11 @@
+//go:build no_ui
+
+package ui
+
+import "io/fs"
+
+// DistDirFS is deliberately nil under the no_ui build tag so the dashboard is
+// not bundled. archie-agent has no use for it, and leaving it out keeps the
+// per-task container image smaller. internal/webui serves an explanatory page
+// rather than failing when this is nil.
+var DistDirFS fs.FS
diff --git a/ui/index.html b/ui/index.html
new file mode 100644
index 000000000..c5b79a9f9
--- /dev/null
+++ b/ui/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Archie
+
+
+
+
+
+
diff --git a/ui/package-lock.json b/ui/package-lock.json
new file mode 100644
index 000000000..473cd96c3
--- /dev/null
+++ b/ui/package-lock.json
@@ -0,0 +1,778 @@
+{
+ "name": "archie-dashboard",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "archie-dashboard",
+ "devDependencies": {
+ "vite": "^8.0.0"
+ }
+ },
+ "node_modules/@oxc-project/types": {
+ "version": "0.142.0",
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.142.0.tgz",
+ "integrity": "sha512-7W+2q5AKQVU36fkaryontrHn3YDt1RyUYXatw9i5H8ocYe2sPKSFB6eS8WNPeRKiN1qAWWZUPm7gwFzJGrccqQ==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/Boshen"
+ }
+ },
+ "node_modules/@rolldown/binding-android-arm64": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.2.tgz",
+ "integrity": "sha512-l7x215OGvo1s52JWmR8U/DAVzEDWBCIbTm28aeJV/WDTSHgcKXaZTuBT0hJMs5NggilfJTW3clZVvd24yfKJxA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-arm64": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.2.tgz",
+ "integrity": "sha512-9u9Xv6c1AJZT0FfwH5vrMG5Jjcwhc1MlyrPu0XfTqkzsmqfks2M6W/o5XwAJgVVN/jHpqqngC1WevHKKTIUtIA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-x64": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.2.tgz",
+ "integrity": "sha512-9W1mbGZAfW3oqd85bhBkmpyHCCzL1TeG/zFFP3vg7b0rlly8cxOcre5nXwz+LHazCwac2MNWgPdPCHndABjpWQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-freebsd-x64": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.2.tgz",
+ "integrity": "sha512-0p1lhiCSCyaerFwtrdZQUx7NqGk6LQnaRKWX7tFQqwQgvX0rjM15cIkm3pax1UpEakK14C4mOxx/jSqCBdBRqQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.2.tgz",
+ "integrity": "sha512-e+cOJXrJ2L3zx6YzqPg+f6Wbk3V1cKB8bOhbaYdVYN3DdquzNdRAmrbETz1qnt5yp/c7JNlNjmITiA2cVneQ7w==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-gnu": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.2.tgz",
+ "integrity": "sha512-JsSMsj6sNat/MuhG5fnBD7QgbtpHKVe30x5/bAVirDHdhoQRXJkF6xc0Jqk8O4fiCUQAzMOoH9wZi3m60c8wtg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-musl": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.2.tgz",
+ "integrity": "sha512-B5G/zJdHaoJn9vD50eGHWkiWfmq8Uhi3IiLPJTzmZTrAalk1bztUikSXo0qga18ibE0IXboyeMUnhPjhAJ45wQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.2.tgz",
+ "integrity": "sha512-6mC/awzKka8W6EoekjegpfGkjz8jXWDX63pqu/HYVpyKtZfu65Jsh4QAH3Kej3CAv/c1oGX7psTmFEbr0mDxLA==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-s390x-gnu": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.2.tgz",
+ "integrity": "sha512-412MX9fJLdA1IK28EZnc8jYv2HRTleOZgfLQumJ5zy7OeJLZlg/CETwFaXjNmGVxG51cFHpKLqb5LKvBC+HsHA==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-gnu": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.2.tgz",
+ "integrity": "sha512-Q/+HI/ToJafZ1iCqGgVQXUEkIjufHCTF0gBQ2a5o3cg7GJ2h0qyq3nvvSmU+bGda2/7ygXpTY4TM6gO9OhQ0ZA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-musl": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.2.tgz",
+ "integrity": "sha512-ZKp/w41n6wCvxzxQHtQSbuphfX3Y4cCvbjkKHusrLx4lh+JWLTU7StSltO/DKARISzbj368d+qUaCjI8K2wzXw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-openharmony-arm64": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.2.tgz",
+ "integrity": "sha512-pxE6xD4KS3eAROkKK5yrhB9/3+vhlhVGMvlQLbdpzrBGDbKrnzx3RLwPaHvasLo6jgaiBLn7e04Df9C4tYhjmA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-arm64-msvc": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.2.tgz",
+ "integrity": "sha512-4MqEue5re+xIZzAWsB8sj0P1kqZySWqIuN4t6QaIO/YA6SFwySOLruvWQFzfmqk8LBK2P30KCSJwf6mJCZZ5/A==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-x64-msvc": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.2.tgz",
+ "integrity": "sha512-NweNxxD0Nf9t8v7kodun45Ijp3EIwYY+uydPP6qBEYvfBqhIjN6dZMzlQja3tqX/aLs3F3Uz+AxDpKgRhpOZQg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/pluginutils": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/detect-libc": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/fdir": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "peerDependencies": {
+ "picomatch": "^3 || ^4"
+ },
+ "peerDependenciesMeta": {
+ "picomatch": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/lightningcss": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
+ "dev": true,
+ "license": "MPL-2.0",
+ "dependencies": {
+ "detect-libc": "^2.0.3"
+ },
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ },
+ "optionalDependencies": {
+ "lightningcss-android-arm64": "1.33.0",
+ "lightningcss-darwin-arm64": "1.33.0",
+ "lightningcss-darwin-x64": "1.33.0",
+ "lightningcss-freebsd-x64": "1.33.0",
+ "lightningcss-linux-arm-gnueabihf": "1.33.0",
+ "lightningcss-linux-arm64-gnu": "1.33.0",
+ "lightningcss-linux-arm64-musl": "1.33.0",
+ "lightningcss-linux-x64-gnu": "1.33.0",
+ "lightningcss-linux-x64-musl": "1.33.0",
+ "lightningcss-win32-arm64-msvc": "1.33.0",
+ "lightningcss-win32-x64-msvc": "1.33.0"
+ }
+ },
+ "node_modules/lightningcss-android-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-freebsd-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm-gnueabihf": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-arm64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-x64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/nanoid": {
+ "version": "3.3.17",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.17.tgz",
+ "integrity": "sha512-xQLf0A3HOMlgHq0n247/LRuAOYmB7dXJ/DvAxGvsSBij45XtBSmQycu+F8ODbHwns/XyFZagyL1+J0Offw1E0g==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
+ "node_modules/picocolors": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/picomatch": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/postcss": {
+ "version": "8.5.25",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.25.tgz",
+ "integrity": "sha512-DTPx3RWSSnWyzLxQnlH0rJP+EW5ekl16ZU4/psbIhA0e53kJfdgaN5vKM+xP7yJtXVu+nfdVFmlgFDEKAe4Pyw==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/postcss"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "nanoid": "^3.3.16",
+ "picocolors": "^1.1.1",
+ "source-map-js": "^1.2.1"
+ },
+ "engines": {
+ "node": "^10 || ^12 || >=14"
+ }
+ },
+ "node_modules/rolldown": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.2.tgz",
+ "integrity": "sha512-opwpo1tQBAcpSUJDt94B7hhLNGOKjCdE//XXjeLrnx9b83bjnw45tXdg1b09yEw/VLFBJGZpwRULMmOZo7ol+A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@oxc-project/types": "=0.142.0",
+ "@rolldown/pluginutils": "^1.0.0"
+ },
+ "bin": {
+ "rolldown": "bin/cli.mjs"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "optionalDependencies": {
+ "@rolldown/binding-android-arm64": "1.2.2",
+ "@rolldown/binding-darwin-arm64": "1.2.2",
+ "@rolldown/binding-darwin-x64": "1.2.2",
+ "@rolldown/binding-freebsd-x64": "1.2.2",
+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.2",
+ "@rolldown/binding-linux-arm64-gnu": "1.2.2",
+ "@rolldown/binding-linux-arm64-musl": "1.2.2",
+ "@rolldown/binding-linux-ppc64-gnu": "1.2.2",
+ "@rolldown/binding-linux-s390x-gnu": "1.2.2",
+ "@rolldown/binding-linux-x64-gnu": "1.2.2",
+ "@rolldown/binding-linux-x64-musl": "1.2.2",
+ "@rolldown/binding-openharmony-arm64": "1.2.2",
+ "@rolldown/binding-win32-arm64-msvc": "1.2.2",
+ "@rolldown/binding-win32-x64-msvc": "1.2.2"
+ }
+ },
+ "node_modules/source-map-js": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/tinyglobby": {
+ "version": "0.2.17",
+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fdir": "^6.5.0",
+ "picomatch": "^4.0.4"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/SuperchupuDev"
+ }
+ },
+ "node_modules/vite": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.0.tgz",
+ "integrity": "sha512-pn+CFpM0lwDeKwmOq1ZaBK/9sjorZcgqxki6MbY/jPEVd9vichIlmlD4HmQ5wdP5EgqQCFRaACBxMC7uEGc6lQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lightningcss": "^1.33.0",
+ "picomatch": "^4.0.5",
+ "postcss": "^8.5.23",
+ "rolldown": "~1.2.0",
+ "tinyglobby": "^0.2.17"
+ },
+ "bin": {
+ "vite": "bin/vite.js"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "funding": {
+ "url": "https://github.com/vitejs/vite?sponsor=1"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.3"
+ },
+ "peerDependencies": {
+ "@types/node": "^20.19.0 || >=22.12.0",
+ "@vitejs/devtools": "^0.4.0",
+ "esbuild": "^0.27.0 || ^0.28.0",
+ "jiti": ">=1.21.0",
+ "less": "^4.0.0",
+ "sass": "^1.70.0",
+ "sass-embedded": "^1.70.0",
+ "stylus": ">=0.54.8",
+ "sugarss": "^5.0.0",
+ "terser": "^5.16.0",
+ "tsx": "^4.8.1",
+ "yaml": "^2.4.2"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ },
+ "@vitejs/devtools": {
+ "optional": true
+ },
+ "esbuild": {
+ "optional": true
+ },
+ "jiti": {
+ "optional": true
+ },
+ "less": {
+ "optional": true
+ },
+ "sass": {
+ "optional": true
+ },
+ "sass-embedded": {
+ "optional": true
+ },
+ "stylus": {
+ "optional": true
+ },
+ "sugarss": {
+ "optional": true
+ },
+ "terser": {
+ "optional": true
+ },
+ "tsx": {
+ "optional": true
+ },
+ "yaml": {
+ "optional": true
+ }
+ }
+ }
+ }
+}
diff --git a/ui/package.json b/ui/package.json
new file mode 100644
index 000000000..fce9648ea
--- /dev/null
+++ b/ui/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "archie-dashboard",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build"
+ },
+ "devDependencies": {
+ "vite": "^8.0.0"
+ }
+}
diff --git a/ui/src/base/api.js b/ui/src/base/api.js
new file mode 100644
index 000000000..284a33174
--- /dev/null
+++ b/ui/src/base/api.js
@@ -0,0 +1,63 @@
+// Single place that knows how to talk to archied. Every feature folder goes
+// through this, so auth handling and error shape live in one file.
+
+async function req(path) {
+ const res = await fetch(path, { headers: { Accept: "application/json" } });
+ if (res.status === 401) {
+ throw new ApiError("unauthorised", 401);
+ }
+ if (!res.ok) {
+ throw new ApiError(`${res.status} ${res.statusText}`, res.status);
+ }
+ return res.json();
+}
+
+// qs builds a query string, omitting empty values so the server sees an
+// absent filter rather than an empty one.
+function qs(params) {
+ const q = new URLSearchParams();
+ for (const [k, v] of Object.entries(params || {})) {
+ if (v !== "" && v != null) q.set(k, v);
+ }
+ const s = q.toString();
+ return s ? `?${s}` : "";
+}
+
+export class ApiError extends Error {
+ constructor(message, status) {
+ super(message);
+ this.status = status;
+ }
+}
+
+export const api = {
+ summary: () => req("/api/summary"),
+ tasks: () => req("/api/tasks"),
+ task: (id) => req(`/api/tasks/${id}`),
+ setup: () => req("/api/setup"),
+ workflows: () => req("/api/workflows"),
+ skills: () => req("/api/skills"),
+ channels: () => req("/api/channels"),
+ config: () => req("/api/config"),
+ logs: (params) => req("/api/logs" + qs(params)),
+ memory: () => req("/api/memory"),
+};
+
+/**
+ * Subscribe to archied's event stream. Returns an unsubscribe function.
+ * Reconnection is the browser's job via EventSource, but a closed stream is
+ * surfaced to the caller so the UI can show it rather than silently freezing.
+ */
+export function subscribeEvents(onEvent, onStateChange) {
+ const src = new EventSource("/events");
+ src.onopen = () => onStateChange?.("live");
+ src.onerror = () => onStateChange?.("reconnecting");
+ src.onmessage = (e) => {
+ try {
+ onEvent(JSON.parse(e.data));
+ } catch {
+ /* a malformed frame should not kill the stream */
+ }
+ };
+ return () => src.close();
+}
diff --git a/ui/src/base/dom.js b/ui/src/base/dom.js
new file mode 100644
index 000000000..79c47b0fc
--- /dev/null
+++ b/ui/src/base/dom.js
@@ -0,0 +1,103 @@
+// Tiny DOM helpers. Deliberately not a framework: the dashboard is a handful
+// of pages over a read-mostly API, and a build-free vanilla layer keeps the
+// embedded bundle small.
+
+/**
+ * el("div.card", {onclick}, child, child) -> HTMLElement
+ * The tag string accepts CSS-ish shorthand: "button.btn.btn-primary".
+ */
+export function el(spec, attrs, ...children) {
+ const [tag, ...classes] = spec.split(".");
+ const node = document.createElement(tag || "div");
+ if (classes.length) node.className = classes.join(" ");
+
+ if (attrs && (typeof attrs !== "object" || attrs instanceof Node)) {
+ children.unshift(attrs);
+ attrs = null;
+ }
+ for (const [k, v] of Object.entries(attrs || {})) {
+ if (v == null || v === false) continue;
+ if (k.startsWith("on") && typeof v === "function") {
+ node.addEventListener(k.slice(2).toLowerCase(), v);
+ } else if (k === "class") {
+ node.className = [node.className, v].filter(Boolean).join(" ");
+ } else if (k === "html") {
+ node.innerHTML = v;
+ } else {
+ node.setAttribute(k, v === true ? "" : String(v));
+ }
+ }
+ append(node, children);
+ return node;
+}
+
+function append(node, children) {
+ for (const c of children.flat(Infinity)) {
+ if (c == null || c === false) continue;
+ node.append(c instanceof Node ? c : document.createTextNode(String(c)));
+ }
+}
+
+export function mount(parent, ...children) {
+ parent.replaceChildren();
+ append(parent, children);
+ return parent;
+}
+
+/** Status pill. Kind maps to the semantic colour tokens. */
+export function pill(text, kind = "idle") {
+ return el(`span.pill.pill-${kind}`, text);
+}
+
+/**
+ * Map an archie task status onto a pill kind. Centralised so "merged" is the
+ * same green everywhere it appears.
+ */
+export function statusKind(status) {
+ switch (status) {
+ case "running":
+ return "info";
+ case "merged":
+ case "pr_open":
+ return "ok";
+ case "parked":
+ case "waiting_human":
+ return "warn";
+ case "dead":
+ case "rejected":
+ return "danger";
+ default:
+ return "idle";
+ }
+}
+
+/** Humanised relative time: "2 min ago". Raw timestamps make people do maths. */
+export function ago(value) {
+ if (!value) return "—";
+ const then = value instanceof Date ? value : new Date(value);
+ const secs = Math.floor((Date.now() - then.getTime()) / 1000);
+ if (!Number.isFinite(secs)) return "—";
+ if (secs < 45) return "just now";
+ const units = [
+ ["min", 60],
+ ["hr", 3600],
+ ["day", 86400],
+ ["wk", 604800],
+ ];
+ let label = "min", size = 60;
+ for (const [l, s] of units) {
+ if (secs >= s) [label, size] = [l, s];
+ }
+ const n = Math.floor(secs / size);
+ return `${n} ${label}${n === 1 ? "" : "s"} ago`;
+}
+
+/** Compact number: 2_400_000 -> "2.4M". Long digit strings do not scan. */
+export function compact(n) {
+ if (n == null || Number.isNaN(n)) return "—";
+ return new Intl.NumberFormat(undefined, { notation: "compact", maximumFractionDigits: 1 }).format(n);
+}
+
+export function empty(title, detail) {
+ return el("div.empty", el("div.empty-title", title), detail && el("div", detail));
+}
diff --git a/ui/src/base/gauge.js b/ui/src/base/gauge.js
new file mode 100644
index 000000000..9ff739989
--- /dev/null
+++ b/ui/src/base/gauge.js
@@ -0,0 +1,89 @@
+import { el } from "./dom.js";
+
+/**
+ * Arc gauge for a single headline percentage.
+ *
+ * A percentage that decides whether you need to act deserves more than a line
+ * of text -- the arc is readable at a glance from across a room, which a
+ * number is not. Colour follows the value, so "is this bad" is answered before
+ * the digits are read.
+ */
+export function gauge({ value, label, size = 168 }) {
+ const pct = Math.max(0, Math.min(100, Number(value) || 0));
+ const stroke = pct >= 90 ? "var(--ok)" : pct >= 70 ? "var(--warn)" : "var(--danger)";
+
+ // 240-degree arc, opening downward, so the value reads left-to-right.
+ const r = 62;
+ const cx = size / 2;
+ const cy = size / 2;
+ const sweep = 240;
+ const start = 150;
+ const circumference = 2 * Math.PI * r * (sweep / 360);
+
+ const arc = (from, deg) => {
+ const a0 = (from * Math.PI) / 180;
+ const a1 = ((from + deg) * Math.PI) / 180;
+ const large = deg > 180 ? 1 : 0;
+ return [
+ `M ${cx + r * Math.cos(a0)} ${cy + r * Math.sin(a0)}`,
+ `A ${r} ${r} 0 ${large} 1 ${cx + r * Math.cos(a1)} ${cy + r * Math.sin(a1)}`,
+ ].join(" ");
+ };
+
+ const svg = el("svg.gauge", {
+ viewBox: `0 0 ${size} ${size * 0.78}`,
+ role: "img",
+ "aria-label": `${label}: ${pct}%`,
+ });
+ svg.innerHTML = `
+
+ `;
+
+ return el(
+ "div.gauge-wrap",
+ svg,
+ el("div.gauge-center", el("div.gauge-pct", `${Math.round(pct)}%`), el("div.gauge-label", label)),
+ );
+}
+
+/**
+ * Segmented proportional bar with a legend.
+ *
+ * segments: [{ label, value, kind }] where kind maps to a status token.
+ * Used for budget composition -- what is spent, committed and still free --
+ * because three related quantities are easier to compare in one bar than in
+ * three separate numbers.
+ */
+export function segmentBar(segments) {
+ const total = segments.reduce((a, s) => a + (s.value || 0), 0) || 1;
+ return el(
+ "div",
+ el(
+ "div.segbar",
+ ...segments
+ .filter((s) => s.value > 0)
+ .map((s) =>
+ el("span", {
+ class: `segbar-part segbar-${s.kind || "idle"}`,
+ style: `width:${((s.value / total) * 100).toFixed(1)}%`,
+ title: `${s.label}: ${s.value}`,
+ }),
+ ),
+ ),
+ el(
+ "div.segbar-legend",
+ ...segments.map((s) =>
+ el(
+ "span.segbar-key",
+ el("span", { class: `segbar-dot segbar-${s.kind || "idle"}` }),
+ s.label,
+ ),
+ ),
+ ),
+ );
+}
diff --git a/ui/src/base/icons.js b/ui/src/base/icons.js
new file mode 100644
index 000000000..261e6e8d2
--- /dev/null
+++ b/ui/src/base/icons.js
@@ -0,0 +1,48 @@
+/**
+ * Icon set.
+ *
+ * A single stroked 24-grid system rather than Unicode glyphs: glyphs render at
+ * different weights and baselines per platform, cannot inherit stroke width,
+ * and have no consistent optical size. Every icon here shares the same grid,
+ * stroke and cap style, so a row of them lines up.
+ */
+
+const paths = {
+ dashboard: ' ',
+ tasks: ' ',
+ logs: ' ',
+ skills: ' ',
+ workflows: ' ',
+ memory: ' ',
+ channels: ' ',
+ settings: ' ',
+ search: ' ',
+ moon: ' ',
+ sun: ' ',
+ refresh: ' ',
+ bell: ' ',
+ trendUp: ' ',
+ trendDown: ' ',
+ check: ' ',
+ help: ' ',
+};
+
+/**
+ * icon("tasks") -> SVGElement. size is the rendered box; the grid is always 24
+ * so stroke weight stays optically consistent at any size.
+ */
+export function icon(name, { size = 18, className = "" } = {}) {
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ svg.setAttribute("viewBox", "0 0 24 24");
+ svg.setAttribute("width", String(size));
+ svg.setAttribute("height", String(size));
+ svg.setAttribute("fill", "none");
+ svg.setAttribute("stroke", "currentColor");
+ svg.setAttribute("stroke-width", "1.6");
+ svg.setAttribute("stroke-linecap", "round");
+ svg.setAttribute("stroke-linejoin", "round");
+ svg.setAttribute("aria-hidden", "true");
+ svg.setAttribute("class", `ico ${className}`.trim());
+ svg.innerHTML = paths[name] || paths.dashboard;
+ return svg;
+}
diff --git a/ui/src/base/statTile.js b/ui/src/base/statTile.js
new file mode 100644
index 000000000..7f7a60c61
--- /dev/null
+++ b/ui/src/base/statTile.js
@@ -0,0 +1,57 @@
+import { el } from "./dom.js";
+import { icon } from "./icons.js";
+
+/**
+ * A KPI tile: label, big value, trend against a stated comparison window, and
+ * a sparkline. The comparison line is not decoration -- a number without a
+ * baseline cannot be acted on, so `compare` is required.
+ *
+ * trend > 0 renders as an increase. `goodDirection` says whether that is good,
+ * because rising latency and rising success rate are not the same news.
+ */
+export function statTile({ label, value, unit, trend, compare, series = [], goodDirection = "up" }) {
+ const dir = trend == null ? null : trend >= 0 ? "up" : "down";
+ const good = dir == null ? null : dir === goodDirection;
+
+ return el(
+ "div.card.stat",
+ el(
+ "div.stat-head",
+ el("span.stat-label", label),
+ dir &&
+ el(
+ `span.stat-trend.${good ? "up" : "down"}`,
+ icon(dir === "up" ? "trendUp" : "trendDown", { size: 13 }),
+ `${Math.abs(trend).toFixed(1)}%`,
+ ),
+ ),
+ el("div.stat-value", value, unit && el("span.stat-unit", unit)),
+ compare && el("div.stat-compare", compare),
+ series.length > 1 && sparkline(series, good === false ? "var(--danger)" : "var(--ok)"),
+ );
+}
+
+/**
+ * Inline SVG sparkline. Shows shape, not exact values -- the tile's headline
+ * number carries the precision.
+ */
+export function sparkline(series, stroke = "var(--ok)", { width = 220, height = 34 } = {}) {
+ const max = Math.max(...series, 1);
+ const min = Math.min(...series, 0);
+ const span = max - min || 1;
+ const step = series.length > 1 ? width / (series.length - 1) : width;
+
+ const points = series
+ .map((v, i) => `${(i * step).toFixed(1)},${(height - ((v - min) / span) * height).toFixed(1)}`)
+ .join(" ");
+
+ const svg = el("svg.spark", {
+ viewBox: `0 0 ${width} ${height}`,
+ preserveAspectRatio: "none",
+ "aria-hidden": "true",
+ });
+ svg.innerHTML =
+ ` `;
+ return svg;
+}
diff --git a/ui/src/channels/channels.css b/ui/src/channels/channels.css
new file mode 100644
index 000000000..67c1a50d0
--- /dev/null
+++ b/ui/src/channels/channels.css
@@ -0,0 +1,19 @@
+/* Channels-only styles. */
+
+.channel-card {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-1);
+}
+
+.channel-desc {
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+ margin: 0;
+}
+
+.channel-detail {
+ color: var(--fg-subtle);
+ font-size: var(--text-xs);
+ margin: 0;
+}
diff --git a/ui/src/channels/channels.js b/ui/src/channels/channels.js
new file mode 100644
index 000000000..f60529bee
--- /dev/null
+++ b/ui/src/channels/channels.js
@@ -0,0 +1,72 @@
+import "./channels.css";
+import { api } from "../base/api.js";
+import { el, empty, mount, pill } from "../base/dom.js";
+
+/**
+ * How you reach Archie. Backed by GET /api/channels, which derives from
+ * [chat] in config.toml -- see internal/webui/api_config.go's
+ * handleChannels. Each channel is a card with a connected/not-configured
+ * pill and one line explaining what turning it on gets you, because
+ * "token_env unset" means nothing to someone who hasn't read config.toml.
+ */
+export function channelsPage() {
+ const root = el("div");
+ const cardGrid = el("div.grid.grid-2");
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Channels"),
+ el("p.page-sub", "The conversational front-ends Archie can be reached through."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ cardGrid,
+ );
+ }
+
+ async function load() {
+ try {
+ const res = await api.channels();
+ renderCards(res?.channels || []);
+ } catch (err) {
+ mount(cardGrid, empty("Cannot reach archied", String(err.message || err)));
+ }
+ }
+
+ function renderCards(channels) {
+ if (!channels.length) {
+ mount(
+ cardGrid,
+ empty(
+ "No channels configured",
+ "Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.",
+ ),
+ );
+ return;
+ }
+ mount(cardGrid, ...channels.map(channelCard));
+ }
+
+ function channelCard(channel) {
+ return el(
+ "div.card.channel-card",
+ el(
+ "div.card-head",
+ el("h3.card-title", channel.name),
+ channel.configured ? pill("connected", "ok") : pill("not configured", "idle"),
+ ),
+ el("p.channel-desc", channel.description),
+ el("p.channel-detail", channel.detail),
+ );
+ }
+
+ return root;
+}
diff --git a/ui/src/css/_main.css b/ui/src/css/_main.css
new file mode 100644
index 000000000..3cc8071b6
--- /dev/null
+++ b/ui/src/css/_main.css
@@ -0,0 +1,17 @@
+/*
+ * Style entry point. One file per concern, imported here in cascade order:
+ * tokens first (everything depends on them), then element defaults, then
+ * layout, then components. Feature folders own their own CSS and import it
+ * from their JS rather than adding to this list.
+ */
+
+@import "./tokens.css";
+@import "./base.css";
+@import "./layout.css";
+@import "./page.css";
+@import "./button.css";
+@import "./card.css";
+@import "./pill.css";
+@import "./table.css";
+@import "./empty.css";
+@import "./responsive.css";
diff --git a/ui/src/css/base.css b/ui/src/css/base.css
new file mode 100644
index 000000000..9ab5215b1
--- /dev/null
+++ b/ui/src/css/base.css
@@ -0,0 +1,32 @@
+/* Element defaults. Nothing here is component-specific. */
+
+/*
+ * App shell and shared primitives. Feature folders style their own specifics;
+ * anything that appears on more than one page lives here so pages cannot
+ * drift into three visual languages.
+ */
+
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+}
+
+html,
+body {
+ margin: 0;
+ height: 100%;
+}
+
+body {
+ color: var(--fg);
+ font-family: var(--font-sans);
+ font-size: var(--text-base);
+ line-height: 1.5;
+ -webkit-font-smoothing: antialiased;
+}
+
+a {
+ color: inherit;
+ text-decoration: none;
+}
diff --git a/ui/src/css/button.css b/ui/src/css/button.css
new file mode 100644
index 000000000..8aa0c554d
--- /dev/null
+++ b/ui/src/css/button.css
@@ -0,0 +1,37 @@
+/* Buttons. One shape, three weights. */
+
+.btn {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-2);
+ padding: var(--sp-2) var(--sp-4);
+ border-radius: var(--radius-pill);
+ border: 1px solid var(--border-strong);
+ background: var(--surface);
+ color: var(--fg);
+ font: inherit;
+ font-size: var(--text-sm);
+ cursor: pointer;
+ transition: background var(--transition), border-color var(--transition);
+}
+
+.btn:hover {
+ background: var(--surface-hover);
+}
+
+.btn-primary {
+ background: var(--accent);
+ border-color: var(--accent);
+ color: var(--accent-fg);
+ font-weight: 500;
+}
+
+.btn-primary:hover {
+ filter: brightness(1.08);
+ background: var(--accent);
+}
+
+.btn-icon {
+ padding: var(--sp-2);
+ border-radius: var(--radius-sm);
+}
diff --git a/ui/src/css/card.css b/ui/src/css/card.css
new file mode 100644
index 000000000..8a6e8de46
--- /dev/null
+++ b/ui/src/css/card.css
@@ -0,0 +1,43 @@
+/* Cards and the grids that arrange them. */
+
+.card {
+ background: var(--surface-glass);
+ backdrop-filter: blur(14px);
+ border: 1px solid var(--hairline);
+ border-radius: var(--radius-lg);
+ padding: var(--sp-5);
+ box-shadow: var(--shadow-sm);
+}
+
+.card-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-3);
+ margin-bottom: var(--sp-4);
+}
+
+.card-title {
+ font-size: var(--text-base);
+ font-weight: 600;
+ margin: 0;
+}
+
+.card-sub {
+ font-size: var(--text-xs);
+ color: var(--fg-muted);
+ margin: var(--sp-1) 0 0;
+}
+
+.grid {
+ display: grid;
+ gap: var(--sp-4);
+}
+
+.grid-4 {
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+}
+
+.grid-2 {
+ grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
+}
diff --git a/ui/src/css/empty.css b/ui/src/css/empty.css
new file mode 100644
index 000000000..ec3e01ddb
--- /dev/null
+++ b/ui/src/css/empty.css
@@ -0,0 +1,26 @@
+/* Empty and loading states. */
+
+.empty {
+ text-align: center;
+ padding: var(--sp-7) var(--sp-4);
+ color: var(--fg-muted);
+}
+
+.empty-title {
+ color: var(--fg);
+ font-weight: 500;
+ margin-bottom: var(--sp-1);
+}
+
+.skeleton {
+ background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
+ background-size: 200% 100%;
+ animation: shimmer 1.4s infinite;
+ border-radius: var(--radius-sm);
+}
+
+@keyframes shimmer {
+ to {
+ background-position: -200% 0;
+ }
+}
diff --git a/ui/src/css/layout.css b/ui/src/css/layout.css
new file mode 100644
index 000000000..e3f8cf52b
--- /dev/null
+++ b/ui/src/css/layout.css
@@ -0,0 +1,242 @@
+/* The shell: one contained, rounded application surface floating on a lit
+ * canvas.
+ *
+ * The dashboard is a *workspace*, not a document that fills the viewport --
+ * framing it gives the panels an edge to sit against, and lets the canvas
+ * behind read as light rather than wallpaper. Everything inside is translucent
+ * so that light carries through instead of stopping at the first opaque card.
+ */
+
+body {
+ /* The luminous canvas. Large, off-axis and low-frequency, so it lights the
+ workspace rather than competing with it. */
+ background:
+ radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%),
+ radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%),
+ radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%),
+ var(--bg);
+ background-attachment: fixed;
+ padding: var(--sp-4);
+}
+
+.shell {
+ min-height: calc(100vh - var(--sp-4) * 2);
+ display: flex;
+ flex-direction: column;
+ border-radius: var(--radius-xl);
+ border: 1px solid var(--hairline);
+ background: var(--workspace);
+ backdrop-filter: blur(28px) saturate(120%);
+ box-shadow: var(--shadow-workspace);
+ overflow: hidden;
+}
+
+/* ── Command bar ────────────────────────────────────────────────────────── */
+
+.topbar {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-4);
+ padding: var(--sp-3) var(--sp-4);
+ border-bottom: 1px solid var(--hairline);
+ background: var(--bg-blur);
+ position: sticky;
+ top: 0;
+ z-index: 10;
+}
+
+.brand {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-2);
+ font-weight: 600;
+ font-size: var(--text-sm);
+ letter-spacing: -0.01em;
+ flex: none;
+}
+
+.brand-mark {
+ width: 26px;
+ height: 26px;
+ border-radius: 8px;
+ background: linear-gradient(135deg, var(--accent), var(--accent-2));
+ display: grid;
+ place-items: center;
+ color: #fff;
+ font-size: var(--text-xs);
+ font-weight: 700;
+}
+
+/* Compact icon navigation: one pill, icons only, label on the active item. */
+.nav {
+ display: flex;
+ align-items: center;
+ gap: 2px;
+ margin: 0 auto;
+ padding: 3px;
+ border-radius: var(--radius-pill);
+ background: var(--surface-glass-strong);
+ border: 1px solid var(--hairline);
+}
+
+.nav-item {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-2);
+ padding: var(--sp-2) var(--sp-3);
+ border-radius: var(--radius-pill);
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+ white-space: nowrap;
+ cursor: pointer;
+ transition: background var(--transition), color var(--transition);
+}
+
+.nav-item:hover {
+ color: var(--fg);
+ background: var(--surface-hover);
+}
+
+.nav-item[aria-current="page"] {
+ background: var(--accent);
+ color: var(--accent-fg);
+ font-weight: 500;
+ padding-right: var(--sp-4);
+}
+
+.nav-item .nav-label {
+ display: none;
+}
+
+.nav-item[aria-current="page"] .nav-label {
+ display: inline;
+}
+
+/* ── Utility cluster ────────────────────────────────────────────────────── */
+
+.topbar-end {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-2);
+ flex: none;
+}
+
+.topbar-search {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-2);
+ padding: var(--sp-2) var(--sp-3);
+ border-radius: var(--radius-pill);
+ background: var(--surface-glass-strong);
+ border: 1px solid var(--hairline);
+ color: var(--fg-subtle);
+}
+
+.topbar-search input {
+ background: none;
+ border: 0;
+ color: var(--fg);
+ font: inherit;
+ font-size: var(--text-sm);
+ width: 8rem;
+ outline: none;
+}
+
+.topbar-search input::placeholder {
+ color: var(--fg-subtle);
+}
+
+.icon-btn {
+ display: grid;
+ place-items: center;
+ width: 32px;
+ height: 32px;
+ border-radius: var(--radius-pill);
+ border: 1px solid var(--hairline);
+ background: var(--surface-glass-strong);
+ color: var(--fg-muted);
+ cursor: pointer;
+ transition: color var(--transition), background var(--transition);
+}
+
+.icon-btn:hover {
+ color: var(--fg);
+ background: var(--surface-hover);
+}
+
+.avatar {
+ width: 32px;
+ height: 32px;
+ border-radius: var(--radius-pill);
+ display: grid;
+ place-items: center;
+ font-size: var(--text-xs);
+ font-weight: 600;
+ color: #fff;
+ background: linear-gradient(135deg, var(--accent), var(--accent-2));
+ cursor: pointer;
+ flex: none;
+}
+
+.ico {
+ flex: none;
+ display: block;
+}
+
+/* ── Canvas ─────────────────────────────────────────────────────────────── */
+
+.main {
+ padding: var(--sp-6);
+ width: 100%;
+ flex: 1;
+ overflow-x: hidden;
+}
+
+/* ── Narrow screens ─────────────────────────────────────────────────────── */
+
+/* The frame is a desktop affordance. Below the breakpoint the workspace goes
+ edge to edge -- a rounded card inset on a phone wastes the only axis that
+ matters -- and the icon bar becomes a scrollable labelled row. */
+@media (max-width: 900px) {
+ body {
+ padding: 0;
+ }
+
+ .shell {
+ min-height: 100vh;
+ border-radius: 0;
+ border: 0;
+ box-shadow: none;
+ }
+
+ .topbar {
+ flex-wrap: wrap;
+ padding: var(--sp-3);
+ gap: var(--sp-2);
+ }
+
+ .nav {
+ order: 3;
+ width: 100%;
+ overflow-x: auto;
+ justify-content: flex-start;
+ border-radius: var(--radius-lg);
+ scrollbar-width: none;
+ }
+
+ .nav::-webkit-scrollbar {
+ display: none;
+ }
+
+ .nav-item .nav-label {
+ display: inline;
+ }
+
+ .topbar-search {
+ display: none;
+ }
+
+ .main {
+ padding: var(--sp-4);
+ }
+}
diff --git a/ui/src/css/page.css b/ui/src/css/page.css
new file mode 100644
index 000000000..b3042c417
--- /dev/null
+++ b/ui/src/css/page.css
@@ -0,0 +1,29 @@
+/* Page header: title, subtitle and the actions that belong to a page. */
+
+.page-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: var(--sp-5);
+ margin-bottom: var(--sp-6);
+ flex-wrap: wrap;
+}
+
+.page-title {
+ font-size: var(--text-2xl);
+ font-weight: 600;
+ letter-spacing: -0.02em;
+ margin: 0;
+}
+
+.page-sub {
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+ margin: var(--sp-1) 0 0;
+}
+
+.page-actions {
+ display: flex;
+ gap: var(--sp-2);
+ align-items: center;
+}
diff --git a/ui/src/css/pill.css b/ui/src/css/pill.css
new file mode 100644
index 000000000..5ab7ab979
--- /dev/null
+++ b/ui/src/css/pill.css
@@ -0,0 +1,43 @@
+/* Status pills. The only place status colour is decided. */
+
+/* Status is always a pill, never bare text: a colour and a shape are read at
+ a glance where a word has to be parsed. */
+.pill {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-1);
+ padding: 2px var(--sp-2);
+ border-radius: var(--radius-pill);
+ font-size: var(--text-xs);
+ font-weight: 500;
+ white-space: nowrap;
+}
+
+.pill::before {
+ content: "";
+ width: 5px;
+ height: 5px;
+ border-radius: 50%;
+ background: currentColor;
+}
+
+.pill-ok {
+ color: var(--ok);
+ background: var(--ok-soft);
+}
+.pill-warn {
+ color: var(--warn);
+ background: var(--warn-soft);
+}
+.pill-danger {
+ color: var(--danger);
+ background: var(--danger-soft);
+}
+.pill-info {
+ color: var(--info);
+ background: var(--info-soft);
+}
+.pill-idle {
+ color: var(--idle);
+ background: var(--idle-soft);
+}
diff --git a/ui/src/css/responsive.css b/ui/src/css/responsive.css
new file mode 100644
index 000000000..20ccf8933
--- /dev/null
+++ b/ui/src/css/responsive.css
@@ -0,0 +1,30 @@
+/* Motion preferences and narrow viewports. */
+
+@media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ animation-duration: 0.01ms !important;
+ transition-duration: 0.01ms !important;
+ }
+}
+
+
+.nav-soon {
+ margin-left: auto;
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ background: var(--surface-hover);
+ padding: 1px var(--sp-2);
+ border-radius: var(--radius-pill);
+}
+
+.nav-item[aria-disabled] {
+ opacity: 0.55;
+ cursor: default;
+}
+
+.nav-item[aria-disabled]:hover {
+ background: none;
+ color: var(--fg-muted);
+}
diff --git a/ui/src/css/table.css b/ui/src/css/table.css
new file mode 100644
index 000000000..e5c6c35ef
--- /dev/null
+++ b/ui/src/css/table.css
@@ -0,0 +1,42 @@
+/* Data tables. */
+
+.table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: var(--text-sm);
+}
+
+.table th {
+ text-align: left;
+ font-weight: 500;
+ font-size: var(--text-xs);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--fg-subtle);
+ padding: 0 var(--sp-3) var(--sp-3);
+ border-bottom: 1px solid var(--border);
+}
+
+.table td {
+ padding: var(--sp-3);
+ border-bottom: 1px solid var(--border);
+ color: var(--fg-muted);
+}
+
+.table tbody tr:last-child td {
+ border-bottom: 0;
+}
+
+.table tbody tr:hover td {
+ background: var(--surface-hover);
+}
+
+.table td.strong {
+ color: var(--fg);
+ font-weight: 500;
+}
+
+.mono {
+ font-family: var(--font-mono);
+ font-size: 0.95em;
+}
diff --git a/ui/src/css/tokens.css b/ui/src/css/tokens.css
new file mode 100644
index 000000000..0939dad8d
--- /dev/null
+++ b/ui/src/css/tokens.css
@@ -0,0 +1,130 @@
+/*
+ * Design tokens. Dark is the default because archied is a daemon you check at
+ * odd hours; light is a toggle, not an afterthought, so both themes define the
+ * same variable set and nothing else in the app references a raw colour.
+ *
+ * Semantic names only. Never `--blue`; always `--accent` or `--status-running`,
+ * so a palette change is one file rather than a grep.
+ */
+
+:root {
+ /* Type */
+ --font-sans:
+ ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
+ --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
+
+ --text-xs: 0.6875rem;
+ --text-sm: 0.8125rem;
+ --text-base: 0.875rem;
+ --text-lg: 1.0625rem;
+ --text-xl: 1.375rem;
+ --text-2xl: 1.875rem;
+ --text-3xl: 2.5rem;
+
+ /* Spacing: a 4px scale. Layout uses these, never magic pixels. */
+ --sp-1: 0.25rem;
+ --sp-2: 0.5rem;
+ --sp-3: 0.75rem;
+ --sp-4: 1rem;
+ --sp-5: 1.5rem;
+ --sp-6: 2rem;
+ --sp-7: 3rem;
+
+ --radius-sm: 6px;
+ --radius-md: 10px;
+ --radius-lg: 14px;
+ --radius-xl: 20px;
+ --radius-pill: 999px;
+
+ --transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);
+}
+
+/* ── Dark (default) ─────────────────────────────────────────────────────── */
+[data-theme="dark"] {
+ --bg: #0d1014;
+ --bg-raised: #141920;
+ --surface: #171d25;
+ --surface-hover: #1d242e;
+ --border: #232b36;
+ --border-strong: #303a48;
+
+ --fg: #e8edf4;
+ --fg-muted: #8b97a8;
+ --fg-subtle: #5d6878;
+
+ --accent: #4c8dff;
+ --accent-fg: #ffffff;
+ --accent-soft: rgba(76, 141, 255, 0.14);
+
+ /* Status. Used for task state, gate results and trend direction alike, so
+ the same colour always means the same thing wherever it appears. */
+ --ok: #3fbf7f;
+ --ok-soft: rgba(63, 191, 127, 0.14);
+ --warn: #e8a33d;
+ --warn-soft: rgba(232, 163, 61, 0.14);
+ --danger: #f0616d;
+ --danger-soft: rgba(240, 97, 109, 0.14);
+ --info: #4c8dff;
+ --info-soft: rgba(76, 141, 255, 0.14);
+ --idle: #6b7688;
+ --idle-soft: rgba(107, 118, 136, 0.14);
+
+ --accent-2: #7b5cff;
+ --bg-blur: rgba(20, 25, 32, 0.55);
+ /* Panels are translucent so the canvas wash shows through and the whole
+ workspace reads as one lit surface rather than opaque cards on a picture. */
+ --surface-glass: rgba(23, 29, 37, 0.62);
+ --surface-glass-strong: rgba(20, 25, 32, 0.78);
+ --workspace: rgba(17, 21, 27, 0.55);
+ --hairline: rgba(255, 255, 255, 0.06);
+ --wash-a: rgba(76, 141, 255, 0.10);
+ --wash-b: rgba(123, 92, 255, 0.12);
+ --wash-c: rgba(63, 191, 127, 0.06);
+ --shadow-workspace: 0 24px 70px rgba(0, 0, 0, 0.5);
+
+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
+ --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.42);
+}
+
+/* ── Light ──────────────────────────────────────────────────────────────── */
+[data-theme="light"] {
+ --bg: #f6f8fb;
+ --bg-raised: #ffffff;
+ --surface: #ffffff;
+ --surface-hover: #f1f4f9;
+ --border: #e2e8f0;
+ --border-strong: #cbd5e1;
+
+ --fg: #16202e;
+ --fg-muted: #5a6779;
+ --fg-subtle: #8c99ab;
+
+ --accent: #2563eb;
+ --accent-fg: #ffffff;
+ --accent-soft: rgba(37, 99, 235, 0.1);
+
+ --ok: #10935c;
+ --ok-soft: rgba(16, 147, 92, 0.12);
+ --warn: #b87514;
+ --warn-soft: rgba(184, 117, 20, 0.12);
+ --danger: #d4344a;
+ --danger-soft: rgba(212, 52, 74, 0.12);
+ --info: #2563eb;
+ --info-soft: rgba(37, 99, 235, 0.1);
+ --idle: #64748b;
+ --idle-soft: rgba(100, 116, 139, 0.12);
+
+ --accent-2: #7c3aed;
+ --bg-blur: rgba(255, 255, 255, 0.6);
+ --surface-glass: rgba(255, 255, 255, 0.72);
+ --surface-glass-strong: rgba(255, 255, 255, 0.88);
+ --workspace: rgba(255, 255, 255, 0.55);
+ --hairline: rgba(15, 23, 42, 0.06);
+ --wash-a: rgba(37, 99, 235, 0.10);
+ --wash-b: rgba(124, 58, 237, 0.12);
+ --wash-c: rgba(16, 147, 92, 0.07);
+ --shadow-workspace: 0 24px 70px rgba(15, 23, 42, 0.14);
+
+ --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
+ --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.10);
+}
diff --git a/ui/src/dashboard/dashboard.css b/ui/src/dashboard/dashboard.css
new file mode 100644
index 000000000..69f7d1f35
--- /dev/null
+++ b/ui/src/dashboard/dashboard.css
@@ -0,0 +1,368 @@
+/* Dashboard-only styles. Feature folders own their CSS and import it from
+ their JS, so a section can be added or removed without editing _main.css. */
+
+/* ── Stat tiles ─────────────────────────────────────────────────────────── */
+
+.stat-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-2);
+}
+
+.stat-label {
+ font-size: var(--text-sm);
+ color: var(--fg-muted);
+}
+
+.stat-trend {
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ font-size: var(--text-xs);
+ font-weight: 500;
+}
+
+.stat-trend.up {
+ color: var(--ok);
+}
+
+.stat-trend.down {
+ color: var(--danger);
+}
+
+.stat-value {
+ font-size: var(--text-3xl);
+ font-weight: 600;
+ letter-spacing: -0.03em;
+ margin: var(--sp-2) 0 0;
+}
+
+.stat-unit {
+ font-size: var(--text-lg);
+ color: var(--fg-muted);
+ margin-left: var(--sp-1);
+}
+
+.stat-compare {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ margin-top: var(--sp-1);
+}
+
+.spark {
+ width: 100%;
+ height: 34px;
+ margin-top: var(--sp-3);
+ display: block;
+}
+
+/* ── Getting started checklist ──────────────────────────────────────────── */
+
+.setup {
+ margin-bottom: var(--sp-4);
+}
+
+.setup-pct {
+ font-size: var(--text-lg);
+ font-weight: 600;
+ color: var(--accent);
+}
+
+.setup-bar {
+ height: 5px;
+ border-radius: var(--radius-pill);
+ background: var(--border);
+ overflow: hidden;
+ margin-bottom: var(--sp-4);
+}
+
+.setup-bar-fill {
+ height: 100%;
+ background: var(--accent);
+ border-radius: var(--radius-pill);
+ transition: width var(--transition);
+}
+
+.setup-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+}
+
+.setup-step {
+ display: flex;
+ gap: var(--sp-3);
+ align-items: flex-start;
+}
+
+.setup-check {
+ width: 18px;
+ height: 18px;
+ flex: none;
+ border-radius: 50%;
+ border: 1.5px solid var(--border-strong);
+ display: grid;
+ place-items: center;
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ margin-top: 1px;
+}
+
+.setup-step.done .setup-check {
+ background: var(--ok-soft);
+ border-color: transparent;
+ color: var(--ok);
+}
+
+.setup-step-title {
+ font-size: var(--text-sm);
+}
+
+.setup-step.done .setup-step-title {
+ color: var(--fg-muted);
+ text-decoration: line-through;
+}
+
+.setup-step-detail {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ margin-top: 2px;
+}
+
+/* ── Hero: greeting and the actions that belong with it ─────────────────── */
+
+.hero {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: var(--sp-5);
+ flex-wrap: wrap;
+ margin-bottom: var(--sp-5);
+}
+
+.hero-title {
+ font-size: var(--text-3xl);
+ font-weight: 600;
+ letter-spacing: -0.03em;
+ margin: 0;
+}
+
+.hero-sub {
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+ margin: var(--sp-2) 0 0;
+}
+
+.hero-actions {
+ display: flex;
+ gap: var(--sp-2);
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+/* ── Top row: checklist / pulse side by side ────────────────────────────── */
+
+.dash-top {
+ display: grid;
+ grid-template-columns: 1.6fr 1fr;
+ gap: var(--sp-4);
+ margin-bottom: var(--sp-4);
+}
+
+@media (max-width: 1080px) {
+ .dash-top {
+ grid-template-columns: 1fr;
+ }
+}
+
+/* ── Gauge ──────────────────────────────────────────────────────────────── */
+
+.gauge-wrap {
+ position: relative;
+ display: grid;
+ place-items: center;
+}
+
+.gauge {
+ width: 100%;
+ max-width: 200px;
+ display: block;
+}
+
+.gauge-value {
+ transition: stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
+}
+
+.gauge-center {
+ position: absolute;
+ top: 52%;
+ transform: translateY(-50%);
+ text-align: center;
+}
+
+.gauge-pct {
+ font-size: var(--text-2xl);
+ font-weight: 600;
+ letter-spacing: -0.03em;
+}
+
+.gauge-label {
+ font-size: var(--text-xs);
+ color: var(--fg-muted);
+}
+
+.pulse-list {
+ list-style: none;
+ margin: var(--sp-4) 0 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-2);
+}
+
+.pulse-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-3);
+ font-size: var(--text-sm);
+ padding: var(--sp-2) var(--sp-3);
+ border-radius: var(--radius-sm);
+ background: var(--bg-raised);
+}
+
+.pulse-name {
+ color: var(--fg-muted);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+/* ── Segmented bar ──────────────────────────────────────────────────────── */
+
+.segbar {
+ display: flex;
+ height: 10px;
+ border-radius: var(--radius-pill);
+ overflow: hidden;
+ background: var(--border);
+ gap: 2px;
+}
+
+.segbar-part {
+ display: block;
+ height: 100%;
+}
+
+.segbar-ok { background: var(--ok); }
+.segbar-warn { background: var(--warn); }
+.segbar-danger { background: var(--danger); }
+.segbar-info { background: var(--info); }
+.segbar-idle { background: var(--idle); }
+
+.segbar-legend {
+ display: flex;
+ gap: var(--sp-4);
+ margin-top: var(--sp-3);
+ flex-wrap: wrap;
+}
+
+.segbar-key {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-2);
+ font-size: var(--text-xs);
+ color: var(--fg-muted);
+}
+
+.segbar-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+}
+
+.forecast-value {
+ font-size: var(--text-3xl);
+ font-weight: 600;
+ letter-spacing: -0.03em;
+ margin-bottom: var(--sp-1);
+}
+
+.forecast-note {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ margin-bottom: var(--sp-4);
+}
+
+.dash-split {
+ display: grid;
+ grid-template-columns: 1fr 1.5fr;
+ gap: var(--sp-4);
+ margin-top: var(--sp-4);
+}
+
+@media (max-width: 1080px) {
+ .dash-split {
+ grid-template-columns: 1fr;
+ }
+}
+
+.stat-card {
+ position: relative;
+ overflow: hidden;
+}
+
+/* ── Section grouping ───────────────────────────────────────────────────── */
+
+/* Panels are grouped under a quiet section label so the dashboard reads as one
+ surface with regions, rather than a scatter of unrelated cards. */
+.dash-section {
+ margin-bottom: var(--sp-5);
+}
+
+.dash-section-head {
+ display: flex;
+ align-items: baseline;
+ gap: var(--sp-3);
+ margin-bottom: var(--sp-3);
+ padding-left: var(--sp-1);
+}
+
+.dash-section-title {
+ font-size: var(--text-xs);
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--fg-subtle);
+ font-weight: 600;
+ margin: 0;
+}
+
+.dash-section-note {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+}
+
+.hero-actions-inner {
+ display: flex;
+ gap: var(--sp-2);
+ flex-wrap: wrap;
+ align-items: center;
+}
+
+/* An action that exists because something needs attention should look unlike
+ one that is always present. */
+.btn-attention {
+ border-color: var(--warn);
+ color: var(--warn);
+ background: var(--warn-soft);
+ font-weight: 500;
+}
+
+.btn-attention:hover {
+ background: var(--warn-soft);
+ filter: brightness(1.1);
+}
diff --git a/ui/src/dashboard/dashboard.js b/ui/src/dashboard/dashboard.js
new file mode 100644
index 000000000..3c0481ded
--- /dev/null
+++ b/ui/src/dashboard/dashboard.js
@@ -0,0 +1,353 @@
+import "./dashboard.css";
+import { api, subscribeEvents } from "../base/api.js";
+import { ago, compact, el, empty, mount, pill, statusKind } from "../base/dom.js";
+import { statTile } from "../base/statTile.js";
+import { gauge, segmentBar } from "../base/gauge.js";
+import { icon } from "../base/icons.js";
+
+/**
+ * The control room. Answers, in order: is anything wrong, what is Archie doing
+ * right now, and what have I not finished setting up.
+ *
+ * Every panel degrades to an explanatory empty state rather than a blank box,
+ * because a fresh install has no tasks and a dashboard of zeroes teaches
+ * nobody anything.
+ */
+export function dashboardPage() {
+ const root = el("div");
+ const runs = el("tbody");
+ const statsRow = el("div.grid.grid-4");
+ const setupSlot = el("div");
+ const pulseSlot = el("div");
+ const forecastSlot = el("div");
+ const actions = el("div.hero-actions-inner");
+ const title = el("h1.hero-title", greeting());
+ const streamState = pill("connecting", "idle");
+
+ render();
+ load();
+
+ const unsubscribe = subscribeEvents(
+ (event) => prependRun(runs, event),
+ (state) => {
+ const kind = state === "live" ? "ok" : "warn";
+ streamState.className = `pill pill-${kind}`;
+ streamState.textContent = state;
+ },
+ );
+ root.addEventListener("archie:teardown", unsubscribe);
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.hero",
+ el(
+ "div",
+ title,
+ el(
+ "p.hero-sub",
+ "Your agent's control room \u2014 what it is working on, what needs you, and what it is spending.",
+ ),
+ ),
+ el("div.hero-actions", actions),
+ ),
+ el(
+ "div.dash-section",
+ el("div.dash-section-head", el("h2.dash-section-title", "Health")),
+ el("div.dash-top", setupSlot, pulseSlot),
+ ),
+ el(
+ "div.dash-section",
+ el(
+ "div.dash-section-head",
+ el("h2.dash-section-title", "Throughput"),
+ el("span.dash-section-note", "Across all repositories"),
+ ),
+ statsRow,
+ ),
+ el(
+ "div.dash-section",
+ el(
+ "div.dash-section-head",
+ el("h2.dash-section-title", "Right now"),
+ ),
+ el(
+ "div.dash-split",
+ forecastSlot,
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "Live activity"), el("p.card-sub", "Last 50, newest first")),
+ streamState,
+ ),
+ el(
+ "table.table",
+ el("thead", el("tr", ...["Event", "Task", "Detail", "When"].map((h) => el("th", h)))),
+ runs,
+ ),
+ ),
+ ),
+ ),
+ );
+ mount(runs, el("tr", el("td", { colspan: 4 }, empty("Waiting for activity", "Events appear here as Archie works."))));
+ }
+
+ async function load() {
+ try {
+ const [summary, setup, workflows] = await Promise.all([
+ api.summary(),
+ api.setup().catch(() => null),
+ api.workflows().catch(() => null),
+ ]);
+ renderActions(summary);
+ // The greeting is only personalised when the deployment says who it
+ // assists; an unconfigured instance greets without a name rather than
+ // inventing one.
+ title.textContent = setup?.operator ? `${greeting()}, ${setup.operator}` : greeting();
+ renderStats(summary);
+ renderSetup(setup);
+ renderPulse(summary, workflows);
+ renderForecast(summary);
+ } catch (err) {
+ mount(statsRow, el("div.card", empty("Cannot reach archied", String(err.message || err))));
+ }
+ }
+
+ // Actions follow state: what needs you comes first, and the generic ones
+ // only fill the space when nothing does. A row of buttons that is identical
+ // whatever is happening teaches nobody anything.
+ function renderActions(summary) {
+ const counts = summary?.statuses || {};
+ const blocked = (counts.parked || 0) + (counts.waiting_human || 0);
+ const running = counts.running || 0;
+
+ mount(
+ actions,
+ blocked > 0 &&
+ el(
+ "a.btn.btn-attention",
+ { href: "#/tasks" },
+ icon("tasks", { size: 15 }),
+ `${blocked} need${blocked === 1 ? "s" : ""} you`,
+ ),
+ running > 0 &&
+ el("a.btn", { href: "#/tasks" }, icon("workflows", { size: 15 }), `${running} running`),
+ el("a.btn", { href: "#/logs" }, icon("logs", { size: 15 }), "Logs"),
+ el("button.btn.btn-primary", { onclick: load }, icon("refresh", { size: 15 }), "Refresh"),
+ );
+ }
+
+ function renderStats(summary) {
+ const counts = summary?.statuses || {};
+ const done = (counts.merged || 0) + (counts.pr_open || 0);
+ const attention = (counts.parked || 0) + (counts.waiting_human || 0);
+ const total = Object.values(counts).reduce((a, b) => a + b, 0);
+ const tokens = summary?.tokens_by_day || [];
+
+ mount(
+ statsRow,
+ statTile({
+ label: "Working now",
+ value: counts.running || 0,
+ compare: `${counts.queued || 0} waiting to start`,
+ series: tokens.map((d) => d.tokens || 0),
+ }),
+ statTile({
+ label: "Needs you",
+ value: attention,
+ compare: attention ? "Parked or awaiting a reply" : "Nothing is blocked",
+ goodDirection: "down",
+ }),
+ statTile({
+ label: "Delivered",
+ value: done,
+ compare: total ? `${Math.round((done / total) * 100)}% of all tasks` : "No tasks yet",
+ }),
+ statTile({
+ label: "Tokens used",
+ value: compact(tokens.reduce((a, d) => a + (d.tokens || 0), 0)),
+ compare: `Across ${tokens.length || 0} days`,
+ trend: trendPct(tokens.map((d) => d.tokens || 0)),
+ goodDirection: "down",
+ series: tokens.map((d) => d.tokens || 0),
+ }),
+ );
+ }
+
+ function renderSetup(setup) {
+ if (!setup?.steps?.length) return mount(setupSlot);
+ const remaining = setup.steps.filter((s) => !s.done);
+ if (!remaining.length) return mount(setupSlot);
+
+ const pct = Math.round(((setup.steps.length - remaining.length) / setup.steps.length) * 100);
+ mount(
+ setupSlot,
+ el(
+ "div.card.setup",
+ el(
+ "div.card-head",
+ el(
+ "div",
+ el("h2.card-title", "Finish setting up"),
+ el("p.card-sub", "Archie needs these before it can work on its own."),
+ ),
+ el("span.setup-pct", `${pct}%`),
+ ),
+ el("div.setup-bar", el("div.setup-bar-fill", { style: `width:${pct}%` })),
+ el("ul.setup-list", ...setup.steps.map(setupStep)),
+ ),
+ );
+ }
+
+ function renderPulse(summary, workflows) {
+ renderPulseInto(pulseSlot, summary, workflows);
+ }
+
+ function renderForecast(summary) {
+ renderForecastInto(forecastSlot, summary);
+ }
+
+ function setupStep(step) {
+ return el(
+ `li.setup-step${step.done ? ".done" : ""}`,
+ el("span.setup-check", step.done ? icon("check", { size: 12 }) : ""),
+ el("div", el("div.setup-step-title", step.title), step.detail && el("div.setup-step-detail", step.detail)),
+ );
+ }
+
+ return root;
+}
+
+function prependRun(tbody, event) {
+ if (tbody.firstElementChild?.querySelector(".empty")) tbody.replaceChildren();
+ const row = el(
+ "tr",
+ el("td.strong", el("span", event.kind || event.type || "event")),
+ el("td.mono", event.task_id ? `#${event.task_id}` : "—"),
+ el("td", event.detail || event.message || ""),
+ el("td", ago(event.at || Date.now())),
+ );
+ tbody.prepend(row);
+ while (tbody.children.length > 50) tbody.lastElementChild.remove();
+}
+
+function greeting() {
+ const h = new Date().getHours();
+ if (h < 5) return "Still up?";
+ if (h < 12) return "Good morning";
+ if (h < 18) return "Good afternoon";
+ return "Good evening";
+}
+
+
+/**
+ * Gate pulse: the share of finished work that got through the quality gates.
+ *
+ * This is the dashboard's headline health number -- Archie's whole promise is
+ * that it does not open a PR until the gates pass, so a falling pass rate is
+ * the first thing worth seeing.
+ */
+function renderPulseInto(slot, summary, workflows) {
+ const stats = workflows?.workflows || [];
+ const runs = stats.reduce((a, w) => a + (w.runs || 0), 0);
+ const merged = stats.reduce((a, w) => a + (w.merged || 0) + (w.pr_open || 0), 0);
+ const parked = stats.reduce((a, w) => a + (w.parked || 0), 0);
+
+ if (!runs) {
+ mount(
+ slot,
+ el(
+ "div.card",
+ el("div.card-head", el("h2.card-title", "Gate pulse")),
+ empty("No completed runs yet", "Once Archie finishes a task, its gate pass rate appears here."),
+ ),
+ );
+ return;
+ }
+
+ const pct = (merged / runs) * 100;
+ mount(
+ slot,
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el(
+ "div",
+ el("h2.card-title", "Gate pulse"),
+ el("p.card-sub", "Work that passed its quality gates"),
+ ),
+ ),
+ gauge({ value: pct, label: "pass rate" }),
+ el(
+ "ul.pulse-list",
+ ...stats.slice(0, 3).map((w) =>
+ el(
+ "li.pulse-item",
+ el("span.pulse-name", w.workflow || "workflow"),
+ pill(
+ `${w.merged || 0}/${w.runs || 0}`,
+ (w.merged || 0) === (w.runs || 0) ? "ok" : (w.parked || 0) > 0 ? "warn" : "info",
+ ),
+ ),
+ ),
+ parked > 0 &&
+ el("li.pulse-item", el("span.pulse-name", "Parked, awaiting you"), pill(String(parked), "warn")),
+ ),
+ ),
+ );
+}
+
+/**
+ * Budget outlook: what this month's token spend is tracking toward, and how
+ * much of the configured budget it accounts for.
+ */
+function renderForecastInto(slot, summary) {
+ const days = summary?.tokens_by_day || [];
+ const used = days.reduce((a, d) => a + (d.tokens || 0), 0);
+
+ if (!days.length) {
+ mount(
+ slot,
+ el(
+ "div.card",
+ el("div.card-head", el("h2.card-title", "Token outlook")),
+ empty("Nothing spent yet", "Usage appears here once Archie runs its first task."),
+ ),
+ );
+ return;
+ }
+
+ const perDay = used / days.length;
+ const projected = Math.round(perDay * 30);
+ const recent = days.slice(-7).reduce((a, d) => a + (d.tokens || 0), 0);
+
+ mount(
+ slot,
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "Token outlook"), el("p.card-sub", "Next 30 days at the current rate")),
+ ),
+ el("div.forecast-value", compact(projected)),
+ el("div.forecast-note", `Based on ${compact(Math.round(perDay))} per day over ${days.length} days`),
+ segmentBar([
+ { label: `Last 7 days (${compact(recent)})`, value: recent, kind: "info" },
+ { label: `Earlier (${compact(used - recent)})`, value: Math.max(used - recent, 0), kind: "idle" },
+ ]),
+ ),
+ );
+}
+
+/** Percentage change between the first and second half of a series. */
+function trendPct(series) {
+ if (series.length < 4) return null;
+ const mid = Math.floor(series.length / 2);
+ const older = series.slice(0, mid).reduce((a, b) => a + b, 0);
+ const newer = series.slice(mid).reduce((a, b) => a + b, 0);
+ if (!older) return null;
+ return ((newer - older) / older) * 100;
+}
diff --git a/ui/src/logs/logs.css b/ui/src/logs/logs.css
new file mode 100644
index 000000000..e38db2e1d
--- /dev/null
+++ b/ui/src/logs/logs.css
@@ -0,0 +1,145 @@
+/* Log view. Dense by design: the point is scanning many lines quickly, so the
+ type is smaller and the rows tighter than elsewhere in the dashboard. */
+
+.log-filters {
+ display: flex;
+ gap: var(--sp-2);
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.log-status {
+ display: flex;
+ gap: var(--sp-3);
+ align-items: center;
+}
+
+.log-meta {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ font-family: var(--font-mono);
+}
+
+.log-select,
+.log-search {
+ background: var(--bg-raised);
+ border: 1px solid var(--border-strong);
+ color: var(--fg);
+ border-radius: var(--radius-sm);
+ padding: var(--sp-2) var(--sp-3);
+ font: inherit;
+ font-size: var(--text-sm);
+}
+
+.log-search {
+ min-width: 220px;
+}
+
+.log-select:focus,
+.log-search:focus {
+ outline: 2px solid var(--accent);
+ outline-offset: -1px;
+}
+
+.log-list {
+ max-height: 62vh;
+ overflow-y: auto;
+ font-family: var(--font-mono);
+ font-size: var(--text-xs);
+ border-top: 1px solid var(--border);
+}
+
+.log-loading {
+ padding: var(--sp-5);
+ color: var(--fg-muted);
+ text-align: center;
+}
+
+.log-row {
+ display: grid;
+ grid-template-columns: 62px 52px 1fr;
+ gap: var(--sp-3);
+ padding: var(--sp-2) var(--sp-1);
+ border-bottom: 1px solid var(--border);
+ align-items: baseline;
+}
+
+.log-row:hover {
+ background: var(--surface-hover);
+}
+
+.log-time {
+ color: var(--fg-subtle);
+}
+
+.log-level {
+ font-size: 10px;
+ font-weight: 600;
+ letter-spacing: 0.04em;
+}
+
+/* Level colour lives on the row so the message inherits emphasis without a
+ second rule per level. */
+.log-danger .log-level {
+ color: var(--danger);
+}
+.log-warn .log-level {
+ color: var(--warn);
+}
+.log-info .log-level {
+ color: var(--info);
+}
+.log-idle .log-level {
+ color: var(--idle);
+}
+
+.log-danger .log-msg {
+ color: var(--fg);
+}
+
+.log-body {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--sp-2);
+ align-items: baseline;
+ min-width: 0;
+}
+
+.log-msg {
+ color: var(--fg);
+ word-break: break-word;
+}
+
+/* Structured fields read as attached detail, not part of the sentence. */
+.log-field {
+ color: var(--fg-muted);
+ background: var(--bg-raised);
+ border-radius: var(--radius-sm);
+ padding: 0 var(--sp-2);
+ white-space: nowrap;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.log-field-key {
+ color: var(--fg-subtle);
+}
+
+.log-field-key::after {
+ content: "=";
+ opacity: 0.6;
+}
+
+@media (max-width: 860px) {
+ .log-row {
+ grid-template-columns: 56px 1fr;
+ }
+ .log-level {
+ display: none;
+ }
+ .log-search {
+ min-width: 0;
+ flex: 1;
+ }
+}
diff --git a/ui/src/logs/logs.js b/ui/src/logs/logs.js
new file mode 100644
index 000000000..1c21311e2
--- /dev/null
+++ b/ui/src/logs/logs.js
@@ -0,0 +1,233 @@
+import "./logs.css";
+import { api, subscribeEvents } from "../base/api.js";
+import { el, empty, mount, pill } from "../base/dom.js";
+
+/**
+ * The log view: history from the file on disk, then live lines appended from
+ * the event stream.
+ *
+ * Filtering is applied server-side for history (the file is far larger than a
+ * page of it) and client-side for live lines (they are already in hand). Both
+ * paths go through the same matcher shape so a filter means the same thing
+ * either side of the join.
+ */
+
+const LEVELS = [
+ { value: "", label: "All levels" },
+ { value: "ERROR", label: "Errors" },
+ { value: "WARN,ERROR", label: "Warnings and errors" },
+ { value: "INFO,WARN,ERROR", label: "Info and above" },
+ { value: "DEBUG", label: "Debug only" },
+];
+
+function levelKind(level) {
+ switch ((level || "").toUpperCase()) {
+ case "ERROR":
+ return "danger";
+ case "WARN":
+ return "warn";
+ case "DEBUG":
+ return "idle";
+ default:
+ return "info";
+ }
+}
+
+export function logsPage() {
+ const root = el("div");
+ const list = el("div.log-list");
+ const streamState = pill("connecting", "idle");
+ const meta = el("span.log-meta");
+
+ let filters = { level: "", component: "", q: "" };
+ let paused = false;
+ let componentOptions = [];
+
+ const levelSelect = el(
+ "select.log-select",
+ { onchange: (e) => set({ level: e.target.value }) },
+ ...LEVELS.map((l) => el("option", { value: l.value }, l.label)),
+ );
+ const componentSelect = el("select.log-select", {
+ onchange: (e) => set({ component: e.target.value }),
+ });
+ const search = el("input.log-search", {
+ type: "search",
+ placeholder: "Search messages and fields…",
+ oninput: debounce((e) => set({ q: e.target.value }), 250),
+ });
+ const pauseBtn = el("button.btn", { onclick: togglePause }, "Pause");
+
+ render();
+ load();
+
+ const unsubscribe = subscribeEvents(
+ (event) => appendLive(event),
+ (state) => {
+ streamState.className = `pill pill-${state === "live" ? "ok" : "warn"}`;
+ streamState.textContent = state;
+ },
+ );
+ root.addEventListener("archie:teardown", unsubscribe);
+
+ function set(patch) {
+ filters = { ...filters, ...patch };
+ load();
+ }
+
+ function togglePause() {
+ paused = !paused;
+ pauseBtn.textContent = paused ? "Resume" : "Pause";
+ pauseBtn.classList.toggle("btn-primary", paused);
+ }
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Logs"),
+ el("p.page-sub", "What Archie has been doing, newest last."),
+ ),
+ el("div.page-actions", pauseBtn, el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div.log-filters", levelSelect, componentSelect, search),
+ el("div.log-status", meta, streamState),
+ ),
+ list,
+ ),
+ );
+ }
+
+ async function load() {
+ mount(list, el("div.log-loading", "Loading…"));
+ try {
+ const res = await api.logs({
+ level: filters.level,
+ component: filters.component,
+ q: filters.q,
+ limit: 500,
+ });
+
+ if (res.disabled) {
+ mount(
+ list,
+ empty(
+ "File logging is off",
+ "Set [log] file in your config to keep a durable record. Live lines below still stream while this page is open.",
+ ),
+ );
+ meta.textContent = "";
+ return;
+ }
+
+ syncComponents(res.components || []);
+ meta.textContent = res.truncated
+ ? `showing the most recent matches from ${res.file}`
+ : res.file || "";
+
+ const entries = res.entries || [];
+ if (!entries.length) {
+ mount(list, empty("Nothing matches", "Try a wider level or clear the search."));
+ return;
+ }
+ mount(list, ...entries.map(row));
+ list.scrollTop = list.scrollHeight;
+ } catch (err) {
+ mount(list, empty("Cannot read logs", String(err.message || err)));
+ }
+ }
+
+ // Rebuild the component filter from what the log actually contains, so the
+ // options never drift from reality.
+ function syncComponents(components) {
+ if (sameList(components, componentOptions)) return;
+ componentOptions = components;
+ const current = filters.component;
+ mount(
+ componentSelect,
+ el("option", { value: "" }, "All components"),
+ ...components.map((c) => el("option", { value: c }, c)),
+ );
+ componentSelect.value = current;
+ }
+
+ function appendLive(event) {
+ if (paused) return;
+ const entry = {
+ time: event.at || new Date().toISOString(),
+ level: event.level || "INFO",
+ msg: event.detail || event.message || event.kind || "event",
+ fields: event.task_id ? { task: event.task_id } : null,
+ };
+ if (!matchesLocally(entry)) return;
+
+ // Only auto-scroll when already at the bottom, so reading history is not
+ // yanked away by an arriving line.
+ const atBottom = list.scrollHeight - list.scrollTop - list.clientHeight < 40;
+ if (list.querySelector(".empty, .log-loading")) list.replaceChildren();
+ list.append(row({ ...entry, message: entry.msg }));
+ while (list.children.length > 1000) list.firstElementChild.remove();
+ if (atBottom) list.scrollTop = list.scrollHeight;
+ }
+
+ function matchesLocally(entry) {
+ if (filters.level && !filters.level.split(",").includes((entry.level || "").toUpperCase())) {
+ return false;
+ }
+ if (filters.component && entry.fields?.component !== filters.component) return false;
+ if (filters.q) {
+ const needle = filters.q.toLowerCase();
+ const hay = `${entry.msg} ${JSON.stringify(entry.fields || {})}`.toLowerCase();
+ if (!hay.includes(needle)) return false;
+ }
+ return true;
+ }
+
+ return root;
+}
+
+function row(entry) {
+ const fields = entry.fields || {};
+ return el(
+ `div.log-row.log-${levelKind(entry.level)}`,
+ el("span.log-time.mono", shortTime(entry.time)),
+ el("span.log-level", (entry.level || "info").toUpperCase()),
+ el(
+ "span.log-body",
+ el("span.log-msg", entry.message || entry.msg || ""),
+ ...Object.entries(fields).map(([k, v]) =>
+ el("span.log-field", el("span.log-field-key", k), String(fmtValue(v))),
+ ),
+ ),
+ );
+}
+
+function fmtValue(v) {
+ if (v == null) return "";
+ return typeof v === "object" ? JSON.stringify(v) : v;
+}
+
+function shortTime(value) {
+ const d = value instanceof Date ? value : new Date(value);
+ if (Number.isNaN(d.getTime())) return "--:--:--";
+ return d.toTimeString().slice(0, 8);
+}
+
+function sameList(a, b) {
+ return a.length === b.length && a.every((v, i) => v === b[i]);
+}
+
+function debounce(fn, ms) {
+ let t;
+ return (...args) => {
+ clearTimeout(t);
+ t = setTimeout(() => fn(...args), ms);
+ };
+}
diff --git a/ui/src/main.js b/ui/src/main.js
new file mode 100644
index 000000000..fadf38bee
--- /dev/null
+++ b/ui/src/main.js
@@ -0,0 +1,164 @@
+import "./css/_main.css";
+import { el, mount } from "./base/dom.js";
+import { icon } from "./base/icons.js";
+import { dashboardPage } from "./dashboard/dashboard.js";
+import { tasksPage } from "./tasks/tasks.js";
+import { skillsPage } from "./skills/skills.js";
+import { workflowsPage } from "./workflows/workflows.js";
+import { channelsPage } from "./channels/channels.js";
+import { settingsPage } from "./settings/settings.js";
+import { logsPage } from "./logs/logs.js";
+import { memoryPage } from "./memory/memory.js";
+
+/**
+ * Routes are declared once here. Adding a section means adding a feature
+ * folder and one entry -- there is no switch statement to hunt for.
+ *
+ * `soon: true` sections are deliberately visible before they are built: a
+ * greyed, labelled entry tells you the capability exists and is coming, which
+ * is more honest than hiding it and more useful than a 404.
+ */
+const routes = [
+ { path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
+ { path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
+ { path: "/logs", label: "Logs", icon: "logs", view: logsPage },
+ { path: "/skills", label: "Skills", icon: "skills", view: skillsPage },
+ { path: "/workflows", label: "Workflows", icon: "workflows", view: workflowsPage },
+ { path: "/memory", label: "Memory", icon: "memory", view: memoryPage },
+ { path: "/channels", label: "Channels", icon: "channels", view: channelsPage },
+ { path: "/settings", label: "Configuration", icon: "settings", view: settingsPage },
+];
+
+const THEME_KEY = "archie.theme";
+
+function applyTheme(theme) {
+ document.documentElement.dataset.theme = theme;
+ localStorage.setItem(THEME_KEY, theme);
+}
+
+function currentTheme() {
+ return localStorage.getItem(THEME_KEY) || "dark";
+}
+
+
+function commandBar(onNavigate) {
+ const items = new Map();
+
+ const nav = el(
+ "nav.nav",
+ ...[null].flatMap(() => [
+ ...routes
+ .map((route) => {
+ const item = el(
+ "a.nav-item",
+ {
+ href: `#${route.path}`,
+ onclick: (e) => {
+ if (route.soon) e.preventDefault();
+ else onNavigate(route.path);
+ },
+ "aria-disabled": route.soon || undefined,
+ title: route.soon ? "Coming soon" : undefined,
+ },
+ icon(route.icon),
+ el("span.nav-label", route.label),
+ route.soon && el("span.nav-soon", "soon"),
+ );
+ items.set(route.path, item);
+ return item;
+ }),
+ ]),
+ );
+
+ const themeBtn = el("button.icon-btn", {
+ title: "Toggle light and dark",
+ "aria-label": "Toggle light and dark",
+ onclick: () => {
+ applyTheme(currentTheme() === "dark" ? "light" : "dark");
+ mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
+ },
+ });
+ mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
+
+ // Search jumps between sections. It is deliberately not a data search: the
+ // sections own their own filtering, and a second search that means something
+ // different in each place is worse than none.
+ const search = el("input", {
+ type: "search",
+ placeholder: "Jump to\u2026",
+ "aria-label": "Jump to a section",
+ onkeydown: (e) => {
+ if (e.key !== "Enter") return;
+ const q = e.target.value.trim().toLowerCase();
+ const hit = routes.find((r) => !r.soon && r.label.toLowerCase().startsWith(q));
+ if (hit) {
+ onNavigate(hit.path);
+ e.target.value = "";
+ e.target.blur();
+ }
+ },
+ });
+
+ return {
+ node: el(
+ "header.topbar",
+ el("div.brand", el("span.brand-mark", "A"), "Archie"),
+ nav,
+ el(
+ "div.topbar-end",
+ el("div.topbar-search", icon("search", { size: 15 }), search),
+ el("button.icon-btn", { title: "Documentation", "aria-label": "Documentation" }, icon("help")),
+ themeBtn,
+ el("div.avatar", { title: "Signed in locally" }, "A"),
+ ),
+ ),
+ highlight(path) {
+ for (const [p, node] of items) {
+ if (p === path) node.setAttribute("aria-current", "page");
+ else node.removeAttribute("aria-current");
+ }
+ },
+ };
+}
+
+function start() {
+ applyTheme(currentTheme());
+
+ const outlet = el("main.main");
+ const bar = commandBar(navigate);
+ mount(document.getElementById("app"), el("div.shell", bar.node, outlet));
+
+ function navigate(path) {
+ if (location.hash !== `#${path}`) location.hash = path;
+ else show(path);
+ }
+
+ function show(path) {
+ // Let a page release its subscriptions before it is replaced, so the SSE
+ // stream does not leak a connection per navigation.
+ outlet.firstElementChild?.dispatchEvent(new CustomEvent("archie:teardown"));
+ const route = routes.find((r) => r.path === path) || routes[0];
+ bar.highlight(route.path);
+ mount(outlet, route.view ? route.view() : comingSoon(route));
+ }
+
+ window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
+ show(location.hash.slice(1) || "/");
+}
+
+function comingSoon(route) {
+ return el(
+ "div",
+ el("div.page-head", el("div", el("h1.page-title", route.label))),
+ el(
+ "div.card",
+ el(
+ "div.empty",
+ el("div.empty-title", `${route.label} is not built yet`),
+ el("div", "This section is next up. Nothing is broken."),
+ ),
+ ),
+ );
+}
+
+start();
diff --git a/ui/src/memory/memory.css b/ui/src/memory/memory.css
new file mode 100644
index 000000000..ca3d96b58
--- /dev/null
+++ b/ui/src/memory/memory.css
@@ -0,0 +1,44 @@
+/* Memory view: provider cards listing the tools each gives the agent. */
+
+.mem-loading {
+ padding: var(--sp-5);
+ text-align: center;
+ color: var(--fg-muted);
+}
+
+.mem-warning {
+ font-size: var(--text-sm);
+ color: var(--warn);
+ background: var(--warn-soft);
+ border-radius: var(--radius-sm);
+ padding: var(--sp-2) var(--sp-3);
+ margin: 0 0 var(--sp-3);
+}
+
+.mem-tools {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-2);
+}
+
+.mem-tool {
+ padding: var(--sp-3);
+ border-radius: var(--radius-sm);
+ background: var(--bg-raised);
+ border: 1px solid var(--hairline);
+}
+
+.mem-tool-name {
+ font-size: var(--text-sm);
+ color: var(--fg);
+ font-weight: 500;
+}
+
+.mem-tool-desc {
+ font-size: var(--text-xs);
+ color: var(--fg-muted);
+ margin-top: 2px;
+}
diff --git a/ui/src/memory/memory.js b/ui/src/memory/memory.js
new file mode 100644
index 000000000..c8417fff0
--- /dev/null
+++ b/ui/src/memory/memory.js
@@ -0,0 +1,102 @@
+import "./memory.css";
+import { api } from "../base/api.js";
+import { el, empty, mount, pill } from "../base/dom.js";
+import { icon } from "../base/icons.js";
+
+/**
+ * Memory: what Archie can recall, and with what.
+ *
+ * Memory is otherwise invisible -- it is a set of tools handed to the model at
+ * discovery time, so without this page the only way to know what the agent can
+ * remember is to read the provider source.
+ */
+export function memoryPage() {
+ const root = el("div");
+ const body = el("div");
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Memory"),
+ el("p.page-sub", "What Archie can recall between conversations, and the tools it uses to do it."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, icon("refresh", { size: 15 }), "Refresh")),
+ ),
+ body,
+ );
+ }
+
+ async function load() {
+ mount(body, el("div.card", el("div.mem-loading", "Loading…")));
+ try {
+ const res = await api.memory();
+ if (!res.enabled || !res.providers?.length) {
+ mount(
+ body,
+ el(
+ "div.card",
+ empty(
+ "Memory is not configured",
+ "Without a provider, Archie starts every conversation with no recollection of earlier ones.",
+ ),
+ ),
+ );
+ return;
+ }
+ mount(body, el("div.grid.grid-2", ...res.providers.map(providerCard)));
+ } catch (err) {
+ mount(body, el("div.card", empty("Cannot read memory providers", String(err.message || err))));
+ }
+ }
+
+ return root;
+}
+
+function providerCard(p) {
+ const tools = p.tools || [];
+ return el(
+ "div.card",
+ el(
+ "div.card-head",
+ el(
+ "div",
+ el("h2.card-title", p.name || "provider"),
+ el("p.card-sub", roleLabel(p.role)),
+ ),
+ p.available
+ ? pill("ready", "ok")
+ : pill("unavailable", "danger"),
+ ),
+ !p.available &&
+ el(
+ "p.mem-warning",
+ "Configured but not usable right now — a required binary or connection may be missing.",
+ ),
+ tools.length
+ ? el(
+ "ul.mem-tools",
+ ...tools.map((t) =>
+ el(
+ "li.mem-tool",
+ el("div.mem-tool-name.mono", t.name),
+ t.description && el("div.mem-tool-desc", t.description),
+ ),
+ ),
+ )
+ : el("p.mem-warning", "This provider exposes no tools, so the agent cannot use it."),
+ );
+}
+
+// Plain language: "builtin" and "external" are implementation words.
+function roleLabel(role) {
+ return role === "external"
+ ? "Added by you — an external store Archie was given"
+ : "Built in — always available to Archie";
+}
diff --git a/ui/src/settings/settings.css b/ui/src/settings/settings.css
new file mode 100644
index 000000000..0463a682e
--- /dev/null
+++ b/ui/src/settings/settings.css
@@ -0,0 +1,46 @@
+/* Configuration-only styles. */
+
+.cfg-section {
+ margin-bottom: var(--sp-4);
+}
+
+.cfg-subhead {
+ font-size: var(--text-sm);
+ font-weight: 600;
+ color: var(--fg-muted);
+ margin: var(--sp-4) 0 var(--sp-2);
+}
+
+.cfg-subhead:first-child {
+ margin-top: 0;
+}
+
+.cfg-rows {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-2);
+}
+
+.cfg-row {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: var(--sp-4);
+ padding: var(--sp-2) 0;
+ border-bottom: 1px solid var(--border);
+}
+
+.cfg-row:last-child {
+ border-bottom: 0;
+}
+
+.cfg-label {
+ font-size: var(--text-sm);
+ color: var(--fg-muted);
+}
+
+.cfg-value {
+ font-size: var(--text-sm);
+ color: var(--fg);
+ text-align: right;
+}
diff --git a/ui/src/settings/settings.js b/ui/src/settings/settings.js
new file mode 100644
index 000000000..009cb7fb5
--- /dev/null
+++ b/ui/src/settings/settings.js
@@ -0,0 +1,273 @@
+import "./settings.css";
+import { api } from "../base/api.js";
+import { el, empty, mount, pill } from "../base/dom.js";
+
+/**
+ * A read-only view of the config archied is actually running with, grouped
+ * by domain and explained in plain language. Backed by GET /api/config,
+ * which is built from an explicit, hand-picked allowlist on the Go side
+ * (internal/webui/api_config.go handleConfig) -- secrets never reach this
+ * page, so nothing here needs to be hidden or redacted client-side.
+ */
+export function settingsPage() {
+ const root = el("div");
+ const body = el("div");
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Configuration"),
+ el("p.page-sub", "What archied is actually running with right now."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ body,
+ );
+ }
+
+ async function load() {
+ try {
+ const cfg = await api.config();
+ renderBody(cfg);
+ } catch (err) {
+ mount(body, el("div.card", empty("Cannot reach archied", String(err.message || err))));
+ }
+ }
+
+ function renderBody(cfg) {
+ if (!cfg || Object.keys(cfg).length === 0) {
+ mount(
+ body,
+ el(
+ "div.card",
+ empty(
+ "No configuration loaded",
+ "archied is running without a config file wired into the dashboard, so there is nothing to show.",
+ ),
+ ),
+ );
+ return;
+ }
+
+ mount(
+ body,
+ identityCard(cfg.identity),
+ repositoriesCard(cfg.repositories),
+ modelsAndProvidersCard(cfg.models, cfg.providers),
+ budgetsCard(cfg.budgets),
+ agentCard(cfg.agent),
+ storageCard(cfg.storage, cfg.containers),
+ webCard(cfg.web),
+ );
+ }
+
+ return root;
+}
+
+function section(title, sub, ...children) {
+ return el(
+ "div.card.cfg-section",
+ el("div.card-head", el("div", el("h2.card-title", title), el("p.card-sub", sub))),
+ ...children,
+ );
+}
+
+function row(label, value) {
+ return el("div.cfg-row", el("span.cfg-label", label), el("span.cfg-value.mono", value ?? "—"));
+}
+
+function identityCard(identity) {
+ if (!identity) return section("Identity", "Who Archie is on the forge.", empty("Not available"));
+ return section(
+ "Identity",
+ "Who Archie is on the forge, and how it addresses commits and comments.",
+ el(
+ "div.cfg-rows",
+ row("Bot account", identity.bot_user),
+ row("Commit author email", identity.bot_email),
+ row("Pickup label", identity.label),
+ row("Forge type", identity.forge_type),
+ row("Forge host", identity.forge_host),
+ row("Max diff size (lines)", identity.diff_cap_lines),
+ ),
+ );
+}
+
+function repositoriesCard(repos) {
+ if (!repos?.length) {
+ return section(
+ "Repositories",
+ "The repositories Archie polls for work.",
+ empty("No repositories configured", "Add a [[repos]] entry in config.toml so Archie has somewhere to work."),
+ );
+ }
+ return section(
+ "Repositories",
+ "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
+ el(
+ "table.table",
+ el(
+ "thead",
+ el("tr", ...["Repository", "Base branch", "Ecosystem", "Quality gate", "Protected paths"].map((h) => el("th", h))),
+ ),
+ el(
+ "tbody",
+ ...repos.map((r) =>
+ el(
+ "tr",
+ el("td.strong", `${r.owner}/${r.name}`),
+ el("td.mono", r.base),
+ el("td", r.ecosystem || "go"),
+ el("td.mono", gateSummary(r.gate)),
+ el("td.mono", r.protect?.length ? r.protect.join(", ") : "—"),
+ ),
+ ),
+ ),
+ ),
+ );
+}
+
+function gateSummary(gate) {
+ if (!gate?.length) return "—";
+ return gate.map((cmd) => cmd.join(" ")).join(" → ");
+}
+
+function modelsAndProvidersCard(models, providers) {
+ const modelEntries = Object.entries(models || {});
+ const providerEntries = Object.entries(providers || {});
+
+ const modelRows = modelEntries.length
+ ? el("div.cfg-rows", ...modelEntries.map(([role, ref]) => row(roleLabel(role), ref)))
+ : empty("No model roles configured", "Assign a model to at least one role (e.g. \"builder\") in [models].");
+
+ const providerRows = providerEntries.length
+ ? el(
+ "table.table",
+ el("thead", el("tr", ...["Provider", "Class", "Base URL", "API key env var", "Status"].map((h) => el("th", h)))),
+ el(
+ "tbody",
+ ...providerEntries.map(([name, p]) =>
+ el(
+ "tr",
+ el("td.strong", name),
+ el("td", p.class),
+ el("td.mono", p.base_url || "default"),
+ el("td.mono", p.api_key_env || "—"),
+ el("td", p.configured ? pill("configured", "ok") : pill("missing credentials", "warn")),
+ ),
+ ),
+ ),
+ )
+ : empty("No providers configured", "Add a [providers.] entry so a model role above has something to run on.");
+
+ return section(
+ "Models & providers",
+ "Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.",
+ el("h3.cfg-subhead", "Model roles"),
+ modelRows,
+ el("h3.cfg-subhead", "Providers"),
+ providerRows,
+ );
+}
+
+function roleLabel(role) {
+ if (!role) return "Unknown role";
+ return role.charAt(0).toUpperCase() + role.slice(1).replace(/_/g, " ");
+}
+
+function budgetsCard(budgets) {
+ if (!budgets) return section("Budgets", "Limits on every agent stage.", empty("Not available"));
+ return section(
+ "Budgets",
+ "The limits every autonomous stage runs under, so a stuck task cannot run forever.",
+ el(
+ "div.cfg-rows",
+ row("Max steps", budgets.max_steps || "Unlimited"),
+ row("Max tokens", budgets.max_tokens || "Unlimited"),
+ row("Wall clock", budgets.wall_clock),
+ row("Max gate failures before parking", budgets.gate_max_failures || "Unlimited"),
+ ),
+ );
+}
+
+function agentCard(agent) {
+ if (!agent) return section("Agent execution", "How Archie runs autonomous stages.", empty("Not available"));
+ return section(
+ "Agent execution",
+ "How archied actually runs a stage of work.",
+ el(
+ "div.cfg-rows",
+ row("Execution mode", agentModeLabel(agent.mode)),
+ row("Worker command", agent.command),
+ row("Extra environment variables passed through", agent.env?.length ? agent.env.join(", ") : "None"),
+ ),
+ );
+}
+
+function agentModeLabel(mode) {
+ switch (mode) {
+ case "inprocess":
+ return "In-process (same binary as the daemon)";
+ case "subprocess":
+ return "Subprocess (separate archie-agent process)";
+ case "nats":
+ return "NATS (dispatched to a worker over the message bus)";
+ default:
+ return mode || "Not set";
+ }
+}
+
+function storageCard(storage, containers) {
+ const children = [];
+ if (storage) {
+ children.push(
+ el("h3.cfg-subhead", "Paths"),
+ el(
+ "div.cfg-rows",
+ row("Work directory", storage.work_dir),
+ row("Task database", storage.db_path),
+ row("Shared skills directory", storage.skills_dir || "None (uses the work directory)"),
+ row("Daemon plugin directory", storage.plugin_dir || "None"),
+ row("Secret engine plugin directory", storage.secret_engine_dir || "None (built-in engines only)"),
+ ),
+ );
+ }
+ if (containers) {
+ children.push(
+ el("h3.cfg-subhead", "Sandboxed containers"),
+ el(
+ "div.cfg-rows",
+ row("Sandboxing enabled", containers.enabled ? "Yes" : "No"),
+ row("Agent image", containers.image || "Not set"),
+ row("Max concurrent tasks", containers.max_concurrency || "Unlimited"),
+ row("Container max lifetime", containers.max_uptime),
+ row("Persistent volume retention", containers.volume_ttl),
+ row("How images are refreshed", pullPolicyLabel(containers.pull_policy)),
+ row("Docker network", containers.network || "Auto-detected"),
+ ),
+ );
+ }
+ if (!children.length) children.push(empty("Not available"));
+ return section("Storage & sandboxing", "Where archied keeps its state, and how it isolates task execution.", ...children);
+}
+
+function pullPolicyLabel(policy) {
+ if (policy === "always") return "Always pull the latest image before running";
+ return "Only pull when the image is missing locally";
+}
+
+function webCard(web) {
+ if (!web) return section("Dashboard", "This dashboard's own listen address.", empty("Not available"));
+ return section(
+ "Dashboard",
+ "This dashboard's own listen address.",
+ el("div.cfg-rows", row("Listen address", web.listen === "off" ? "Disabled" : web.listen)),
+ );
+}
diff --git a/ui/src/skills/skills.css b/ui/src/skills/skills.css
new file mode 100644
index 000000000..706b63742
--- /dev/null
+++ b/ui/src/skills/skills.css
@@ -0,0 +1,34 @@
+/* Skills-only styles. */
+
+.skill-search {
+ font: inherit;
+ font-size: var(--text-sm);
+ color: var(--fg);
+ background: var(--surface);
+ border: 1px solid var(--border-strong);
+ border-radius: var(--radius-sm);
+ padding: var(--sp-2) var(--sp-3);
+ width: 220px;
+}
+
+.skill-search:focus {
+ outline: 2px solid var(--accent-soft);
+ outline-offset: 1px;
+}
+
+.skill-card {
+ display: flex;
+ flex-direction: column;
+}
+
+.skill-desc {
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+ margin: 0 0 var(--sp-3);
+ flex: 1;
+}
+
+.skill-source {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+}
diff --git a/ui/src/skills/skills.js b/ui/src/skills/skills.js
new file mode 100644
index 000000000..44c3f8a15
--- /dev/null
+++ b/ui/src/skills/skills.js
@@ -0,0 +1,113 @@
+import "./skills.css";
+import { api } from "../base/api.js";
+import { el, empty, mount } from "../base/dom.js";
+
+/**
+ * What Archie can actually do, beyond what is in the source. Backed by
+ * GET /api/skills, which scans .agents/skills//SKILL.md (see
+ * internal/skill.Catalog) and returns each skill's name, plain-language
+ * description, and where it was found.
+ *
+ * This page exists for someone who has never read the source: a search box
+ * over a card grid, and an empty state that explains what a skill is and
+ * how to add one rather than a blank box.
+ */
+export function skillsPage() {
+ const root = el("div");
+ const cardGrid = el("div.grid.grid-2");
+ const searchInput = el("input.skill-search", {
+ type: "search",
+ placeholder: "Search skills…",
+ oninput: (e) => {
+ search = e.target.value.trim().toLowerCase();
+ renderCards();
+ },
+ });
+
+ let skills = [];
+ let search = "";
+ let loadError = null;
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Skills"),
+ el("p.page-sub", "What Archie can do, in plain language."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "Catalogue"), el("p.card-sub", "Discovered from .agents/skills/")),
+ searchInput,
+ ),
+ cardGrid,
+ ),
+ );
+ renderCards();
+ }
+
+ async function load() {
+ try {
+ const res = await api.skills();
+ skills = res?.skills || [];
+ loadError = null;
+ } catch (err) {
+ skills = [];
+ loadError = String(err.message || err);
+ }
+ renderCards();
+ }
+
+ function renderCards() {
+ if (loadError) {
+ return mount(cardGrid, empty("Cannot reach archied", loadError));
+ }
+ if (!skills.length) {
+ return mount(
+ cardGrid,
+ empty(
+ "No skills discovered yet",
+ "Skills live as SKILL.md files under .agents/skills//. Add one, or point skills_dir in config.toml at a shared skills directory, and it will appear here.",
+ ),
+ );
+ }
+
+ const filtered = skills.filter((s) => matches(s, search));
+ if (!filtered.length) {
+ return mount(cardGrid, empty("No skills match", `Nothing found for "${search}".`));
+ }
+
+ mount(cardGrid, ...filtered.map(skillCard));
+ }
+
+ function matches(skill, term) {
+ if (!term) return true;
+ const haystack = `${skill.name} ${skill.description}`.toLowerCase();
+ return haystack.includes(term);
+ }
+
+ function skillCard(skill) {
+ return el(
+ "div.card.skill-card",
+ el(
+ "div.card-head",
+ el("h3.card-title", skill.name || "Untitled skill"),
+ skill.workflow && el("span.pill.pill-info", skill.workflow),
+ ),
+ el("p.skill-desc", skill.description || "No description provided."),
+ el("div.skill-source", skill.source || "Unknown source"),
+ );
+ }
+
+ return root;
+}
diff --git a/ui/src/tasks/tasks.css b/ui/src/tasks/tasks.css
new file mode 100644
index 000000000..0a4de50c5
--- /dev/null
+++ b/ui/src/tasks/tasks.css
@@ -0,0 +1,84 @@
+/* Tasks-only styles. */
+
+.task-filters {
+ display: flex;
+ gap: var(--sp-2);
+ align-items: center;
+}
+
+.task-search,
+.task-filter {
+ font: inherit;
+ font-size: var(--text-sm);
+ color: var(--fg);
+ background: var(--surface);
+ border: 1px solid var(--border-strong);
+ border-radius: var(--radius-sm);
+ padding: var(--sp-2) var(--sp-3);
+}
+
+.task-search {
+ width: 220px;
+}
+
+.task-search:focus,
+.task-filter:focus {
+ outline: 2px solid var(--accent-soft);
+ outline-offset: 1px;
+}
+
+.task-row {
+ cursor: pointer;
+}
+
+.task-timeline-row td {
+ background: var(--bg-raised);
+ padding: var(--sp-4);
+}
+
+.task-timeline-loading {
+ color: var(--fg-muted);
+ font-size: var(--text-sm);
+}
+
+.task-timeline {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-3);
+}
+
+.task-timeline-entry {
+ display: flex;
+ gap: var(--sp-3);
+ align-items: flex-start;
+}
+
+.task-timeline-dot {
+ width: 8px;
+ height: 8px;
+ margin-top: 5px;
+ flex: none;
+ border-radius: 50%;
+ background: var(--accent);
+}
+
+.task-timeline-kind {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--fg);
+}
+
+.task-timeline-detail {
+ font-size: var(--text-xs);
+ color: var(--fg-muted);
+ margin-top: 2px;
+}
+
+.task-timeline-when {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+ margin-top: 2px;
+}
diff --git a/ui/src/tasks/tasks.js b/ui/src/tasks/tasks.js
new file mode 100644
index 000000000..fba810f8e
--- /dev/null
+++ b/ui/src/tasks/tasks.js
@@ -0,0 +1,248 @@
+import "./tasks.css";
+import { api } from "../base/api.js";
+import { ago, el, empty, mount, pill, statusKind } from "../base/dom.js";
+import { statTile } from "../base/statTile.js";
+
+/**
+ * Plain-language status labels. One place, so "waiting_human" only ever
+ * reads as "Waiting for you" wherever a task list is shown.
+ */
+const STATUS_LABELS = {
+ queued: "Queued",
+ running: "Working",
+ waiting_human: "Waiting for you",
+ pr_open: "In review",
+ merged: "Merged",
+ parked: "Parked",
+ dead: "Stopped (too many retries)",
+ rejected: "Rejected",
+ closed_wont_do: "Won't do",
+};
+
+function statusLabel(status) {
+ return STATUS_LABELS[status] || status || "Unknown";
+}
+
+/**
+ * The work board: every task archied knows about, filterable by status and
+ * text, with a per-task event timeline available on click. Task rows carry
+ * carries created_at/updated_at, so age is shown in the list and once
+ * a row's timeline is loaded, sourced from its most recent event.
+ */
+export function tasksPage() {
+ const root = el("div");
+ const summaryRow = el("div.grid.grid-4");
+ const body = el("tbody");
+ const searchInput = el("input.task-search", {
+ type: "search",
+ placeholder: "Search by title or repo…",
+ oninput: (e) => {
+ search = e.target.value.trim().toLowerCase();
+ renderRows();
+ },
+ });
+ const statusSelect = el(
+ "select.task-filter",
+ {
+ onchange: (e) => {
+ filterStatus = e.target.value;
+ renderRows();
+ },
+ },
+ el("option", { value: "" }, "All statuses"),
+ ...Object.entries(STATUS_LABELS).map(([value, label]) => el("option", { value }, label)),
+ );
+
+ let tasks = [];
+ let filterStatus = "";
+ let search = "";
+ let expandedId = null;
+ const eventCache = new Map();
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Tasks"),
+ el("p.page-sub", "Every issue archied has picked up, and where it stands."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ summaryRow,
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "All tasks"), el("p.card-sub", "Click a row for its timeline")),
+ el("div.task-filters", searchInput, statusSelect),
+ ),
+ el(
+ "table.table",
+ el(
+ "thead",
+ el(
+ "tr",
+ ...["Repo", "Issue", "Title", "Status", "Workflow", "Stage", "Last activity"].map((h) => el("th", h)),
+ ),
+ ),
+ body,
+ ),
+ ),
+ );
+ }
+
+ async function load() {
+ try {
+ tasks = await api.tasks();
+ renderSummary();
+ renderRows();
+ } catch (err) {
+ mount(summaryRow, el("div.card", empty("Cannot reach archied", String(err.message || err))));
+ mount(body, el("tr", el("td", { colspan: 7 }, empty("Cannot reach archied", String(err.message || err)))));
+ }
+ }
+
+ function renderSummary() {
+ const total = tasks.length;
+ const counts = {};
+ for (const t of tasks) counts[t.status] = (counts[t.status] || 0) + 1;
+ const working = counts.running || 0;
+ const needsYou = (counts.waiting_human || 0) + (counts.parked || 0);
+ const delivered = (counts.merged || 0) + (counts.pr_open || 0);
+
+ mount(
+ summaryRow,
+ statTile({
+ label: "Total tasks",
+ value: total,
+ compare: total ? "Everything archied has ever picked up" : "No tasks yet",
+ }),
+ statTile({
+ label: "Working now",
+ value: working,
+ compare: total ? `${working} of ${total} in progress` : "Nothing running",
+ }),
+ statTile({
+ label: "Needs you",
+ value: needsYou,
+ compare: needsYou ? "Parked or awaiting a reply" : "Nothing is blocked",
+ goodDirection: "down",
+ }),
+ statTile({
+ label: "Delivered",
+ value: delivered,
+ compare: total ? `${Math.round((delivered / total) * 100)}% of all tasks` : "No tasks yet",
+ }),
+ );
+ }
+
+ function filtered() {
+ return tasks.filter((t) => {
+ if (filterStatus && t.status !== filterStatus) return false;
+ if (!search) return true;
+ const hay = `${t.title} ${t.repo}`.toLowerCase();
+ return hay.includes(search);
+ });
+ }
+
+ function renderRows() {
+ const rows = filtered();
+ if (!tasks.length) {
+ mount(
+ body,
+ el(
+ "tr",
+ el(
+ "td",
+ { colspan: 7 },
+ empty("No tasks yet", "Tasks appear here once archied picks up an issue to work."),
+ ),
+ ),
+ );
+ return;
+ }
+ if (!rows.length) {
+ mount(
+ body,
+ el("tr", el("td", { colspan: 7 }, empty("No matching tasks", "Try a different search or status filter."))),
+ );
+ return;
+ }
+ body.replaceChildren();
+ for (const t of rows) {
+ body.append(taskRow(t));
+ if (expandedId === t.id) body.append(timelineRow(t));
+ }
+ }
+
+ function taskRow(t) {
+ return el(
+ "tr.task-row",
+ {
+ onclick: () => {
+ expandedId = expandedId === t.id ? null : t.id;
+ renderRows();
+ if (expandedId === t.id) loadTimeline(t.id);
+ },
+ },
+ el("td.mono", `${t.owner}/${t.repo}`),
+ el("td.mono", `#${t.issue_number}`),
+ el("td.strong", t.title || "(untitled)"),
+ el("td", pill(statusLabel(t.status), statusKind(t.status))),
+ el("td", t.workflow || "—"),
+ el("td", t.stage || "—"),
+ // updated_at moves on every transition, so this reads as "how long has
+ // it been sitting like this" rather than "how old is the task".
+ el("td", { title: t.created_at ? `Created ${ago(t.created_at)}` : "" }, ago(t.updated_at)),
+ );
+ }
+
+ function timelineRow(t) {
+ const cached = eventCache.get(t.id);
+ return el(
+ "tr.task-timeline-row",
+ el(
+ "td",
+ { colspan: 7 },
+ cached === undefined
+ ? el("div.task-timeline-loading", "Loading timeline…")
+ : cached === null
+ ? empty("Could not load timeline", "archied could not be reached for this task's events.")
+ : cached.length
+ ? el("ul.task-timeline", ...cached.map(timelineEntry))
+ : empty("No events yet", "This task has not recorded any transitions."),
+ ),
+ );
+ }
+
+ function timelineEntry(ev) {
+ return el(
+ "li.task-timeline-entry",
+ el("span.task-timeline-dot"),
+ el(
+ "div",
+ el("div.task-timeline-kind", ev.kind || ev.type || "event"),
+ ev.detail && el("div.task-timeline-detail", ev.detail),
+ el("div.task-timeline-when", ago(ev.at)),
+ ),
+ );
+ }
+
+ async function loadTimeline(id) {
+ try {
+ const events = await api.task(id);
+ eventCache.set(id, events || []);
+ } catch {
+ eventCache.set(id, null);
+ }
+ renderRows();
+ }
+
+ return root;
+}
diff --git a/ui/src/workflows/workflows.css b/ui/src/workflows/workflows.css
new file mode 100644
index 000000000..69181b795
--- /dev/null
+++ b/ui/src/workflows/workflows.css
@@ -0,0 +1,49 @@
+/* Workflows-only styles. */
+
+.wf-stage-card {
+ margin-top: var(--sp-4);
+}
+
+.wf-rate {
+ font-size: var(--text-sm);
+ color: var(--fg);
+ display: flex;
+ align-items: baseline;
+ gap: var(--sp-2);
+}
+
+.wf-rate-sub {
+ font-size: var(--text-xs);
+ color: var(--fg-subtle);
+}
+
+.wf-bar {
+ height: 5px;
+ border-radius: var(--radius-pill);
+ background: var(--border);
+ overflow: hidden;
+ margin-top: var(--sp-2);
+ width: 140px;
+}
+
+.wf-bar-fill {
+ height: 100%;
+ border-radius: var(--radius-pill);
+ transition: width var(--transition);
+}
+
+.wf-bar-ok {
+ background: var(--ok);
+}
+
+.wf-bar-warn {
+ background: var(--warn);
+}
+
+.wf-bar-danger {
+ background: var(--danger);
+}
+
+.wf-bar-info {
+ background: var(--info);
+}
diff --git a/ui/src/workflows/workflows.js b/ui/src/workflows/workflows.js
new file mode 100644
index 000000000..445685530
--- /dev/null
+++ b/ui/src/workflows/workflows.js
@@ -0,0 +1,223 @@
+import "./workflows.css";
+import { api } from "../base/api.js";
+import { el, empty, mount } from "../base/dom.js";
+
+/**
+ * Plain-language workflow names. Falls back to a title-cased version of the
+ * raw identifier for anything not listed here, so a new workflow never
+ * renders blank.
+ */
+const WORKFLOW_LABELS = {
+ bootstrap: "Bootstrap",
+ implement: "Implement",
+ tdd: "TDD",
+ feasibility: "Feasibility check",
+};
+
+function workflowLabel(name) {
+ if (WORKFLOW_LABELS[name]) return WORKFLOW_LABELS[name];
+ if (!name) return "Unknown";
+ return name.charAt(0).toUpperCase() + name.slice(1).replace(/_/g, " ");
+}
+
+function pct(part, whole) {
+ if (!whole) return 0;
+ return Math.round((part / whole) * 100);
+}
+
+function bar(fraction, kind = "ok") {
+ return el(
+ "div.wf-bar",
+ el(`div.wf-bar-fill.wf-bar-${kind}`, { style: `width:${Math.min(100, Math.max(0, fraction))}%` }),
+ );
+}
+
+function formatMs(ms) {
+ if (!ms) return "—";
+ if (ms < 1000) return `${ms} ms`;
+ const secs = ms / 1000;
+ if (secs < 60) return `${secs.toFixed(1)} s`;
+ return `${(secs / 60).toFixed(1)} min`;
+}
+
+/**
+ * How work actually flows: per-workflow outcomes and spend, then per-stage
+ * duration and failure counts -- the "where does it get stuck" view. Both
+ * come from a single /api/workflows call built on the same store queries
+ * that back the dashboard's summary stats.
+ */
+export function workflowsPage() {
+ const root = el("div");
+ const workflowSlot = el("div");
+ const stageSlot = el("div");
+
+ render();
+ load();
+
+ function render() {
+ mount(
+ root,
+ el(
+ "div.page-head",
+ el(
+ "div",
+ el("h1.page-title", "Workflows"),
+ el("p.page-sub", "Run outcomes and spend per workflow, and where stages get stuck."),
+ ),
+ el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
+ ),
+ workflowSlot,
+ stageSlot,
+ );
+ }
+
+ async function load() {
+ try {
+ const data = await api.workflows();
+ renderWorkflows(data?.workflows || []);
+ renderStages(data?.stages || []);
+ } catch (err) {
+ mount(workflowSlot, el("div.card", empty("Cannot reach archied", String(err.message || err))));
+ mount(stageSlot);
+ }
+ }
+
+ function renderWorkflows(workflows) {
+ if (!workflows.length) {
+ mount(
+ workflowSlot,
+ el(
+ "div.card",
+ el("div.card-head", el("div", el("h2.card-title", "Per workflow"))),
+ empty("No workflow runs yet", "Stats appear here once a task has run through a workflow."),
+ ),
+ );
+ return;
+ }
+
+ mount(
+ workflowSlot,
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el(
+ "div",
+ el("h2.card-title", "Per workflow"),
+ el("p.card-sub", "Success rate is merged tasks over all runs"),
+ ),
+ ),
+ el(
+ "table.table",
+ el(
+ "thead",
+ el(
+ "tr",
+ ...["Workflow", "Runs", "Success rate", "Avg tokens", "Avg steps"].map((h) => el("th", h)),
+ ),
+ ),
+ el(
+ "tbody",
+ ...workflows.map((w) => {
+ const rate = pct(w.merged, w.runs);
+ return el(
+ "tr",
+ el("td.strong", workflowLabel(w.workflow)),
+ el("td", `${w.runs} run${w.runs === 1 ? "" : "s"}`),
+ el(
+ "td",
+ el("div.wf-rate", `${rate}%`, el("span.wf-rate-sub", `${w.merged} of ${w.runs} merged`)),
+ bar(rate, rate >= 50 ? "ok" : "warn"),
+ ),
+ el("td.mono", w.avg_tokens ? w.avg_tokens.toLocaleString() : "—"),
+ el("td.mono", w.avg_steps ? w.avg_steps.toFixed(1) : "—"),
+ );
+ }),
+ ),
+ ),
+ ),
+ );
+ }
+
+ function renderStages(stages) {
+ if (!stages.length) {
+ mount(
+ stageSlot,
+ el(
+ "div.card.wf-stage-card",
+ el("div.card-head", el("div", el("h2.card-title", "Per stage"))),
+ empty("No stage data yet", "Stage timing and failures appear here once workflows have run."),
+ ),
+ );
+ return;
+ }
+
+ const maxMs = Math.max(...stages.map((s) => s.avg_ms || 0), 1);
+ const byDuration = [...stages].sort((a, b) => (b.avg_ms || 0) - (a.avg_ms || 0));
+ const byErrors = [...stages].filter((s) => s.errors > 0).sort((a, b) => b.errors - a.errors);
+
+ mount(
+ stageSlot,
+ el(
+ "div.grid.grid-2.wf-stage-card",
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "Slowest stages"), el("p.card-sub", "Average duration, this workflow's stages")),
+ ),
+ el(
+ "table.table",
+ el("thead", el("tr", ...["Workflow", "Stage", "Runs", "Avg duration"].map((h) => el("th", h)))),
+ el(
+ "tbody",
+ ...byDuration.map((s) =>
+ el(
+ "tr",
+ el("td", workflowLabel(s.workflow)),
+ el("td.strong", s.stage),
+ el("td", `${s.runs}`),
+ el(
+ "td",
+ el("div.wf-rate", formatMs(s.avg_ms)),
+ bar(pct(s.avg_ms, maxMs), "info"),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ el(
+ "div.card",
+ el(
+ "div.card-head",
+ el("div", el("h2.card-title", "Most failures"), el("p.card-sub", "Stages that error out, over their runs")),
+ ),
+ byErrors.length
+ ? el(
+ "table.table",
+ el("thead", el("tr", ...["Workflow", "Stage", "Failures"].map((h) => el("th", h)))),
+ el(
+ "tbody",
+ ...byErrors.map((s) =>
+ el(
+ "tr",
+ el("td", workflowLabel(s.workflow)),
+ el("td.strong", s.stage),
+ el(
+ "td",
+ el("div.wf-rate", `${s.errors} of ${s.runs}`),
+ bar(pct(s.errors, s.runs), "danger"),
+ ),
+ ),
+ ),
+ ),
+ )
+ : empty("No failures recorded", "Every stage has completed cleanly so far."),
+ ),
+ ),
+ );
+ }
+
+ return root;
+}
diff --git a/ui/vite.config.js b/ui/vite.config.js
new file mode 100644
index 000000000..851d2ea9a
--- /dev/null
+++ b/ui/vite.config.js
@@ -0,0 +1,28 @@
+import { defineConfig } from "vite";
+
+// The dashboard is served from the archied binary, so the build output is a
+// committed dist/ that ui/embed.go embeds. Hashed asset names are avoided:
+// dist/ lives in git, and hashed filenames would leave a new orphan on every
+// rebuild rather than overwriting the previous one.
+export default defineConfig({
+ base: "./",
+ build: {
+ outDir: "dist",
+ emptyOutDir: true,
+ rollupOptions: {
+ output: {
+ entryFileNames: "assets/[name].js",
+ chunkFileNames: "assets/[name].js",
+ assetFileNames: "assets/[name].[ext]",
+ },
+ },
+ },
+ server: {
+ // `npm run dev` proxies the API to a locally running archied so the
+ // dashboard can be developed without rebuilding the Go binary.
+ proxy: {
+ "/api": "http://127.0.0.1:8484",
+ "/events": { target: "http://127.0.0.1:8484", ws: true },
+ },
+ },
+});