feat(webui): render configuration from a published snapshot
The configuration page had exactly one source: this process's own config.Holder. The UI process has no holder and is not permitted one, so the page was empty there and the shared-holder assumption was the thing blocking the cutover. GET /api/config now reads a ConfigViewSource. The daemon builds the projection from the configuration it owns, as before, and publishes that same document to the State Store on boot and on every republish -- reload, a dashboard edit, a repository field change -- since those are exactly the moments it changes. The UI process renders what it reads there and nothing else; an unknown schema is refused rather than half-rendered, and nothing published yet is the documented empty response, not an error. Editable is a property of the process, not of the configuration, so each source sets it: the daemon holds the update path, the reader does not. The settings page honours it, rendering values where it would otherwise offer controls whose PATCH would answer 503 -- the deliberate feature reduction archie-core-ymut recorded, made visible instead of discovered by clicking. A failed publish is logged and degrades to a stale page. It must never fail the reload or the edit that produced the configuration, both of which have already taken effect.
This commit is contained in:
1 parent
242e51b3e1
commit
5288a8d980
11 files changed
+298
-34
No files matched your search
@@ -1374,7 +1374,7 @@ func (b *boot) setupForgeWebhook() {
|
||||
// PATCH path both go through it, so the two can never diverge.
|
||||
// currentProvenance (an atomic) is the last published provenance chain;
|
||||
// the PATCH path appends the runtime-overlay origin to it.
|
||||
func (b *boot) publishConfig(cfg config.Config, provenance configuration.Provenance) {
|
||||
func (b *boot) publishConfig(ctx context.Context, cfg config.Config, provenance configuration.Provenance) {
|
||||
b.d.Cfg.Set(cfg)
|
||||
origins := make([]webui.ConfigOrigin, 0, len(provenance.Origins))
|
||||
for _, origin := range provenance.Origins {
|
||||
@@ -1383,6 +1383,48 @@ func (b *boot) publishConfig(cfg config.Config, provenance configuration.Provena
|
||||
})
|
||||
}
|
||||
b.web.SetProvenance(origins)
|
||||
b.publishConfigSnapshot(ctx)
|
||||
}
|
||||
|
||||
// publishConfigSnapshot sends the dashboard's projection to the State Store,
|
||||
// where a UI process reads it. This is the only crossing: the configuration
|
||||
// owner publishes what it already renders, and no other process holds the
|
||||
// daemon's config.Holder (archie-core-ymut).
|
||||
//
|
||||
// A failed publish degrades to a stale configuration page and is logged, not
|
||||
// propagated: it must never fail the reload or dashboard write that produced
|
||||
// the new configuration, both of which have already taken effect.
|
||||
func (b *boot) publishConfigSnapshot(ctx context.Context) {
|
||||
snapshots, ok := b.stateStore.(store.ConfigSnapshotStore)
|
||||
if !ok || b.web == nil {
|
||||
return
|
||||
}
|
||||
// Detached from the caller: a dashboard edit's request context is
|
||||
// cancelled the moment the browser has its answer, and the write it
|
||||
// describes has already taken effect either way.
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
view, found, err := b.web.LocalConfigView(ctx)
|
||||
if err != nil || !found {
|
||||
if err != nil {
|
||||
b.log.Warn("config snapshot not published", "err", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
document, err := json.Marshal(view)
|
||||
if err != nil {
|
||||
b.log.Warn("config snapshot not published", "err", err)
|
||||
return
|
||||
}
|
||||
err = snapshots.PutConfigSnapshot(ctx, store.ConfigSnapshot{
|
||||
Schema: webui.ConfigViewSchema,
|
||||
Document: document,
|
||||
PublishedAt: time.Now().UTC(),
|
||||
})
|
||||
if err != nil {
|
||||
b.log.Warn("config snapshot not published", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// wireConfigPublishing installs SIGHUP reload and the reload status
|
||||
@@ -1401,7 +1443,7 @@ func (b *boot) wireConfigPublishing(ctx context.Context, cfgPath, overlayPath st
|
||||
applyModelCatalog(&doc.Config, b.catalog)
|
||||
old := b.d.Cfg.Get()
|
||||
b.currentProvenance.Store(&doc.Provenance)
|
||||
b.publishConfig(doc.Config, doc.Provenance)
|
||||
b.publishConfig(ctx, doc.Config, doc.Provenance)
|
||||
if fields := changedNonReloadableFields(old, doc.Config); len(fields) > 0 {
|
||||
log.Warn("config reloaded; some changes require a restart",
|
||||
"fields", fields, "paths", doc.Provenance.Paths())
|
||||
@@ -1481,7 +1523,7 @@ func (b *boot) installUpdateConfigHandler() {
|
||||
prov := configuration.Provenance{Origins: append(kept,
|
||||
configuration.Origin{Path: "config_overlay (runtime)", Role: configuration.RoleMain, Layer: configuration.LayerOverlay})}
|
||||
b.currentProvenance.Store(&prov)
|
||||
b.publishConfig(next, prov)
|
||||
b.publishConfig(ctx, next, prov)
|
||||
b.bootOverlayErr.Store(nil) // a successful write proves the overlay works again
|
||||
log.Info("config updated from dashboard", "keys", len(updates))
|
||||
return nil
|
||||
@@ -1566,7 +1608,7 @@ func (b *boot) installConfigHandlers(cfgPath, overlayPath string) {
|
||||
}
|
||||
applyModelCatalog(&doc.Config, b.catalog)
|
||||
b.currentProvenance.Store(&doc.Provenance)
|
||||
b.publishConfig(doc.Config, doc.Provenance)
|
||||
b.publishConfig(ctx, doc.Config, doc.Provenance)
|
||||
b.bootOverlayErr.Store(nil)
|
||||
log.Info("config key reset to file value", "key", key)
|
||||
return nil
|
||||
|
||||
@@ -455,6 +455,10 @@ func (b *boot) wireConfigSurfaces(ctx context.Context, cfgPath, overlayPath stri
|
||||
b.installUpdateConfigHandler()
|
||||
b.installUpdateRepoFieldHandler()
|
||||
b.installConfigHandlers(cfgPath, overlayPath)
|
||||
// Publish once at boot. Every later change goes through publishConfig,
|
||||
// which republishes; without this the UI process would render nothing
|
||||
// until the first reload or dashboard edit.
|
||||
b.publishConfigSnapshot(ctx)
|
||||
}
|
||||
|
||||
// bootConfigOverlay layers the runtime config overlay over the resolved
|
||||
|
||||
@@ -30,9 +30,9 @@ type deps struct {
|
||||
// What is deliberately absent, and which bead fills it:
|
||||
//
|
||||
// - Cfg, LastReload, UpdateConfig, ConfigOverrides, ResetConfig,
|
||||
// UpdateRepoField: the configuration owner stays the daemon, reached
|
||||
// through a narrow admin contract. The shared holder is removed from the
|
||||
// daemon's own wiring by archie-core-8cda.5.4.
|
||||
// UpdateRepoField: the configuration owner stays the daemon. The read
|
||||
// crosses as the snapshot ConfigSource renders; the write routes answer
|
||||
// 503 and the page hides their controls (archie-core-ymut).
|
||||
// - LogFeed, TaskLogs, Events, Channels, ReloadChannel, Curators, Memory,
|
||||
// Workflows, WorkRequests, RunningVersions, Chat.Updates,
|
||||
// UpdateReportPath: no contract exists for these yet.
|
||||
@@ -52,6 +52,9 @@ func compose(d deps) *webui.Server {
|
||||
TrustForwardedHeaders: d.Options.trustForwardedHeaders(),
|
||||
Health: d.Health,
|
||||
}
|
||||
if snapshots, ok := d.Store.(store.ConfigSnapshotStore); ok {
|
||||
srv.ConfigSource = webui.RemoteConfigView(snapshots)
|
||||
}
|
||||
if d.Chat != nil {
|
||||
srv.Chat = &webui.ChatService{Contract: d.Chat}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||
"github.com/samcharles93/archie-core/internal/webui"
|
||||
)
|
||||
|
||||
// fakeChat is a minimal gateway.ChatContract standing in for the standalone
|
||||
@@ -101,9 +102,23 @@ func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||
if _, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "remote summary", "body", "implement", ""); err != nil {
|
||||
t.Fatalf("seed task: %v", err)
|
||||
}
|
||||
// The daemon publishes the configuration page's projection; this process
|
||||
// only renders it (archie-core-ymut).
|
||||
published, err := json.Marshal(webui.ConfigView{
|
||||
Identity: webui.IdentityView{BotUser: "archie", ForgeType: "github"},
|
||||
Editable: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := st.PutConfigSnapshot(t.Context(), store.ConfigSnapshot{
|
||||
Schema: webui.ConfigViewSchema, Document: published,
|
||||
}); err != nil {
|
||||
t.Fatalf("publish config snapshot: %v", err)
|
||||
}
|
||||
|
||||
stateTarget, stopState := serveGRPC(t, func(r grpc.ServiceRegistrar) {
|
||||
staterpc.RegisterServer(r, staterpc.Deps{Tasks: st, Log: slog.New(slog.DiscardHandler)})
|
||||
staterpc.RegisterServer(r, staterpc.Deps{Tasks: st, ConfigSnapshots: st, Log: slog.New(slog.DiscardHandler)})
|
||||
})
|
||||
defer stopState()
|
||||
chat := &fakeChat{sessions: []gateway.SessionContext{
|
||||
@@ -195,9 +210,21 @@ func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||
t.Fatalf("chat sessions = %s, want the single web session from the remote contract", body)
|
||||
}
|
||||
|
||||
// No shared config.Holder: the read is empty and there is no second writer.
|
||||
if code, body := get("/api/config"); code != http.StatusOK || string(body) != "{}\n" {
|
||||
t.Errorf("GET /api/config = %d %q, want 200 {}", code, body)
|
||||
// No shared config.Holder: the page renders the snapshot the daemon
|
||||
// published, and this process is not a second writer.
|
||||
code, body = get("/api/config")
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("GET /api/config = %d (%s), want 200", code, body)
|
||||
}
|
||||
var rendered webui.ConfigView
|
||||
if err := json.Unmarshal(body, &rendered); err != nil {
|
||||
t.Fatalf("decode config view: %v", err)
|
||||
}
|
||||
if rendered.Identity.BotUser != "archie" {
|
||||
t.Fatalf("config view = %s, want the published projection", body)
|
||||
}
|
||||
if rendered.Editable {
|
||||
t.Error("the UI process rendered configuration as editable; it has no write path")
|
||||
}
|
||||
req, err := http.NewRequestWithContext(t.Context(), http.MethodPatch, ts.URL+"/api/config", http.NoBody)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package webui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -12,6 +14,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
)
|
||||
|
||||
// Sentinel errors for handleConfigUpdate status classification. The
|
||||
@@ -225,6 +228,11 @@ type ConfigView struct {
|
||||
// runtime overlay, so the UI can mark those rows (their file value
|
||||
// is shadowed until reset) and offer a per-row reset.
|
||||
Overridden []string `json:"overridden,omitempty"`
|
||||
// Editable reports whether this process can apply configuration
|
||||
// changes. False makes the page render values without edit controls,
|
||||
// which is what a process that only displays a published snapshot can
|
||||
// honestly offer -- its write routes answer 503.
|
||||
Editable bool `json:"editable"`
|
||||
// Schema is the field-descriptor catalog (archie-core-b6ew) attached to
|
||||
// this view's own values, locked reasons, and overridden markers -- see
|
||||
// config_schema.go. The dashboard's generic renderer (archie-core-b6ew.3)
|
||||
@@ -316,15 +324,50 @@ type WebView struct {
|
||||
// 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.
|
||||
// ConfigViewSchema names the projection's shape. It travels with a published
|
||||
// snapshot so a reader can refuse a document it does not understand, and it
|
||||
// changes when ConfigView's JSON shape changes incompatibly.
|
||||
const ConfigViewSchema = "webui.ConfigView/1"
|
||||
|
||||
// ConfigViewSource supplies the configuration projection the page renders.
|
||||
// The process that owns configuration builds it; a process that only displays
|
||||
// configuration reads the published snapshot instead. found is false when no
|
||||
// configuration is available to render, which the handler answers with an
|
||||
// empty object rather than an error.
|
||||
type ConfigViewSource func(ctx context.Context) (ConfigView, bool, error)
|
||||
|
||||
func (s *Server) configSource() ConfigViewSource {
|
||||
if s.ConfigSource != nil {
|
||||
return s.ConfigSource
|
||||
}
|
||||
return s.LocalConfigView
|
||||
}
|
||||
|
||||
func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
if s.Cfg == nil {
|
||||
view, found, err := s.configSource()(r.Context())
|
||||
if err != nil {
|
||||
s.logf("config view unavailable", "err", err)
|
||||
http.Error(w, "configuration is unavailable", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
if !found {
|
||||
writeJSON(w, map[string]any{})
|
||||
return
|
||||
}
|
||||
// cfg := s.Cfg was a shared-pointer copy that aliased the live
|
||||
// config. Under the Holder it becomes a value snapshot, which is
|
||||
// what the read-only view always wanted -- every ConfigView field
|
||||
// is read from this local.
|
||||
writeJSON(w, view)
|
||||
}
|
||||
|
||||
// LocalConfigView builds the projection from the configuration this process
|
||||
// holds. It is what the daemon serves and, byte for byte, what it publishes
|
||||
// for the UI process to render (see store.ConfigSnapshot).
|
||||
//
|
||||
// Every value here is read from one config snapshot taken up front: under the
|
||||
// Holder a reload swaps the whole value, which is what a read-only view
|
||||
// always wanted.
|
||||
func (s *Server) LocalConfigView(ctx context.Context) (ConfigView, bool, error) {
|
||||
if s.Cfg == nil {
|
||||
return ConfigView{}, false, nil
|
||||
}
|
||||
cfg := s.Cfg.Get()
|
||||
|
||||
var provenance []ConfigOrigin
|
||||
@@ -370,9 +413,14 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
},
|
||||
Provenance: provenance,
|
||||
Locked: lockedConfigKeys(),
|
||||
// Editable is a property of this process, not of the
|
||||
// configuration, so it is set by the source rather than carried
|
||||
// in a published document: the writer is whoever holds the
|
||||
// update path.
|
||||
Editable: s.UpdateConfig != nil,
|
||||
}
|
||||
if s.ConfigOverrides != nil {
|
||||
if overridden, err := s.ConfigOverrides(r.Context()); err == nil {
|
||||
if overridden, err := s.ConfigOverrides(ctx); err == nil {
|
||||
view.Overridden = overridden
|
||||
}
|
||||
// A failed read omits the list rather than failing the whole
|
||||
@@ -383,8 +431,28 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
view.Reload = &rs
|
||||
}
|
||||
view.Schema = buildConfigSchema(view)
|
||||
return view, true, nil
|
||||
}
|
||||
|
||||
writeJSON(w, view)
|
||||
// RemoteConfigView reads the projection the configuration owner published.
|
||||
// The reading process cannot edit it: it has no update path, and the page is
|
||||
// told so rather than offering a control that would 503.
|
||||
func RemoteConfigView(snapshots store.ConfigSnapshotStore) ConfigViewSource {
|
||||
return func(ctx context.Context) (ConfigView, bool, error) {
|
||||
snapshot, found, err := snapshots.ConfigSnapshot(ctx)
|
||||
if err != nil || !found {
|
||||
return ConfigView{}, false, err
|
||||
}
|
||||
if snapshot.Schema != ConfigViewSchema {
|
||||
return ConfigView{}, false, fmt.Errorf("webui: published config snapshot has schema %q, want %q", snapshot.Schema, ConfigViewSchema)
|
||||
}
|
||||
var view ConfigView
|
||||
if err := json.Unmarshal(snapshot.Document, &view); err != nil {
|
||||
return ConfigView{}, false, fmt.Errorf("webui: decode published config snapshot: %w", err)
|
||||
}
|
||||
view.Editable = false
|
||||
return view, true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// handleConfigReset deletes one runtime-overlay row via ResetConfig,
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/channels"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
)
|
||||
|
||||
// fakeSecrets are recognisable strings that must never appear anywhere in
|
||||
@@ -610,3 +611,77 @@ func TestHandleChannelsUsesRuntimeManager(t *testing.T) {
|
||||
t.Fatalf("channels = %#v", got.Channels)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRemoteConfigViewRendersThePublishedSnapshot: the UI process has no
|
||||
// configuration of its own, so the page it serves is whatever the owner
|
||||
// published -- and it must never claim to be editable, because this process
|
||||
// has no write path and its PATCH routes answer 503.
|
||||
func TestRemoteConfigViewRendersThePublishedSnapshot(t *testing.T) {
|
||||
published := ConfigView{
|
||||
Identity: IdentityView{BotUser: "archie", ForgeType: "github"},
|
||||
Models: map[string]string{"chat": "anthropic/claude"},
|
||||
Providers: map[string]ProviderView{"anthropic": {APIKeyEnv: "ANTHROPIC_API_KEY", Configured: true}},
|
||||
Editable: true, // the daemon's own view; publishing must not carry it
|
||||
Provenance: []ConfigOrigin{{Path: "/etc/archie/config.toml", Role: "main"}},
|
||||
}
|
||||
document, err := json.Marshal(published)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := RemoteConfigView(stubSnapshots{snapshot: store.ConfigSnapshot{
|
||||
Schema: ConfigViewSchema,
|
||||
Document: document,
|
||||
}, found: true})
|
||||
|
||||
view, found, err := source(t.Context())
|
||||
if err != nil || !found {
|
||||
t.Fatalf("RemoteConfigView = (found %v, %v), want the published snapshot", found, err)
|
||||
}
|
||||
if view.Identity.BotUser != "archie" || view.Providers["anthropic"].APIKeyEnv != "ANTHROPIC_API_KEY" {
|
||||
t.Fatalf("view = %+v, want the published values", view)
|
||||
}
|
||||
if view.Editable {
|
||||
t.Error("a rendered snapshot claims to be editable; this process has no write path")
|
||||
}
|
||||
}
|
||||
|
||||
// TestRemoteConfigViewRefusesAnUnknownSchema: a document whose shape this
|
||||
// build does not know is not something to render half of.
|
||||
func TestRemoteConfigViewRefusesAnUnknownSchema(t *testing.T) {
|
||||
source := RemoteConfigView(stubSnapshots{snapshot: store.ConfigSnapshot{
|
||||
Schema: "webui.ConfigView/99",
|
||||
Document: []byte(`{}`),
|
||||
}, found: true})
|
||||
|
||||
if _, found, err := source(t.Context()); err == nil || found {
|
||||
t.Fatalf("unknown schema = (found %v, %v), want an error", found, err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestConfigWithNoPublishedSnapshotIsEmpty: before the owner has published
|
||||
// anything the page has nothing to show, which is the documented degraded
|
||||
// response, not a failure.
|
||||
func TestConfigWithNoPublishedSnapshotIsEmpty(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
srv.ConfigSource = RemoteConfigView(stubSnapshots{})
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
|
||||
res := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(res, req)
|
||||
|
||||
if res.Code != http.StatusOK || strings.TrimSpace(res.Body.String()) != "{}" {
|
||||
t.Fatalf("GET /api/config = %d %q, want 200 {}", res.Code, res.Body)
|
||||
}
|
||||
}
|
||||
|
||||
type stubSnapshots struct {
|
||||
snapshot store.ConfigSnapshot
|
||||
found bool
|
||||
err error
|
||||
}
|
||||
|
||||
func (s stubSnapshots) PutConfigSnapshot(context.Context, store.ConfigSnapshot) error { return s.err }
|
||||
|
||||
func (s stubSnapshots) ConfigSnapshot(context.Context) (store.ConfigSnapshot, bool, error) {
|
||||
return s.snapshot, s.found, s.err
|
||||
}
|
||||
@@ -47,6 +47,12 @@ type Server struct {
|
||||
// materialised config, persist, then Set.
|
||||
Cfg *config.Holder
|
||||
|
||||
// ConfigSource supplies the configuration projection GET /api/config
|
||||
// renders. Composition sets it to RemoteConfigView in a process that
|
||||
// only displays configuration; unset means this process builds the view
|
||||
// from the configuration it holds (LocalConfigView).
|
||||
ConfigSource ConfigViewSource
|
||||
|
||||
// Workflows is the executable registry snapshot supplied by composition.
|
||||
Workflows []workflow.Definition
|
||||
// WorkRequests admits dashboard requests through the same task-creation
|
||||
|
||||
Vendored
+1
-1
@@ -1 +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);font-weight:500}.nav-item .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)}.mobile-search-toggle{display:none}.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(--accenLine truncated
|
||||
: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);font-weight:500}.nav-item .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)}.mobile-search-toggle{display:none}.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(--accenLine truncated
|
||||
Vendored
+7
-7
@@ -1,16 +1,16 @@
|
||||
(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)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),te(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,re(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=te(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ie(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ee(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),L(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ee(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function M(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||M(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||M(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function P(e){return function(n){if(this.l){var rLine truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var B=class extends Error{constructor(e,t){super(e),this.status=t}},V={summary:()=>R(`/api/summary`),tasks:()=>R(`/api/tasks`),taskMeta:()=>R(`/api/task-meta`),task:e=>R(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},setup:()=>R(`/api/setup`),workflows:()=>R(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},skills:()=>R(`/api/skills`),channels:()=>R(`/api/channels`),curators:()=>R(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},config:()=>R(`/api/config`),version:()=>R(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,r)=>{let i=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:r}),signal:AbortSignal.timeout(15e3)});if(!i.ok)throw new B(await z(i),i.status);return i.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},logs:e=>R(`/api/logs`+ce(e)),taskLogs:(e,t)=>R(`/api/tasks/${e}/logs`+ce(t)),captures:e=>R(`/api/captures`+ce({limit:e})),mappings:()=>R(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindings:()=>R(`/api/bindings`),bindingCreate:async e=>{let t=await fetch(`/api/bindings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},bindingUpdate:async(e,t)=>{let n=await fetch(`/api/bindings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindingDelete:async e=>{let t=await fetch(`/api/bindings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},bindingApprove:async e=>{let t=await fetch(`/api/bindings/${e}/approve`,{method:`POST`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},memory:()=>R(`/api/memory`),chatSessions:()=>R(`/api/chat/sessions`),chatMessages:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(1
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var B=class extends Error{constructor(e,t){super(e),this.status=t}};function le(e){let t=e instanceof B?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}var V={summary:()=>R(`/api/summary`),tasks:()=>R(`/api/tasks`),taskMeta:()=>R(`/api/task-meta`),task:e=>R(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},setup:()=>R(`/api/setup`),workflows:()=>R(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},skills:()=>R(`/api/skills`),channels:()=>R(`/api/channels`),curators:()=>R(`/api/curators`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},config:()=>R(`/api/config`),version:()=>R(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},configRepoUpdate:async(e,t,n,r)=>{let i=await fetch(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({field:n,value:r}),signal:AbortSignal.timeout(15e3)});if(!i.ok)throw new B(await z(i),i.status);return i.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},logs:e=>R(`/api/logs`+ce(e)),taskLogs:(e,t)=>R(`/api/tasks/${e}/logs`+ce(t)),captures:e=>R(`/api/captures`+ce({limit:e})),mappings:()=>R(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindings:()=>R(`/api/bindings`),bindingCreate:async e=>{let t=await fetch(`/api/bindings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},bindingUpdate:async(e,t)=>{let n=await fetch(`/api/bindings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new B(await z(n),n.status);return n.json()},bindingDelete:async e=>{let t=await fetch(`/api/bindings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status)},bindingApprove:async e=>{let t=await fetch(`/api/bindings/${e}/approve`,{method:`POST`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new B(await z(t),t.status);return t.json()},memory:()=>R(`/api/memory`),chatSessions:()=>R(`/api/chat/sessions`),chatMessages:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>R(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chat
Line truncated
|
||||
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
||||
stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
||||
stroke-width="12" stroke-linecap="round"
|
||||
stroke-dasharray="${s}"
|
||||
stroke-dashoffset="${s*(1-r/100)}"
|
||||
class="gauge-value"/>`,H(`div.gauge-wrap`,l,H(`div.gauge-center`,H(`div.gauge-pct`,`${Math.round(r)}%`),H(`div.gauge-label`,t)))}function Ye(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return H(`div`,H(`div.segbar`,...e.filter(e=>e.value>0).map(e=>H(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),H(`div.segbar-legend`,...e.map(e=>H(`span.segbar-key`,H(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Xe=0;Array.isArray;function Z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xe,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function Q({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}var Ze=`archie.setup-complete.dismissed.v1`;function Qe(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(Ze),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function $e(e=globalThis.localStorage){e?.setItem?.(Ze,`1`)}var et=new Set([`waiting_human`,`parked`]);function tt(e=[]){let t=e.filter(e=>et.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function nt({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function rt(e){return Z(nt,{node:Ke(e)})}function it(e){return Z(nt,{node:Je(e)})}function at({segments:e}){return Z(nt,{node:Ye(e)})}function ot({name:e,opts:t}){return Z(nt,{node:G(e,t)})}function st({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ct(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function lt(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function ut(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}function dt(){let[e,t]=J([]),[n,r]=J(`connecting`),[i,a]=J(`idle`),[o,s]=J(new Map),[c,l]=J(null),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[,v]=J(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([V.summary(),V.setup().catch(()=>null),V.workflows().catch(()=>null),V.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};Y(()=>(y(),le(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{$e(),v(e=>!e)},x=u?.operator?`${lt()}, ${u.operator}`:lt(),C=null;if(g)C=Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=tt(m),t=e.attention.count,n=e.running.count;C=Z(S,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ot,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ot,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ot,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=Z(`div`,{className:`card`,children:Z(st,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=Z(S,{children:[Z(rt,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(rt,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(rt,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(rt,{label:`Tokens used`,value:Ce(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:ut(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=Qe(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,children
Line truncated
|
||||
`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(Q,{text:sn[e.status]||e.status,kind:cn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function un({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function dn({origins:e}){return e?.length?Z(un,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z(nn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z(un,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z($,{title:`Source provenance is unavailable.`})})}function fn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function pn({data:e,error:t}){if(t)return Z(un,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z(un,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??_e(e.id),n=e.kind??ve(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(Q,{text:t,kind:n})})]},e.id)})}):Z($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=fn(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function mn({r:e,field:t,onSaved:n}){let[r,i]=J(!1),[a,o]=J(null),[s,c]=J(!!e[t]);return Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:s,onChange:async r=>{let a=r.target.checked;c(a),i(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,a),n?.()}catch(e){c(!a),o(String(e.message||e))}finally{i(!1)}},disabled:r}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function hn({r:e,field:t,onSaved:n}){let[r,i]=J(String(e[t]??0)),[a,o]=J(null),[s,c]=J(!1);return Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){o(`Enter a whole number`);return}c(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){o(String(e.message||e))}finally{c(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:s}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function gn({repos:e,onSaved:t}){if(!e?.length)return Z(un,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z(un,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,r)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:n(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(mn,{r:e,field:`allow_concurrent`,onSaved:t}),Z(hn,{r:e,field:`max_retries`,onSaved:t}),Z(mn,{r:e,field:`review_enabled`,onSaved:t})]},r
Line truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(H(`p`,sr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(H(`pre`,H(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=lr(c),u=e+1<n.length?lr(n[e+1]):null;if(l&&u&&ur(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=lr(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=H(`tbody`);for(let e of r)i.append(H(`tr`,...e.map(e=>H(`td`,sr(e)))));t.append(H(`table`,H(`thead`,H(`tr`,...l.map(e=>H(`th`,sr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(H(`h${d[1].length}`,sr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=H(e)),i.append(H(`li`,sr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(H(`blockquote`,sr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(H(`pre`,H(`code`,a.join(`
|
||||
`)))),t}function lr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function ur(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var dr=`archie.web.chat.channel`;function fr(){let e=localStorage.getItem(dr);return e||(e=se(),localStorage.setItem(dr,e)),e}function pr(e){return{text:e,sourceID:se()}}function mr(e){return{...e}}function hr(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?mr(e.turn):pr(r),isRetry:n}}function gr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function _r(e){return e?.status===501?null:`Could not check for updates.`}function vr(){return location.hash.slice(1)||`/`}function yr({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(cr(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function br(){let[e,t]=J([]),[n,r]=J(``),[i,a]=J([]),[o,s]=J(``),[c,l]=J(`Ready`),[u,d]=J(!1),[f,p]=J({}),[m,h]=J(``),[g,_]=J(``),[v,y]=J(``),[b,x]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,ee]=J(null),[M,N]=J(null),[P,te]=J(``),[ne,re]=J(``),[F,I]=J(null),ie=X(null),L=X(null),ae=X(null),oe=X(null),se=X(null),R=X(u);R.current=u,Y(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[i,F]),Y(()=>{fe().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ae.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ae.current?.abort()}},[]);async function ce(){try{let e=await V.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=_r(e);A(t?{error:t}:null)}}async function z(){if(j)try{await V.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function B(){if(j)try{l(`Installing…`);let e=await V.chatUpdateInstall(j);ee(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function le(){try{let e=await V.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function ue(e,t){if(t)try{await V.chatDangerousRequest(e,t),l(`Approval requested`),await le()}catch(e){l(e.message||`Could not request action`)}}async function de(e,t){try{await V.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await le()}catch(e){l(e.message||`Approval failed`)}}async function fe(){let e=await V.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await le(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await V.chatMessage(fr(),`/resume ${e}`);let[t,n]=await Promise.all([V.chatMessages(e),V.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function me(e){if(n)try{l(`Working…`);let t=await V.chatMessage(fr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await fe(),(t.session_id||n)&&await pe(t.session_id||n),oe.current&&(oe.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&V.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function _e(e){let t=e.target.value;if(_(t),t)try{let e=await V.chatMessage(fr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await fe()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await V.chatMessage(fr(),`/model ${t}`);l(e.reply||`Model updated`),await fe()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),U({textOverride:`/restart`}))}function be(){s(`/new`),U({textOverride:`/new`})}function xe(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function H(e){let t=C[e];if(!t||!L.current)return;let n=L.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.s
Line truncated
|
||||
class="gauge-value"/>`,H(`div.gauge-wrap`,l,H(`div.gauge-center`,H(`div.gauge-pct`,`${Math.round(r)}%`),H(`div.gauge-label`,t)))}function Ze(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return H(`div`,H(`div.segbar`,...e.filter(e=>e.value>0).map(e=>H(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),H(`div.segbar-legend`,...e.map(e=>H(`span.segbar-key`,H(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Qe=0;Array.isArray;function X(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Qe,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function Z({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}var $e=`archie.setup-complete.dismissed.v1`;function et(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.($e),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function tt(e=globalThis.localStorage){e?.setItem?.($e,`1`)}var nt=new Set([`waiting_human`,`parked`]);function rt(e=[]){let t=e.filter(e=>nt.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function it({node:e}){let t=Y();return J(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function at(e){return X(it,{node:Je(e)})}function ot(e){return X(it,{node:Xe(e)})}function st({segments:e}){return X(it,{node:Ze(e)})}function ct({name:e,opts:t}){return X(it,{node:W(e,t)})}function lt({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function ut(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function dt(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function ft(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}function pt(){let[e,t]=q([]),[n,r]=q(`connecting`),[i,a]=q(`idle`),[o,s]=q(new Map),[c,l]=q(null),[u,d]=q(null),[f,p]=q(null),[m,h]=q(null),[g,_]=q(null),[,v]=q(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([V.summary(),V.setup().catch(()=>null),V.workflows().catch(()=>null),V.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};J(()=>(y(),ue(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{tt(),v(e=>!e)},x=u?.operator?`${dt()}, ${u.operator}`:dt(),C=null;if(g)C=X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(ct,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=rt(m),t=e.attention.count,n=e.running.count;C=X(S,{children:[t>0&&X(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[X(ct,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&X(`a`,{className:`btn`,href:e.running.href,children:[X(ct,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),X(`a`,{className:`btn`,href:`#/logs`,children:[X(ct,{name:`logs`,opts:{size:15}}),` Logs`]}),X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(ct,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=X(`div`,{className:`card`,children:X(lt,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=X(S,{children:[X(at,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),X(at,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(at,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),X(at,{label:`Tokens used`,value:Te(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:ft(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=et(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=X(`div`,{className:`card setup`,children:[X(`div`,{className:`card-head`,children
Line truncated
|
||||
`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Z,{text:un[e.status]||e.status,kind:dn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function Q({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function pn({origins:e}){return e?.length?X($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(on,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X(Q,{title:`Source provenance is unavailable.`})})}function mn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function hn({data:e,error:t}){if(t)return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??ve(e.id),n=e.kind??ye(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Z,{text:t,kind:n})})]},e.id)})}):X(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=mn(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function gn({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=q(!1),[o,s]=q(null),[c,l]=q(!!e[t]);return r?X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await V.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function _n({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=q(String(e[t]??0)),[o,s]=q(null),[c,l]=q(!1);return r?X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await V.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function vn({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X($,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(gn,{r:e,field:`allow_concuLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(H(`p`,lr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(H(`pre`,H(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=dr(c),u=e+1<n.length?dr(n[e+1]):null;if(l&&u&&fr(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=dr(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=H(`tbody`);for(let e of r)i.append(H(`tr`,...e.map(e=>H(`td`,lr(e)))));t.append(H(`table`,H(`thead`,H(`tr`,...l.map(e=>H(`th`,lr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(H(`h${d[1].length}`,lr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=H(e)),i.append(H(`li`,lr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(H(`blockquote`,lr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(H(`pre`,H(`code`,a.join(`
|
||||
`)))),t}function dr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function fr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var pr=`archie.web.chat.channel`;function mr(){let e=localStorage.getItem(pr);return e||(e=se(),localStorage.setItem(pr,e)),e}function hr(e){return{text:e,sourceID:se()}}function gr(e){return{...e}}function _r(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?gr(e.turn):hr(r),isRetry:n}}function vr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function yr(e){return e?.status===501?null:`Could not check for updates.`}function br(){return location.hash.slice(1)||`/`}function xr({text:e}){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(ur(e||``))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function Sr(){let[e,t]=q([]),[n,r]=q(``),[i,a]=q([]),[o,s]=q(``),[c,l]=q(`Ready`),[u,d]=q(!1),[f,p]=q({}),[m,h]=q(``),[g,_]=q(``),[v,y]=q(``),[b,x]=q([]),[C,w]=q([]),[T,E]=q(0),[D,O]=q(!1),[k,A]=q(null),[j,ee]=q(null),[M,N]=q(null),[P,te]=q(``),[ne,re]=q(``),[F,I]=q(null),ie=Y(null),L=Y(null),ae=Y(null),oe=Y(null),se=Y(null),R=Y(u);R.current=u,J(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[i,F]),J(()=>{fe().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ae.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ae.current?.abort()}},[]);async function ce(){try{let e=await V.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=yr(e);A(t?{error:t}:null)}}async function z(){if(j)try{await V.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function B(){if(j)try{l(`Installing…`);let e=await V.chatUpdateInstall(j);ee(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function le(){try{let e=await V.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function ue(e,t){if(t)try{await V.chatDangerousRequest(e,t),l(`Approval requested`),await le()}catch(e){l(e.message||`Could not request action`)}}async function de(e,t){try{await V.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await le()}catch(e){l(e.message||`Approval failed`)}}async function fe(){let e=await V.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await le(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await V.chatMessage(mr(),`/resume ${e}`);let[t,n]=await Promise.all([V.chatMessages(e),V.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function me(e){if(n)try{l(`Working…`);let t=await V.chatMessage(mr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await fe(),(t.session_id||n)&&await pe(t.session_id||n),oe.current&&(oe.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&V.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function _e(e){let t=e.target.value;if(_(t),t)try{let e=await V.chatMessage(mr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await fe()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await V.chatMessage(mr(),`/model ${t}`);l(e.reply||`Model updated`),await fe()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),Ce({textOverride:`/restart`}))}function be(){s(`/new`),Ce({textOverride:`/new`})}function xe(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function Se(e){let t=C[e];if(!t||!L.current)return;let n=L.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=
Line truncated
|
||||
|
||||
`);s=i.pop()||``;for(let e of i){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await fe()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:mr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ae.current=null,d(!1),L.current&&L.current.focus()}}function W(){l(`Stopping…`),n&&V.chatCancel(n).catch(()=>{}),ae.current?.abort()}let Ce=f.models_by_provider||{},we=g&&Ce[g]?Ce[g]:f.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:c}),f.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[Z(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[Z(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[Z(`option`,{value:``,children:`Model`}),we.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(S,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:z,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:B,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`rollback`,P),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`stop`,ne),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[Z(`strong`,{children:gr(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations wiLine truncated
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await fe()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:gr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ae.current=null,d(!1),L.current&&L.current.focus()}}function we(){l(`Stopping…`),n&&V.chatCancel(n).catch(()=>{}),ae.current?.abort()}let U=f.models_by_provider||{},Te=g&&U[g]?U[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[X(`option`,{value:``,children:`Model`}),Te.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:z,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:B,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`rollback`,P),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`stop`,ne),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[X(`strong`,{children:vr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations willLine truncated
|
||||
@@ -105,7 +105,7 @@ function LifecycleCard({ data, error }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RepoBoolCell({ r, field, onSaved }) {
|
||||
function RepoBoolCell({ r, field, onSaved, editable = true }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState(null);
|
||||
const [checked, setChecked] = useState(!!r[field]);
|
||||
@@ -126,6 +126,10 @@ function RepoBoolCell({ r, field, onSaved }) {
|
||||
}
|
||||
};
|
||||
|
||||
if (!editable) {
|
||||
return <td>{checked ? "yes" : "no"}</td>;
|
||||
}
|
||||
|
||||
return (
|
||||
<td>
|
||||
<input className="repo-field-checkbox" type="checkbox" checked={checked} onChange={handleChange} disabled={loading} />
|
||||
@@ -134,7 +138,7 @@ function RepoBoolCell({ r, field, onSaved }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RepoIntCell({ r, field, onSaved }) {
|
||||
function RepoIntCell({ r, field, onSaved, editable = true }) {
|
||||
const [val, setVal] = useState(String(r[field] ?? 0));
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -164,6 +168,10 @@ function RepoIntCell({ r, field, onSaved }) {
|
||||
}
|
||||
};
|
||||
|
||||
if (!editable) {
|
||||
return <td className="mono">{val}</td>;
|
||||
}
|
||||
|
||||
return (
|
||||
<td>
|
||||
<input
|
||||
@@ -180,7 +188,10 @@ function RepoIntCell({ r, field, onSaved }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RepositoriesCard({ repos, onSaved }) {
|
||||
// editable is false in a process that only renders a published
|
||||
// configuration snapshot: its PATCH routes answer 503, so the cells are
|
||||
// values rather than controls (archie-core-ymut).
|
||||
export function RepositoriesCard({ repos, onSaved, editable = true }) {
|
||||
if (!repos?.length) {
|
||||
return (
|
||||
<Section title="Repositories" sub="The repositories Archie polls for work.">
|
||||
@@ -211,9 +222,9 @@ function RepositoriesCard({ repos, onSaved }) {
|
||||
<td>{r.ecosystem || "go"}</td>
|
||||
<td className="mono">{gateSummary(r.gate)}</td>
|
||||
<td className="mono">{r.protect?.length ? r.protect.join(", ") : "—"}</td>
|
||||
<RepoBoolCell r={r} field="allow_concurrent" onSaved={onSaved} />
|
||||
<RepoIntCell r={r} field="max_retries" onSaved={onSaved} />
|
||||
<RepoBoolCell r={r} field="review_enabled" onSaved={onSaved} />
|
||||
<RepoBoolCell r={r} field="allow_concurrent" onSaved={onSaved} editable={editable} />
|
||||
<RepoIntCell r={r} field="max_retries" onSaved={onSaved} editable={editable} />
|
||||
<RepoBoolCell r={r} field="review_enabled" onSaved={onSaved} editable={editable} />
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -387,7 +398,7 @@ function SettingsApp() {
|
||||
options: f.options,
|
||||
raw: f.value,
|
||||
hint: f.description,
|
||||
editable: f.editable,
|
||||
editable: f.editable && cfg.editable !== false,
|
||||
locked: cfg.locked || {},
|
||||
overridden: cfg.overridden || [],
|
||||
onSaved: loadCfg
|
||||
@@ -399,7 +410,7 @@ function SettingsApp() {
|
||||
);
|
||||
})}
|
||||
|
||||
<RepositoriesCard repos={cfg.repositories} onSaved={loadCfg} />
|
||||
<RepositoriesCard repos={cfg.repositories} onSaved={loadCfg} editable={cfg.editable !== false} />
|
||||
<ModelsAndProvidersCard models={cfg.models} providers={cfg.providers} />
|
||||
<ProvenanceCard origins={cfg.provenance} />
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup } from "@testing-library/preact";
|
||||
import { RepositoriesCard } from "../src/settings/settings.jsx";
|
||||
|
||||
const repos = [
|
||||
{ owner: "acme", name: "widget", base: "main", allow_concurrent: true, max_retries: 3, review_enabled: false },
|
||||
];
|
||||
|
||||
// A process that renders a published configuration snapshot has no write
|
||||
// path: its PATCH routes answer 503. Offering a checkbox that fails on click
|
||||
// is worse than not offering one (archie-core-ymut).
|
||||
test("read-only repositories render values, not controls", () => {
|
||||
const { container, unmount } = render(<RepositoriesCard repos={repos} editable={false} />);
|
||||
assert.equal(container.querySelectorAll("input").length, 0, "a read-only page must render no repository inputs");
|
||||
const row = container.querySelector("tbody tr");
|
||||
assert.match(row.textContent, /acme\/widget/);
|
||||
assert.match(row.textContent, /3/, "the value itself is still shown");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("editable repositories keep their controls", () => {
|
||||
const { container, unmount } = render(<RepositoriesCard repos={repos} editable={true} />);
|
||||
assert.ok(container.querySelectorAll("input").length > 0, "the owning process still edits repository fields");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("cleanup", () => cleanup());
|
||||
Reference in new issue
Block a user