*logo dark Hyperon Wiki
    • Register
    • Login 🔑
    • MeTTa Programming Language
      • Hyperon Experimental
      • PeTTa
      • MeTTaLog (Legacy)
      • JeTTa
      • MeTTa-Morph
    • ASI:Chain Runtime Environment
      • F1R3FLY
      • MeTTaCycle
    • Knowledge Representations
      • DAS (Distributed AtomSpace)
      • MORK (MeTTa Optimized Reduction Kernel)
    • Hyperon AI Algorithms
      • ECAN (Economic Attention Networks)
      • MetaMo (Motivational Framework)
      • Semantic Parsing (LLM/NLP)
      • MeTTa-Motto
      • PLN (Probabilistic Logic Networks)
      • MeTTa-NARS (Non-Axiomatic Reasoning System)
      • NACE (Non-Axiomatic Causal Explorer)
      • AI-DSL
      • MOSES
      • AIRIS
    • Cognitive Architectures
      • PRIMUS (formerly CogPrime)
    • Glossary
    • Project Registry
    Extensions
    • About Hyperon
    • Applications
    • Publications
    • Reference
    • Ecosystem

    Left Sidebar Layout

    help edit space_dashboard
    <body class="wiki-layout">
      <header>{{:header|core}}</header>
      <aside id="sidebar-left">
        {{:sidebar|core}}
      </aside>
      <article>{{_main|titled;title:_R}}</article>
      <aside id="sidebar-right">{{*sidebar_right|core}}</aside>
      <footer>{{:footer|core}}</footer>
      <script>
      (function () {
        function slugify(s) {
          return (s || "").toString().trim().toLowerCase()
            .replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
        }
        function buildInlineToc() {
          var article = document.querySelector("article");
          if (!article) return;
          if (article.querySelector(".wiki-inline-toc")) return; // idempotent
          var headings = article.querySelectorAll("h2, h3");
          if (!headings.length) return;
    
          var toc = document.createElement("nav");
          toc.className = "wiki-inline-toc";
          toc.setAttribute("aria-label", "On this page");
    
          var heading = document.createElement("p");
          heading.className = "wiki-inline-toc-heading";
          heading.textContent = "On this page";
          toc.appendChild(heading);
    
          var ul = document.createElement("ul");
          ul.className = "wiki-inline-toc-list";
    
          headings.forEach(function (h) {
            if (!h.id) h.id = slugify(h.textContent);
            var li = document.createElement("li");
            li.className = "wiki-inline-toc-" + h.tagName.toLowerCase();
            var a = document.createElement("a");
            a.href = "#" + h.id;
            a.textContent = (h.textContent || "").trim();
            li.appendChild(a);
            ul.appendChild(li);
          });
          toc.appendChild(ul);
    
          var h1 = article.querySelector(":scope > div > .d0-card-header, :scope > .d0-card-header");
          if (h1 && h1.parentNode) {
            h1.parentNode.insertBefore(toc, h1.nextSibling);
          } else {
            article.insertBefore(toc, article.firstChild);
          }
        }
        function buildBreadcrumb() {
          var article = document.querySelector("article");
          if (!article) return;
          if (article.querySelector(".wiki-page-breadcrumb")) return; // idempotent
          var slot = article.querySelector("#main > [data-card-name]");
          if (!slot) return;
          if (slot.getAttribute("data-card-type-name") !== "IndexSubtopic") return;
    
          var name = slot.getAttribute("data-card-name") || "";
          var linkName = slot.getAttribute("data-card-link-name") || "";
          var parts = name.split("+");
          var linkParts = linkName.split("+");
          if (parts.length < 2 || linkParts.length < 2) return;
    
          var bc = document.createElement("p");
          bc.className = "wiki-page-breadcrumb";
          var a = document.createElement("a");
          a.href = "/" + linkParts[0];
          a.textContent = parts[0];
          bc.appendChild(a);
          bc.appendChild(document.createTextNode(" / " + parts[parts.length - 1]));
    
          var header = slot.querySelector(":scope > .d0-card-header");
          if (header && header.parentNode) {
            header.parentNode.insertBefore(bc, header);
          } else {
            slot.insertBefore(bc, slot.firstChild);
          }
        }
        function setupExamplesToggle() {
          var blocks = document.querySelectorAll(".card-slot.TYPE_PLUS_RIGHT-index_subtopic-example");
          blocks.forEach(function (block) {
            if (block.dataset.examplesProcessed) return;
            block.dataset.examplesProcessed = "1";
    
            var examples = block.querySelectorAll(":scope > .card-slot.TYPE-rich_text");
            if (examples.length < 2) return;
    
            var n = examples.length - 1;
            var collapsedLabel = "â–¾ Read more (" + n + " more example" + (n > 1 ? "s" : "") + ")";
            var expandedLabel = "â–´ Show less";
    
            for (var i = 1; i < examples.length; i++) {
              examples[i].classList.add("wiki-example-hidden");
            }
    
            var toggle = document.createElement("button");
            toggle.type = "button";
            toggle.className = "wiki-example-toggle";
            toggle.textContent = collapsedLabel;
            var expanded = false;
            toggle.addEventListener("click", function () {
              expanded = !expanded;
              for (var j = 1; j < examples.length; j++) {
                examples[j].classList.toggle("wiki-example-hidden", !expanded);
              }
              toggle.textContent = expanded ? expandedLabel : collapsedLabel;
            });
            block.appendChild(toggle);
          });
        }
        function setupCodePlayground() {
          var run = document.getElementById("metta-run");
          var reset = document.getElementById("metta-reset");
          var code = document.getElementById("metta-code");
          var output = document.getElementById("metta-output");
          var outputText = document.getElementById("metta-output-text");
          if (!run || !code || run.dataset.bound) return;
          run.dataset.bound = "1";
          var initial = code.value;
          var endpoint = (typeof window !== "undefined" && window.MAGI_PLAYGROUND_URL) || "/api/playground/run";
    
          function clearError() { outputText.classList.remove("hyperon-rc-output-error"); }
          function markError() { outputText.classList.add("hyperon-rc-output-error"); }
    
          function renderEnvelope(env) {
            var hasOk = !!(env.output || env.stdout);
            var hasErr = !!env.stderr;
            var parts = [];
            if (env.output) parts.push(env.output);
            if (env.stdout) parts.push(env.stdout);
            if (hasErr) parts.push(env.stderr);
            outputText.textContent = parts.join("\n\n") || "(no output)";
            if (hasErr && !hasOk) markError(); else clearError();
            output.hidden = false;
          }
    
          function stubFallback() {
            var lines = code.value.split("\n").filter(function (l) { return l.trim().indexOf("!") === 0; });
            var results = lines.map(function (line) {
              if (line.indexOf("greet World") >= 0) return "[(Hello World welcome to Hyperon!)]";
              if (line.indexOf("match") >= 0 && line.indexOf("Human") >= 0) return "[Alice, Bob]";
              return "[Result of " + line.replace(/^\s*!/, "").trim() + "]";
            });
            outputText.textContent = results.length ? results.join("\n") : "(no ! queries to evaluate)";
            clearError();
            output.hidden = false;
          }
    
          run.addEventListener("click", function () {
            run.disabled = true;
            outputText.textContent = "(running…)";
            clearError();
            output.hidden = false;
    
            var done = function () { run.disabled = false; };
    
            fetch(endpoint, {
              method: "POST",
              credentials: "same-origin",
              headers: { "content-type": "application/json" },
              body: JSON.stringify({ code: code.value })
            }).then(function (r) {
              if (!r.ok) throw new Error("HTTP " + r.status);
              return r.json();
            }).then(function (env) {
              renderEnvelope(env);
              done();
            }).catch(function (err) {
              if (typeof console !== "undefined" && console.warn) {
                console.warn("playground backend unavailable; using stub fallback:", err);
              }
              stubFallback();
              done();
            });
          });
          if (reset) {
            reset.addEventListener("click", function () {
              code.value = initial;
              output.hidden = true;
              clearError();
            });
          }
        }
        function setupWikiChat() {
          var send = document.getElementById("chat-send");
          var input = document.getElementById("chat-input");
          var messages = document.getElementById("chat-messages");
          if (!send || !input || send.dataset.bound) return;
          send.dataset.bound = "1";
          var chatUrl = (typeof window !== "undefined" && window.MAGI_ASSISTANT_URL) || "/api/assistant/chat";
          var history = [];
          var canned = [
            { match: /\bmetta\b/i, reply: "MeTTa is the native \"language of thought\" for AGI — a programming language unifying functional, logic, and dependent typing over a dynamic knowledge metagraph (Atomspace)." },
            { match: /\bhyperon\b/i, reply: "Hyperon is SingularityNET's AGI technology stack, building on decades of OpenCog research." },
            { match: /\bpln\b/i, reply: "PLN (Probabilistic Logic Networks) is Hyperon's reasoning-under-uncertainty algorithm. See /Hyperon_AI_Algorithms+PLN_(Probabilistic_Logic_Networks)" },
            { match: /\becan\b/i, reply: "ECAN (Economic Attention Networks) manages limited computational resources via attention allocation. See /Hyperon_AI_Algorithms+ECAN_(Economic_Attention_Networks)" },
            { match: /\bmork\b/i, reply: "MORK is the high-performance triemap substrate for Hyperon. See /Knowledge_Representations+MORK_(MeTTa_Optimized_Reduction_Kernel)" },
            { match: /\bdas\b/i, reply: "DAS (Distributed AtomSpace) is the distributed knowledge backend. See /Knowledge_Representations+DAS_(Distributed_AtomSpace)" },
            { match: /\bpetta\b/i, reply: "PeTTa is a high-performance Prolog-based MeTTa runtime by Patrick Hammer. See /MeTTa_Programming_Language+PeTTa" },
            { match: /\bprimus\b/i, reply: "PRIMUS is the cognitive architecture that wires Hyperon's modules into a unified AGI system. See /Cognitive_Architectures+PRIMUS_(formerly_CogPrime)" }
          ];
          var defaultFallback = "I can't reach the assistant right now. For deeper questions, try ASI Create — https://create.singularitynet.io/";
          function findCanned(q) {
            for (var i = 0; i < canned.length; i++) {
              if (canned[i].match.test(q)) return canned[i].reply;
            }
            return defaultFallback;
          }
          function clearEmpty() {
            var empty = messages.querySelector(".hyperon-rc-empty");
            if (empty) empty.remove();
          }
          function addUserMessage(text) {
            clearEmpty();
            var div = document.createElement("div");
            div.className = "hyperon-rc-msg hyperon-rc-msg-user";
            div.textContent = text;
            messages.appendChild(div);
            messages.scrollTop = messages.scrollHeight;
          }
          function addAssistantBubble() {
            clearEmpty();
            var div = document.createElement("div");
            div.className = "hyperon-rc-msg hyperon-rc-msg-assistant";
            messages.appendChild(div);
            messages.scrollTop = messages.scrollHeight;
            return div;
          }
          function addToolPill(bubble, name) {
            if (bubble.querySelector(".hyperon-rc-tool-pill")) return;
            var pill = document.createElement("span");
            pill.className = "hyperon-rc-tool-pill";
            pill.textContent = "(searching the wiki…)";
            if (name) pill.dataset.tool = name;
            bubble.appendChild(pill);
            messages.scrollTop = messages.scrollHeight;
          }
          function clearToolPills(bubble) {
            var pills = bubble.querySelectorAll(".hyperon-rc-tool-pill");
            for (var i = 0; i < pills.length; i++) pills[i].remove();
          }
          function safeUrl(u) {
            if (!u) return null;
            if (/^https?:\/\//i.test(u)) return u;
            if (u.charAt(0) === "/" && u.charAt(1) !== "/") return u;
            return null;
          }
          function renderInline(node, text) {
            var re = /(\*\*([^*]+)\*\*)|(`([^`]+)`)|(\[([^\]]+)\]\(([^)]+)\))/g;
            var last = 0;
            var m;
            while ((m = re.exec(text)) !== null) {
              if (m.index > last) node.appendChild(document.createTextNode(text.slice(last, m.index)));
              if (m[2]) {
                var b = document.createElement("strong");
                b.textContent = m[2];
                node.appendChild(b);
              } else if (m[4]) {
                var c = document.createElement("code");
                c.textContent = m[4];
                node.appendChild(c);
              } else if (m[6]) {
                var url = safeUrl(m[7]);
                if (url) {
                  var a = document.createElement("a");
                  a.href = url;
                  a.textContent = m[6];
                  if (/^https?:\/\//i.test(url)) {
                    a.target = "_blank";
                    a.rel = "noopener noreferrer";
                  }
                  node.appendChild(a);
                } else {
                  node.appendChild(document.createTextNode(m[6]));
                }
              }
              last = re.lastIndex;
            }
            if (last < text.length) node.appendChild(document.createTextNode(text.slice(last)));
          }
          function renderMarkdownLight(bubble, text) {
            bubble.textContent = "";
            var paras = text.split(/\n\n+/);
            for (var i = 0; i < paras.length; i++) {
              var p = document.createElement("p");
              var lines = paras[i].split(/\n/);
              for (var j = 0; j < lines.length; j++) {
                if (j > 0) p.appendChild(document.createElement("br"));
                renderInline(p, lines[j]);
              }
              bubble.appendChild(p);
            }
          }
          function parseSse(reader, bubble, onDelta) {
            var decoder = new TextDecoder();
            var buf = "";
            var full = "";
            function processEvent(chunk) {
              var lines = chunk.split(/\n/);
              var dataParts = [];
              for (var i = 0; i < lines.length; i++) {
                var line = lines[i];
                if (line.indexOf("data:") === 0) dataParts.push(line.slice(5).replace(/^ /, ""));
              }
              if (!dataParts.length) return;
              var payload;
              try { payload = JSON.parse(dataParts.join("\n")); } catch (e) { return; }
              if (payload.type === "delta" && typeof payload.text === "string") {
                full += payload.text;
                onDelta(payload.text, full);
              } else if (payload.type === "tool_use") {
                addToolPill(bubble, payload.name);
              }
            }
            function pump() {
              return reader.read().then(function (r) {
                if (r.done) {
                  if (buf.trim()) processEvent(buf);
                  return full;
                }
                buf += decoder.decode(r.value, { stream: true });
                var idx;
                while ((idx = buf.indexOf("\n\n")) !== -1) {
                  var chunk = buf.slice(0, idx);
                  buf = buf.slice(idx + 2);
                  processEvent(chunk);
                }
                return pump();
              });
            }
            return pump();
          }
          function doSend() {
            var q = input.value.trim();
            if (!q) return;
            addUserMessage(q);
            input.value = "";
            history.push({ role: "user", content: q });
            var bubble = addAssistantBubble();
            function onDelta(piece) {
              clearToolPills(bubble);
              bubble.appendChild(document.createTextNode(piece));
              messages.scrollTop = messages.scrollHeight;
            }
            function showFallback(err) {
              if (window.console && err) console.warn("[wiki-assistant] fallback:", err);
              bubble.textContent = "";
              renderMarkdownLight(bubble, findCanned(q));
            }
            var hasFetchStream = (typeof window !== "undefined" && typeof window.fetch === "function" && typeof window.ReadableStream === "function");
            if (!hasFetchStream) { showFallback("no fetch/stream"); return; }
            var body = JSON.stringify({ messages: history, model: "claude-sonnet-4-6" });
            window.fetch(chatUrl, {
              method: "POST",
              headers: { "Content-Type": "application/json", "Accept": "text/event-stream" },
              body: body,
              credentials: "same-origin"
            }).then(function (resp) {
              if (!resp.ok || !resp.body) throw new Error("HTTP " + resp.status);
              return parseSse(resp.body.getReader(), bubble, onDelta);
            }).then(function (finalText) {
              clearToolPills(bubble);
              if (finalText && finalText.trim()) {
                renderMarkdownLight(bubble, finalText);
                history.push({ role: "assistant", content: finalText });
              } else {
                showFallback("empty stream");
              }
            }).catch(function (err) {
              showFallback(err && err.message ? err.message : String(err));
            });
          }
          send.addEventListener("click", doSend);
          input.addEventListener("keydown", function (e) {
            if (e.key === "Enter") { e.preventDefault(); doSend(); }
          });
        }
        function buildAll() { buildInlineToc(); buildBreadcrumb(); setupExamplesToggle(); setupCodePlayground(); setupWikiChat(); }
        if (document.readyState === "loading") {
          document.addEventListener("DOMContentLoaded", buildAll);
        } else {
          buildAll();
        }
      })();
      </script>
    </body>
    MeTTa Playground

    Output:

    
        
    ✨ Wiki Assistant
    ✨

    Ask me about Hyperon

    b&w_logo Created with Sketch. Decko v0.20.0

    Copyright © 2026 by SingularityNET Foundation. All rights reserved, except as noted below. This website's content is free to use: you may redistribute it and/or modify it under the terms of its license, the Creative Commons Attribution-ShareAlike 4.0 License as published by the Creative Commons Corporation.