Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Add memory dashboard view

Justin D'Souza9d7a990bac8d
diff --git a/cli/beacon/internal/endpoint/dashboard/memory.go b/cli/beacon/internal/endpoint/dashboard/memory.go
new file mode 100644
index 00000000..badc46a2
--- /dev/null
+++ b/cli/beacon/internal/endpoint/dashboard/memory.go
@@ -0,0 +1,55 @@
+package dashboard
+
+import (
+ "net/http"
+ "strconv"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/learning"
+)
+
+func ReadMemory(logPath string, query learning.Query) (MemoryResponse, error) {
+ store := learning.Open(learning.PathForRuntimeLog(logPath))
+ status, err := store.Status()
+ if err != nil {
+ return MemoryResponse{}, err
+ }
+ evaluations, err := store.ListEvaluations(query)
+ if err != nil {
+ return MemoryResponse{}, err
+ }
+ candidates, err := store.ListCandidates(query)
+ if err != nil {
+ return MemoryResponse{}, err
+ }
+ memories, err := store.ListMemories(query)
+ if err != nil {
+ return MemoryResponse{}, err
+ }
+ return MemoryResponse{
+ Status: status,
+ Evaluations: evaluations,
+ Candidates: candidates,
+ Memories: memories,
+ }, nil
+}
+
+func parseMemoryQuery(r *http.Request) learning.Query {
+ q := r.URL.Query()
+ limit, _ := strconv.Atoi(q.Get("limit"))
+ if limit <= 0 {
+ limit = 50
+ }
+ page, _ := strconv.Atoi(q.Get("page"))
+ if page <= 0 {
+ page = 1
+ }
+ return learning.Query{
+ ProjectID: q.Get("project_id"),
+ ProjectPath: q.Get("project"),
+ State: q.Get("state"),
+ Kind: q.Get("kind"),
+ Q: q.Get("q"),
+ Limit: limit,
+ Page: page,
+ }
+}
diff --git a/cli/beacon/internal/endpoint/dashboard/server.go b/cli/beacon/internal/endpoint/dashboard/server.go
index cd50cffb..814c9483 100644
--- a/cli/beacon/internal/endpoint/dashboard/server.go
+++ b/cli/beacon/internal/endpoint/dashboard/server.go
@@ -17,6 +17,7 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/inventory"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/tokens"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
const DefaultAddr = "127.0.0.1:8765"
@@ -64,6 +65,13 @@ type HookStatus struct {
Message string `json:"message,omitempty"`
}
+type MemoryResponse struct {
+ Status asymptoteobserve.LearningStatusV1 `json:"status"`
+ Evaluations []asymptoteobserve.LearningEvaluationV1 `json:"evaluations"`
+ Candidates []asymptoteobserve.LearningCandidateV1 `json:"candidates"`
+ Memories []asymptoteobserve.LearningMemoryV1 `json:"memories"`
+}
+
var (
resolveRuntimeLog = lifecycle.ResolveRuntimeLog
getEndpointStatus = lifecycle.GetStatus
@@ -223,6 +231,18 @@ func Handler(opts Options) (http.Handler, error) {
}
writeJSON(w, trace)
})
+ mux.HandleFunc("/api/memory", func(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet {
+ methodNotAllowed(w)
+ return
+ }
+ resp, err := ReadMemory(opts.LogPath, parseMemoryQuery(r))
+ if err != nil {
+ writeError(w, http.StatusInternalServerError, err)
+ return
+ }
+ writeJSON(w, resp)
+ })
mux.HandleFunc("/api/tokens", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
methodNotAllowed(w)
diff --git a/cli/beacon/internal/endpoint/dashboard/server_test.go b/cli/beacon/internal/endpoint/dashboard/server_test.go
index db51755c..ebaeedf2 100644
--- a/cli/beacon/internal/endpoint/dashboard/server_test.go
+++ b/cli/beacon/internal/endpoint/dashboard/server_test.go
@@ -12,7 +12,9 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/diagnostics"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/learning"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/tokens"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
func TestStatusUsesExplicitRuntimeLogPath(t *testing.T) {
@@ -163,6 +165,68 @@ func TestSummaryEndpointAggregatesAllMatchedEvents(t *testing.T) {
}
}
+func TestMemoryEndpointServesReadOnlyLearningState(t *testing.T) {
+ dir := t.TempDir()
+ logPath := filepath.Join(dir, "endpoint", "logs", "runtime.jsonl")
+ if err := os.MkdirAll(filepath.Dir(logPath), 0755); err != nil {
+ t.Fatal(err)
+ }
+ store := learning.Open(learning.PathForRuntimeLog(logPath))
+ project := asymptoteobserve.LearningProjectV1{ID: "project-1"}
+ eval := asymptoteobserve.LearningEvaluationV1{
+ ID: "eval-1",
+ Status: asymptoteobserve.LearningEvaluationStatusCompleted,
+ Project: project,
+ RubricVersion: "rubric",
+ RubricHash: "sha256:rubric",
+ Evaluator: "jev",
+ Trace: asymptoteobserve.LearningTraceRefV1{ID: "trace-1", Title: "Fix package smoke"},
+ Score: 0.9,
+ }
+ if err := store.PutEvaluation(eval); err != nil {
+ t.Fatal(err)
+ }
+ candidate := asymptoteobserve.LearningCandidateV1{
+ ID: "candidate-1",
+ State: asymptoteobserve.LearningCandidateStateApproved,
+ Kind: asymptoteobserve.LearningMemoryKindDebuggingPattern,
+ Title: "Fix package smoke",
+ Body: "Rerun once after a transient failure.",
+ Project: project,
+ SourceEvaluationID: "eval-1",
+ MemoryID: "memory-1",
+ }
+ if err := store.PutCandidate(candidate); err != nil {
+ t.Fatal(err)
+ }
+ if err := store.PutMemory(asymptoteobserve.LearningMemoryV1{
+ ID: "memory-1",
+ CandidateID: candidate.ID,
+ Kind: candidate.Kind,
+ Title: candidate.Title,
+ Body: candidate.Body,
+ Project: project,
+ }); err != nil {
+ t.Fatal(err)
+ }
+ handler, err := Handler(Options{UserMode: true, LogPath: logPath})
+ if err != nil {
+ t.Fatalf("Handler returned error: %v", err)
+ }
+ rec := httptest.NewRecorder()
+ handler.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/api/memory", nil))
+ if rec.Code != http.StatusOK {
+ t.Fatalf("memory status = %d body=%s", rec.Code, rec.Body.String())
+ }
+ var resp MemoryResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
+ t.Fatal(err)
+ }
+ if resp.Status.Evaluations != 1 || len(resp.Evaluations) != 1 || len(resp.Candidates) != 1 || len(resp.Memories) != 1 {
+ t.Fatalf("memory response = %#v", resp)
+ }
+}
+
func itoa2(v int) string {
if v < 10 {
return "0" + strconv.Itoa(v)
diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.js
index 1add80f2..fbb523f0 100644
--- a/cli/beacon/internal/endpoint/dashboard/static/app.js
+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js
@@ -40,6 +40,7 @@ const isOverviewPage = document.body.dataset.page === "overview";
const isTokensPage = document.body.dataset.page === "tokens";
const isDetectionsPage = document.body.dataset.page === "detections";
const isFindingsPage = document.body.dataset.page === "findings";
+const isMemoryPage = document.body.dataset.page === "memory";
// Both inventory pages share loadInventory(); each renderer targets its own
// page's elements and no-ops when they are absent.
const isInventoryPage = document.body.dataset.page === "inventory" || document.body.dataset.page === "inventory-hooks";
@@ -3203,6 +3204,85 @@ function setupNavCollapse() {
});
}
+async function loadMemory() {
+ if (!isMemoryPage) return;
+ state.loading = true;
+ state.error = null;
+ renderMemoryLoading();
+ try {
+ state.memory = await getJSON("/api/memory?limit=50");
+ } catch (err) {
+ state.error = err;
+ } finally {
+ state.loading = false;
+ renderMemory();
+ }
+}
+
+function renderMemoryLoading() {
+ setText("#memory-status", "Loading Beacon memory...");
+}
+
+function renderMemory() {
+ if (!isMemoryPage) return;
+ if (state.error) {
+ setText("#memory-status", state.error.message || String(state.error));
+ return;
+ }
+ const data = state.memory || {};
+ const status = data.status || {};
+ setText("#memory-status", `${status.evaluations || 0} evaluations, ${status.candidates || 0} candidates, ${status.approved_memories || 0} approved memories`);
+ renderMemoryTable("#memory-evaluations", data.evaluations || [], (item) => [
+ item.id || "",
+ item.trace?.id || "",
+ item.status || "",
+ formatScore(item.score),
+ item.trace?.title || "",
+ ]);
+ renderMemoryTable("#memory-candidates", data.candidates || [], (item) => [
+ item.id || "",
+ item.state || "",
+ item.kind || "",
+ item.title || "",
+ ]);
+ renderMemoryTable("#memory-approved", data.memories || [], (item) => [
+ item.id || "",
+ item.kind || "",
+ item.title || "",
+ item.applicability || "",
+ ]);
+}
+
+function renderMemoryTable(selector, items, rowFn) {
+ const tbody = $(selector);
+ if (!tbody) return;
+ tbody.innerHTML = "";
+ if (!items.length) {
+ const row = document.createElement("tr");
+ const cell = document.createElement("td");
+ cell.colSpan = 5;
+ cell.className = "muted";
+ cell.textContent = "No records yet.";
+ row.append(cell);
+ tbody.append(row);
+ return;
+ }
+ for (const item of items) {
+ const row = document.createElement("tr");
+ for (const value of rowFn(item)) {
+ const cell = document.createElement("td");
+ cell.textContent = value;
+ row.append(cell);
+ }
+ tbody.append(row);
+ }
+}
+
+function formatScore(value) {
+ if (typeof value !== "number" || Number.isNaN(value)) return "";
+ return value.toFixed(2);
+}
+
decorateDashboardNav();
setupNavCollapse();
@@ -3262,6 +3342,9 @@ if (isDetectionsPage) {
hydrateInventoryStateFromURL();
loadInventory().catch(console.error);
setInterval(() => loadInventory().catch(console.error), 15000);
+} else if (isMemoryPage) {
+ loadMemory().catch(console.error);
+ setInterval(() => loadMemory().catch(console.error), 15000);
} else {
hydrateFiltersFromURL();
setupSessionFilters();
diff --git a/cli/beacon/internal/endpoint/dashboard/static/memory.html b/cli/beacon/internal/endpoint/dashboard/static/memory.html
new file mode 100644
index 00000000..14496dc5
--- /dev/null
+++ b/cli/beacon/internal/endpoint/dashboard/static/memory.html
@@ -0,0 +1,109 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>Beacon Memory</title>
+ <link rel="icon" type="image/svg+xml" href="/logo.svg" />
+ <link rel="stylesheet" href="/styles.css" />
+ </head>
+ <body data-page="memory">
+ <header class="topbar">
+ <div>
+ <p class="eyebrow">Local-only</p>
+ <h1>Beacon Memory</h1>
+ </div>
+ <nav class="nav-toggle" aria-label="Dashboard navigation">
+ <div class="nav-section">
+ <div class="nav-section-title">Overview</div>
+ <a href="/findings.html">Findings</a>
+ </div>
+ <div class="nav-section">
+ <div class="nav-parent">Analytics</div>
+ <a href="/tokens.html">Token Usage</a>
+ <a href="/overview.html">Agent Activity</a>
+ <a class="active" aria-current="page" href="/memory.html">Memory</a>
+ </div>
+ <div class="nav-section">
+ <div class="nav-section-title">Observe</div>
+ <a href="/inventory.html">Agent Inventory</a>
+ <a href="/">Agent Activity Sessions</a>
+ </div>
+ <div class="nav-section">
+ <div class="nav-section-title">Control</div>
+ <a href="/detections.html">Detections</a>
+ </div>
+ </nav>
+ </header>
+
+ <main>
+ <section class="dashboard-hero">
+ <div>
+ <h2>Cross-Harness Memory</h2>
+ <p class="muted">Read-only view of local evaluations, review candidates, and approved project memories. Mutations stay in the CLI.</p>
+ </div>
+ </section>
+
+ <section class="panel status-panel">
+ <div>
+ <h2>Learning Store</h2>
+ <p id="memory-status" class="muted">Loading Beacon memory...</p>
+ </div>
+ </section>
+
+ <section class="panel">
+ <h2>Evaluations</h2>
+ <div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>Evaluation</th>
+ <th>Trace</th>
+ <th>Status</th>
+ <th>Score</th>
+ <th>Title</th>
+ </tr>
+ </thead>
+ <tbody id="memory-evaluations"></tbody>
+ </table>
+ </div>
+ </section>
+
+ <section class="panel">
+ <h2>Candidates</h2>
+ <div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>Candidate</th>
+ <th>State</th>
+ <th>Kind</th>
+ <th>Title</th>
+ </tr>
+ </thead>
+ <tbody id="memory-candidates"></tbody>
+ </table>
+ </div>
+ </section>
+
+ <section class="panel">
+ <h2>Approved Memory</h2>
+ <div class="table-wrap">
+ <table>
+ <thead>
+ <tr>
+ <th>Memory</th>
+ <th>Kind</th>
+ <th>Title</th>
+ <th>Applicability</th>
+ </tr>
+ </thead>
+ <tbody id="memory-approved"></tbody>
+ </table>
+ </div>
+ </section>
+ </main>
+
+ <script src="/app.js"></script>
+ </body>
+</html>