"use strict"; // Keep links from the former one-page site useful after the page split. const legacyPages = { "#platform": "platform.html", "#architecture": "platform.html", "#tools": "tools.html", "#readiness": "release.html" }; if ((location.pathname.endsWith("/") || location.pathname.endsWith("/index.html")) && legacyPages[location.hash]) { location.replace(new URL(legacyPages[location.hash], location.href).href); } const menu = document.querySelector(".menu-toggle"); const nav = document.querySelector("#nav-links"); function closeMenu() { menu.setAttribute("aria-expanded", "false"); nav.classList.remove("open"); } menu.addEventListener("click", () => { const open = menu.getAttribute("aria-expanded") !== "true"; menu.setAttribute("aria-expanded", String(open)); nav.classList.toggle("open", open); }); nav.querySelectorAll("a").forEach(link => link.addEventListener("click", closeMenu)); document.addEventListener("keydown", event => { if (event.key === "Escape" && menu.getAttribute("aria-expanded") === "true") { closeMenu(); menu.focus(); } }); const examples = { discover: { command: "cybot capability help web.map", output: {id: "web.map", tools: ["httpx", "katana"], output: "cybot://schemas/result", evidence: "SHA-256 artifacts"}, note: "Understand the operation before it runs." }, plan: { command: "cybot capability plan web.map --target https://authorized.example", output: {capability: "web.map", target: "https://authorized.example", selected_tools: ["httpx", "katana"], execution: "not started"}, note: "Inspect tool choices, policy and required approval before execution." }, run: { command: "cybot run web.map --target https://authorized.example --approve", output: {status: "completed", endpoints: 3, evidence: [{type: "structured-output", sha256: ""}], next: "Review the evidence"}, note: "Illustrative fixture result. No operation runs on this page." } }; const tabs = [...document.querySelectorAll("[data-step]")]; function selectStep(button) { const value = examples[button.dataset.step]; tabs.forEach(tab => { tab.setAttribute("aria-selected", String(tab === button)); tab.tabIndex = tab === button ? 0 : -1; }); document.querySelector("#terminal-output").setAttribute("aria-labelledby", button.id); document.querySelector("#demo-command").textContent = value.command; document.querySelector("#demo-output").textContent = JSON.stringify(value.output, null, 2); document.querySelector("#demo-note").textContent = value.note; document.querySelector(".product-label>span:last-child").textContent = String(tabs.indexOf(button) + 1).padStart(2, "0") + " / 03"; } tabs.forEach((tab, index) => { tab.addEventListener("click", () => selectStep(tab)); tab.addEventListener("keydown", event => { let next; if (event.key === "ArrowRight") next = (index + 1) % tabs.length; if (event.key === "ArrowLeft") next = (index + tabs.length - 1) % tabs.length; if (event.key === "Home") next = 0; if (event.key === "End") next = tabs.length - 1; if (next !== undefined) { event.preventDefault(); selectStep(tabs[next]); tabs[next].focus(); } }); }); function icon(name) { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); const use = document.createElementNS("http://www.w3.org/2000/svg", "use"); svg.setAttribute("class", "icon"); svg.setAttribute("aria-hidden", "true"); use.setAttribute("href", "#" + name); svg.append(use); return svg; } async function initializeCatalog() { const grid = document.querySelector("#tool-grid"); if (!grid) return; const message = document.querySelector("#catalog-message"); const search = document.querySelector("#tool-search"); const filter = document.querySelector("#profile-filter"); const more = document.querySelector("#show-tools"); const labels = {core: "Core", web: "Web", analysis: "Code analysis", supplychain: "Supply chain", browser: "Browser"}; let data; let limit = 9; function render() { if (!data) return; const query = search.value.trim().toLowerCase(); const rows = data.tools.filter(tool => (filter.value === "all" || tool.profiles.includes(filter.value)) && [tool.title, tool.id, tool.description, ...tool.capabilities].join(" ").toLowerCase().includes(query) ); grid.replaceChildren(); for (const tool of rows.slice(0, limit)) { const card = document.createElement("article"); card.className = "tool-card"; const top = document.createElement("div"); top.className = "tool-top"; const monogram = document.createElement("span"); monogram.className = "tool-monogram"; monogram.setAttribute("aria-hidden", "true"); monogram.textContent = tool.id.replace(/[^a-z0-9]/gi, "").slice(0, 2).toUpperCase(); const profile = document.createElement("span"); profile.className = "tool-profile"; profile.textContent = tool.profiles.slice(0, 2).map(id => labels[id]).join(" / "); top.append(monogram, profile); const heading = document.createElement("h3"); const link = document.createElement("a"); link.href = tool.source_url; link.textContent = tool.title; link.setAttribute("aria-label", tool.title + " upstream project"); link.append(icon("external")); heading.append(link); const description = document.createElement("p"); description.textContent = tool.description; const bottom = document.createElement("div"); bottom.className = "tool-bottom"; const badge = document.createElement("a"); badge.className = "operation-badge"; badge.href = data.validation_url; badge.append(icon("check"), document.createTextNode("Operation tested")); const version = document.createElement("span"); version.className = "tool-version"; version.textContent = "Tested " + tool.tested_version; version.title = "Tested version at the retained checkpoint: " + tool.tested_version; bottom.append(badge, version); card.append(top, heading, description, bottom); grid.append(card); } message.textContent = rows.length ? (query || filter.value !== "all" ? rows.length + " matching tools" : data.tools.length + " tools with retained operation evidence") : "No matching tools. Try another search or runtime profile."; more.hidden = rows.length <= limit; more.textContent = "View all " + rows.length + " tools ↓"; } search.addEventListener("input", () => {limit = 9; render();}); filter.addEventListener("change", () => {limit = 9; render();}); more.addEventListener("click", () => {limit = Infinity; render();}); try { const snapshot = document.querySelector('meta[name="cybot-tools-snapshot"]').content; if (!/^[a-f0-9]{64}$/.test(snapshot)) throw Error("Invalid checkpoint identity"); const response = await fetch("./available-tools.json?v=" + encodeURIComponent(snapshot)); if (!response.ok) throw Error("Tool checkpoint unavailable"); const bytes = await response.arrayBuffer(); const digest = Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))) .map(byte => byte.toString(16).padStart(2, "0")).join(""); if (digest !== snapshot) throw Error("Tool checkpoint mismatch"); const value = JSON.parse(new TextDecoder().decode(bytes)); const validTool = tool => typeof tool.id === "string" && typeof tool.title === "string" && typeof tool.description === "string" && typeof tool.tested_version === "string" && /^https:\/\//.test(tool.source_url) && Array.isArray(tool.profiles) && tool.profiles.length && tool.profiles.every(profile => Object.hasOwn(labels, profile)) && Array.isArray(tool.capabilities) && tool.capabilities.every(id => typeof id === "string") && Array.isArray(tool.platforms) && tool.platforms.includes("linux/amd64") && tool.platforms.includes("linux/arm64"); if (value.schema !== 1 || value.status !== "functional-checkpoint" || !Array.isArray(value.tools) || !value.tools.length || !Number.isInteger(value.capability_count) || !value.tools.every(validTool) || new Set(value.tools.map(tool => tool.id)).size !== value.tools.length || !/^https:\/\/github\.com\/s41r4j\/cybot\/actions\/runs\/\d+$/.test(value.validation_url)) { throw Error("Invalid tool checkpoint"); } data = value; render(); } catch { message.textContent = "The tool selection could not be verified."; const note = document.createElement("p"); note.className = "catalog-error"; note.append(document.createTextNode("Read the retained checkpoint and current limitations on the ")); const link = document.createElement("a"); link.href = "./release.html"; link.textContent = "release status page"; note.append(link, document.createTextNode(".")); grid.replaceChildren(note); more.hidden = true; } } initializeCatalog(); const copyInstall = document.querySelector("#copy-install"); copyInstall?.addEventListener("click", async () => { const feedback = document.querySelector("#copy-feedback"); try { await navigator.clipboard.writeText(document.querySelector("#install-command").textContent); feedback.textContent = "Install command copied."; } catch { feedback.textContent = "Select and copy the install command above."; const range = document.createRange(); range.selectNodeContents(document.querySelector("#install-command")); const selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); } });