Files
memex/system/skills/org-skill-web-interface.org

3.5 KiB

SKILL: Web Dashboard Agent (Telemetry Interface)

Overview

The Web Dashboard Agent provides a lightweight, browser-based window into the Neurosymbolic Kernel's internal state. It exposes the active skill graph, execution telemetry, and recent system logs, enabling real-time monitoring and transparency of the agent's cognitive processes.

The Interface Mandate

  1. Transparency: Provide a human-readable overview of skill performance (executions, time, failures).
  2. Accessibility: Serve a minimalist HTML dashboard over a configurable local port.
  3. Observability: Expose the tail of the system logs for rapid debugging and "pain" analysis.
  4. Low Overhead: Operate as a background service with minimal impact on the kernel's primary cognitive loop.

Symbolic Implementation (The Logic)

The implementation leverages the Hunchentoot web server to provide a simple, deterministic telemetry endpoint.

Architectural Intent: Server Initialization

Bootstraps the web server on a specified port, ensuring the dashboard is live from the moment the skill is loaded.

(defvar *web-server* nil)

(defun start-dashboard (&optional (port 8080))
  "Starts the Hunchentoot dashboard server."
  (unless *web-server*
    (setf *web-server* (make-instance 'hunchentoot:easy-acceptor :port port))
    (hunchentoot:start *web-server*)
    (kernel-log "WEB - Dashboard live on port ~a" port)))

Architectural Intent: Telemetry Rendering

This handler constructs the dashboard UI. It introspects the skill registry and gathers telemetry for each skill, formatting the results into a clean HTML table alongside the system's recent log history.

(hunchentoot:define-easy-handler (dashboard-home :uri "/") ()
  (setf (hunchentoot:content-type*) "text/html")
  (let* ((skills (org-agent:context-list-all-skills))
         (telemetry (mapcar (lambda (s) 
                              (let ((stats (org-agent:context-get-skill-telemetry (getf s :name))))
                                (format nil "<li><b>~a</b> (P:~a) [Execs: ~a, Time: ~ams, Fails: ~a]</li>"
                                        (getf s :name) 
                                        (getf s :priority)
                                        (or (getf stats :executions) 0)
                                        (or (getf stats :total-time) 0)
                                        (or (getf stats :failures) 0))))
                            skills)))
    (format nil "
      <html>
      <head><title>org-agent Dashboard</title></head>
      <body style='font-family: monospace; background: #111; color: #eee; padding: 20px;'>
        <h1>org-agent Neurosymbolic Kernel</h1>
        <hr>
        <h2>Active Skill Graph & Telemetry</h2>
        <ul>
          ~{~a~%~}
        </ul>
        <hr>
        <h2>Recent Logs</h2>
        <pre>~{~a~%~}</pre>
      </body>
      </html>
    " telemetry (org-agent:context-get-system-logs 20))))

Registration

Architectural Intent: Background Bootstrap

Ensures the server starts automatically using environment-defined ports or sane defaults.

;; Start the dashboard upon skill load
(let* ((env-port (uiop:getenv "ORG_AGENT_WEB_PORT"))
       (port (if env-port (parse-integer env-port :junk-allowed t) 8080)))
  (start-dashboard port))

(defskill :skill-web-interface
  :priority 10 ; Low priority, background service
  :trigger (lambda (context) nil)
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))