WebOrbiton
v1.5.0

AtheraStudio Code

412 lines · 21.2 KB
  1. (function () {
  2. "use strict";
  3. ​
  4. var A = window.Athera;
  5. var util = A.util;
  6. var ai = A.ai;
  7. var t = ai.t;
  8. ​
  9. var HISTORY_KEY = "ai.eval.history";
  10. var HISTORY_MAX = 20;
  11. ​
  12. var PAGE = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>{title}</title>\n<link rel=\"stylesheet\" href=\"style.css\">\n</head>\n<body>\n{body}\n</body>\n</html>\n";
  13. ​
  14. function page(title, body) {
  15. return PAGE.replace("{title}", title).replace("{body}", body);
  16. }
  17. ​
  18. function has(re) {
  19. return function (c) { return re.test(c.all); };
  20. }
  21. ​
  22. function noLayout(types) {
  23. return function (c) {
  24. if (!c.layout) return null;
  25. return !c.layout.issues.some(function (i) { return types.indexOf(i.type) >= 0; });
  26. };
  27. }
  28. ​
  29. var TASKS = [
  30. {
  31. id: "landing",
  32. page: "index.html",
  33. seed: {},
  34. prompt: "Create a one-page landing page for a small local bakery called \"Pod Kłosem\" in {dir}: index.html and style.css only. Sections: header with logo text and navigation, hero with a call to action, three offer cards, opening hours, contact with address and phone, footer. Mobile-first CSS with custom properties, no frameworks, no external resources. Use realistic but short Polish texts.",
  35. checks: [
  36. ["files", function (c) { return !!c.files["index.html"] && !!c.files["style.css"]; }],
  37. ["viewport", has(/<meta[^>]+name=["']viewport/i)],
  38. ["one_h1", function (c) { return (c.files["index.html"] || "").split(/<h1[\s>]/i).length === 2; }],
  39. ["landmarks", has(/<header[\s>][\s\S]*<main[\s>][\s\S]*<footer[\s>]/i)],
  40. ["custom_props", has(/--[\w-]+\s*:/)],
  41. ["no_errors", function (c) { return !c.errors.length; }],
  42. ["mobile_layout", noLayout(["horizontal_overflow", "missing_viewport_meta"])]
  43. ]
  44. },
  45. {
  46. id: "nav",
  47. page: "index.html",
  48. seed: { "index.html": page("Nav", "<header>\n <a href=\"#\">Logo</a>\n <ul>\n <li><a href=\"#\">Home</a></li>\n <li><a href=\"#\">Offer</a></li>\n <li><a href=\"#\">About</a></li>\n <li><a href=\"#\">Contact</a></li>\n </ul>\n</header>\n<main><h1>Page</h1></main>"), "style.css": "header ul { display: flex; gap: 40px; list-style: none; }\n" },
  49. prompt: "Turn the header in {dir}/index.html into an accessible responsive navigation: on phones a menu button (with aria-expanded and aria-controls) shows and hides the links, on wider screens the links are inline. Use a <nav> element, vanilla JS in a small script and mobile-first CSS in {dir}/style.css. Keep it keyboard accessible.",
  50. checks: [
  51. ["nav_element", has(/<nav[\s>]/i)],
  52. ["menu_button", has(/<button[^>]*aria-expanded/i)],
  53. ["aria_controls", has(/aria-controls\s*=/i)],
  54. ["media_query", has(/@media/i)],
  55. ["no_errors", function (c) { return !c.errors.length; }],
  56. ["mobile_layout", noLayout(["horizontal_overflow", "small_tap_target", "empty_button"])]
  57. ]
  58. },
  59. {
  60. id: "php_form",
  61. page: null,
  62. seed: {},
  63. prompt: "Create {dir}/contact.php: a contact form (name, e-mail, message) that posts to itself, validates input on the server (required fields, valid e-mail, length limits), shows errors next to the fields, keeps entered values, protects against CSRF with a session token, escapes all output and on success shows a thank-you message (do not send real e-mail; put the sending in a clearly marked function). Plain PHP 8, no frameworks.",
  64. checks: [
  65. ["files", function (c) { return !!c.files["contact.php"]; }],
  66. ["csrf", has(/csrf|_token/i)],
  67. ["session", has(/session_start\s*\(/)],
  68. ["escaping", has(/htmlspecialchars\s*\(/)],
  69. ["email_check", has(/FILTER_VALIDATE_EMAIL/)],
  70. ["labels", has(/<label[^>]+for=/i)],
  71. ["security", function (c) { return !c.security.length; }],
  72. ["no_errors", function (c) { return !c.errors.length; }]
  73. ]
  74. },
  75. {
  76. id: "css_bug",
  77. page: "index.html",
  78. seed: { "index.html": page("Bug", "<main class=\"wrap\">\n <h1>Offer</h1>\n <div class=\"row\"><div class=\"box\">One</div><div class=\"box\">Two</div><div class=\"box\">Three</div></div>\n <img src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='300'/%3E\" alt=\"Banner\" width=\"900\" height=\"300\">\n</main>"), "style.css": ".wrap { width: 1100px; margin: 0 auto; }\n.row { display: flex; }\n.box { flex: 0 0 360px; padding: 20px; background: #eee; }\n" },
  79. prompt: "On phones the page in {dir} scrolls horizontally. Find the cause and fix it in {dir}/style.css with minimal changes, keeping the desktop layout.",
  80. checks: [
  81. ["no_fixed_width", function (c) { return !/\.wrap\s*\{[^}]*(?:^|[\s;{])width\s*:\s*1100px/.test(c.files["style.css"] || ""); }],
  82. ["no_errors", function (c) { return !c.errors.length; }],
  83. ["mobile_layout", noLayout(["horizontal_overflow", "overflow_source"])]
  84. ]
  85. },
  86. {
  87. id: "dark_mode",
  88. page: "index.html",
  89. seed: { "index.html": page("Dark", "<header><h1>Studio</h1></header>\n<main><p>Welcome to our studio.</p><a class=\"btn\" href=\"#\">Contact</a></main>"), "style.css": "body { background: #ffffff; color: #1a1a1a; font-family: system-ui, sans-serif; }\n.btn { background: #1d4ed8; color: #ffffff; padding: 10px 16px; border-radius: 6px; }\n" },
  90. prompt: "Add a dark mode to {dir}: move the colours in {dir}/style.css to CSS custom properties and switch them with prefers-color-scheme: dark. Keep good contrast in both themes.",
  91. checks: [
  92. ["custom_props", has(/--[\w-]+\s*:/)],
  93. ["color_scheme", has(/prefers-color-scheme\s*:\s*dark/i)],
  94. ["uses_vars", has(/var\(--/)],
  95. ["no_errors", function (c) { return !c.errors.length; }],
  96. ["contrast", noLayout(["low_contrast"])]
  97. ]
  98. },
  99. {
  100. id: "seo",
  101. page: "index.html",
  102. seed: { "index.html": "<html>\n<head>\n<title>Home</title>\n</head>\n<body>\n<h1>Plumber</h1>\n<h1>Services</h1>\n<p>We fix pipes in Kraków. <a href=\"services.html\">Click here</a></p>\n<img src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'/%3E\">\n</body>\n</html>\n" },
  103. prompt: "Do an SEO pass on {dir}/index.html (a local plumber in Kraków): fix the document structure and add what a small business page needs. Do not invent facts like phone numbers; use clearly marked placeholders where needed.",
  104. checks: [
  105. ["doctype", has(/<!doctype html>/i)],
  106. ["lang", has(/<html[^>]+lang=/i)],
  107. ["description", has(/<meta[^>]+name=["']description/i)],
  108. ["viewport", has(/<meta[^>]+name=["']viewport/i)],
  109. ["og", has(/property=["']og:title/i)],
  110. ["one_h1", function (c) { return (c.files["index.html"] || "").split(/<h1[\s>]/i).length === 2; }],
  111. ["alt", has(/<img[^>]+alt=/i)],
  112. ["link_text", function (c) { return !/>\s*click here\s*</i.test(c.files["index.html"] || ""); }]
  113. ]
  114. },
  115. {
  116. id: "a11y",
  117. page: "index.html",
  118. seed: { "index.html": page("A11y", "<div class=\"top\"><div onclick=\"location='#'\">Menu</div></div>\n<h1>Newsletter</h1>\n<img src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'/%3E\">\n<form><input type=\"email\" placeholder=\"E-mail\"><div class=\"send\" onclick=\"\">Send</div></form>\n<p class=\"note\">We never share your e-mail.</p>"), "style.css": ".note { color: #bbbbbb; }\n.send { display: inline-block; padding: 4px; background: #ddd; }\n" },
  119. prompt: "Do an accessibility pass (WCAG 2.2 AA) on {dir}: semantic elements instead of clickable divs, labels, alt text, contrast, focus styles and keyboard access. Change {dir}/index.html and {dir}/style.css.",
  120. checks: [
  121. ["label", has(/<label[\s>]/i)],
  122. ["button", has(/<button[\s>]/i)],
  123. ["alt", has(/<img[^>]+alt=/i)],
  124. ["focus", has(/:focus(-visible)?/i)],
  125. ["no_click_div", function (c) { return !/<div[^>]+onclick/i.test(c.files["index.html"] || ""); }],
  126. ["no_errors", function (c) { return !c.errors.length; }],
  127. ["page_checks", noLayout(["img_no_alt", "unlabelled_field", "low_contrast", "empty_button"])]
  128. ]
  129. },
  130. {
  131. id: "viewer_fix",
  132. page: "index.html",
  133. viewer: true,
  134. seed: { "index.html": page("Cards", "<main>\n <h1>Team</h1>\n <section class=\"grid\"><article>Ann</article><article>Bob</article><article>Eve</article></section>\n <p><a class=\"tiny\" href=\"#\">i</a></p>\n</main>"), "style.css": ".grid { display: grid; grid-template-columns: repeat(3, 300px); gap: 24px; }\n.tiny { display: inline-block; width: 12px; height: 12px; font-size: 8px; }\n" },
  135. prompt: "Open {dir}/index.html in the preview, set a phone viewport and use the preview tools (layout check, inspect) to find the layout problems, then fix them in {dir}/style.css and verify with the layout check again.",
  136. checks: [
  137. ["no_errors", function (c) { return !c.errors.length; }],
  138. ["mobile_layout", noLayout(["horizontal_overflow", "overflow_source", "small_tap_target"])]
  139. ]
  140. }
  141. ];
  142. ​
  143. var running = null;
  144. ​
  145. function configSummary() {
  146. var roles = {};
  147. ai.ROLES.forEach(function (r) {
  148. var c = ai.candidates(r)[0];
  149. roles[r] = c ? c.model : "-";
  150. });
  151. return { mode: ai.get("mode"), efficiency: ai.get("efficiency"), cheap: ai.get("cheap"), roles: roles };
  152. }
  153. ​
  154. function stamp() {
  155. var d = new Date();
  156. var p = function (n) { return n < 10 ? "0" + n : String(n); };
  157. return d.getFullYear() + p(d.getMonth() + 1) + p(d.getDate()) + "-" + p(d.getHours()) + p(d.getMinutes()) + p(d.getSeconds());
  158. }
  159. ​
  160. async function readDir(dir) {
  161. var files = {};
  162. try {
  163. for (var e of await ai.tools.io.list(dir)) {
  164. if (e.kind === "file") files[e.name] = await ai.tools.io.read(dir + "/" + e.name);
  165. }
  166. } catch (err) { }
  167. return files;
  168. }
  169. ​
  170. async function layoutOf(path) {
  171. if (!path || !A.preview || !ai.viewer) return null;
  172. var hadTab = !!A.tabs.byPath(path);
  173. try {
  174. var before = A.preview.buildId();
  175. await A.preview.openRoute(path);
  176. var end = Date.now() + 12000;
  177. while (Date.now() < end && !(A.preview.status().ready && A.preview.buildId() > before)) await new Promise(function (r) { setTimeout(r, 100); });
  178. if (!A.preview.status().ready) return null;
  179. A.preview.setViewport(ai.get("preview.mobile"), 740, t("ai.eval.title"));
  180. await new Promise(function (r) { setTimeout(r, 450); });
  181. var result = await ai.viewer.request("layout_check", {}, 10000);
  182. return result;
  183. } catch (e) {
  184. return null;
  185. } finally {
  186. A.preview.clearViewport();
  187. var opened = A.tabs.byPath(path);
  188. if (!hadTab && opened) await A.tabs.close(opened, true);
  189. }
  190. }
  191. ​
  192. async function runTask(task, root, onEvent, signal) {
  193. var dir = root + "/" + task.id;
  194. for (var name of Object.keys(task.seed)) await ai.tools.io.write(dir + "/" + name, task.seed[name]);
  195. var started = Date.now();
  196. var result = { id: task.id, cost: 0, known: true, calls: 0, model: "", ms: 0, checks: [], score: 0, error: null };
  197. var models = {};
  198. try {
  199. var r = await ai.agent.run({
  200. text: task.prompt.replace(/\{dir\}/g, dir),
  201. history: [],
  202. editorContext: false,
  203. preview: false,
  204. check: false,
  205. kind: "eval",
  206. signal: signal,
  207. autoApprovePrefix: dir + "/",
  208. onEvent: function (e) {
  209. if (e.type === "usage" && e.result) models[e.result.model] = true;
  210. onEvent(e);
  211. }
  212. });
  213. result.cost = r.cost;
  214. result.known = r.costKnown;
  215. result.calls = r.calls;
  216. } catch (e) {
  217. if (e.name === "AbortError") throw e;
  218. result.error = e.message;
  219. result.cost = e.partialCost || 0;
  220. }
  221. result.ms = Date.now() - started;
  222. result.model = Object.keys(models).join(", ");
  223. var files = await readDir(dir);
  224. var all = Object.keys(files).map(function (k) { return files[k]; }).join("\n");
  225. var quality = await ai.quality.check(Object.keys(files).map(function (k) { return dir + "/" + k; }));
  226. var ctx = {
  227. files: files,
  228. all: all,
  229. errors: quality.problems.filter(function (p) { return p.severity === "error" && !p.security; }),
  230. security: quality.problems.filter(function (p) { return p.security; }),
  231. layout: task.page && ai.allowed("preview") ? await layoutOf(dir + "/" + task.page) : null
  232. };
  233. var passed = 0, counted = 0;
  234. task.checks.forEach(function (c) {
  235. var v = null;
  236. try { v = c[1](ctx); } catch (e) { v = false; }
  237. result.checks.push({ id: c[0], ok: v });
  238. if (v === null) return;
  239. counted++;
  240. if (v) passed++;
  241. });
  242. result.score = counted ? Math.round((passed / counted) * 100) : 0;
  243. result.layoutIssues = ctx.layout ? ctx.layout.issues.length : null;
  244. return result;
  245. }
  246. ​
  247. async function run(ids, onProgress) {
  248. if (running) throw new Error(t("ai.eval.busy"));
  249. ai.assertNetwork();
  250. if (!ai.allowed("read") || !ai.allowed("write")) throw new Error(t("ai.eval.need_perms"));
  251. if (!A.fs.provider) throw new Error(t("ai.priv.no_folder"));
  252. if (!(await ai.private.ensure())) throw new Error(t("ai.tool.err_private_declined"));
  253. var ctrl = new AbortController();
  254. running = { ctrl: ctrl };
  255. var root = ".private/sandbox/eval-" + stamp();
  256. var report = { at: Date.now(), root: root, config: configSummary(), tasks: [], cost: 0, known: true, score: 0, aborted: false };
  257. try {
  258. for (var task of TASKS.filter(function (x) { return ids.indexOf(x.id) >= 0; })) {
  259. onProgress({ type: "task", id: task.id, report: report });
  260. var res = await runTask(task, root, function (e) { onProgress({ type: "event", id: task.id, event: e }); }, ctrl.signal);
  261. report.tasks.push(res);
  262. report.cost += res.cost;
  263. if (!res.known) report.known = false;
  264. onProgress({ type: "done", id: task.id, result: res, report: report });
  265. }
  266. } catch (e) {
  267. if (e.name !== "AbortError") throw e;
  268. report.aborted = true;
  269. } finally {
  270. running = null;
  271. if (A.explorer) {
  272. try { await A.explorer.refresh(null); } catch (e) { A.emit("files-changed"); }
  273. } else {
  274. A.emit("files-changed");
  275. }
  276. }
  277. report.score = report.tasks.length ? Math.round(report.tasks.reduce(function (n, x) { return n + x.score; }, 0) / report.tasks.length) : 0;
  278. var history = (await A.idb.get(HISTORY_KEY)) || [];
  279. history.push(report);
  280. while (history.length > HISTORY_MAX) history.shift();
  281. await A.idb.set(HISTORY_KEY, history);
  282. return report;
  283. }
  284. ​
  285. ai.eval = {
  286. TASKS: TASKS,
  287. run: run,
  288. stop: function () { if (running) running.ctrl.abort(); },
  289. busy: function () { return !!running; },
  290. history: async function () { return ((await A.idb.get(HISTORY_KEY)) || []).slice().reverse(); },
  291. clearHistory: function () { return A.idb.set(HISTORY_KEY, []); }
  292. };
  293. ​
  294. var ui = A.aiUi;
  295. var el = ui.el;
  296. var state = { selected: TASKS.map(function (x) { return x.id; }), log: "", report: null };
  297. ​
  298. function money(cost, known) {
  299. return ai.budget.format(cost) + (known === false ? " + ?" : "");
  300. }
  301. ​
  302. function configText(c) {
  303. return t("ai.eval.config_line", {
  304. mode: c.mode === "auto" ? t("ai.model.mode_auto") : ai.providerLabel(c.mode),
  305. efficiency: t("ai.eff." + c.efficiency),
  306. cheap: c.cheap ? " · " + t("ai.model.cheap") : "",
  307. models: ai.ROLES.map(function (r) { return t("ai.role." + r) + ": " + c.roles[r]; }).join(", ")
  308. });
  309. }
  310. ​
  311. function resultTable(report) {
  312. var rows = report.tasks.map(function (r) {
  313. var failed = r.checks.filter(function (c) { return c.ok === false; }).map(function (c) { return t("ai.eval.check_" + c.id); });
  314. var skipped = r.checks.some(function (c) { return c.ok === null; });
  315. return el("tr", {}, [
  316. el("td", {}, t("ai.eval.task_" + r.id)),
  317. el("td", { class: "ath-ai-eval-score is-" + (r.score >= 80 ? "good" : r.score >= 50 ? "mid" : "bad") }, r.score + "%"),
  318. el("td", {}, money(r.cost, r.known)),
  319. el("td", {}, Math.round(r.ms / 1000) + " s"),
  320. el("td", { class: "ath-ai-eval-model" }, r.model || "-"),
  321. el("td", { class: "ath-ai-eval-notes" }, (r.error ? r.error + " " : "") + (failed.length ? t("ai.eval.failed", { list: failed.join(", ") }) : t("ai.eval.all_passed")) + (skipped ? " " + t("ai.eval.skipped") : ""))
  322. ]);
  323. });
  324. rows.push(el("tr", { class: "is-total" }, [
  325. el("td", {}, t("ai.eval.total")),
  326. el("td", {}, (report.tasks.length ? Math.round(report.tasks.reduce(function (n, x) { return n + x.score; }, 0) / report.tasks.length) : 0) + "%"),
  327. el("td", {}, money(report.cost, report.known)),
  328. el("td", {}, ""), el("td", {}, ""), el("td", {}, report.aborted ? t("ai.eval.aborted") : "")
  329. ]));
  330. return el("div", { class: "ath-ai-table-wrap" }, el("table", { class: "orb-table ath-ai-eval-table" }, [
  331. el("thead", {}, el("tr", {}, ["task", "score", "cost", "time", "model", "notes"].map(function (k) { return el("th", {}, t("ai.eval.col_" + k)); }))),
  332. el("tbody", {}, rows)
  333. ]));
  334. }
  335. ​
  336. ui.section({
  337. id: "eval",
  338. order: 115,
  339. icon: "lightbulb",
  340. label: "ai.sec.eval",
  341. hidden: function () { return !ai.get("evalPanel"); },
  342. render: async function (box) {
  343. box.appendChild(ui.hint(t("ai.eval.intro")));
  344. box.appendChild(ui.alert("warning", null, t("ai.eval.warning")));
  345. box.appendChild(ui.heading(t("ai.eval.config")));
  346. box.appendChild(ui.hint(configText(configSummary())));
  347. if (!ai.allowed("preview")) box.appendChild(ui.hint(t("ai.eval.no_preview")));
  348. box.appendChild(ui.heading(t("ai.eval.tasks")));
  349. var list = el("div", { class: "ath-ai-eval-tasks" });
  350. TASKS.forEach(function (task) {
  351. var cb = el("input", { type: "checkbox" });
  352. cb.checked = state.selected.indexOf(task.id) >= 0;
  353. cb.addEventListener("change", function () {
  354. state.selected = cb.checked ? state.selected.concat([task.id]) : state.selected.filter(function (x) { return x !== task.id; });
  355. });
  356. list.appendChild(el("label", { class: "orb-checkbox" }, [cb, el("span", {}, t("ai.eval.task_" + task.id))]));
  357. });
  358. box.appendChild(list);
  359. var progress = el("p", { class: "ath-ai-eval-progress", "aria-live": "polite" }, state.log);
  360. var resultBox = el("div", {}, state.report ? resultTable(state.report) : null);
  361. var runBtn = ui.button(t(ai.eval.busy() ? "ai.eval.stop" : "ai.eval.run"), ai.eval.busy() ? "danger" : "primary", async function () {
  362. if (ai.eval.busy()) return ai.eval.stop();
  363. if (!state.selected.length) return A.ui.toast(t("ai.eval.none_selected"), "info");
  364. if (!ai.enabled() && !(await ai.enable())) return;
  365. var month = await ai.budget.month();
  366. var ok = await A.ui.confirm(t("ai.eval.title"), t("ai.eval.confirm", { n: state.selected.length, spent: ai.budget.format(month.cost), limit: ai.get("budget.monthly") > 0 ? ai.budget.format(ai.get("budget.monthly")) : "-" }), t("ai.eval.run"), false);
  367. if (!ok) return;
  368. state.report = null;
  369. resultBox.innerHTML = "";
  370. runBtn.querySelector("span").textContent = t("ai.eval.stop");
  371. runBtn.classList.replace("orb-btn-primary", "orb-btn-danger");
  372. try {
  373. var report = await ai.eval.run(state.selected.slice(), function (p) {
  374. if (p.type === "task") state.log = t("ai.eval.running", { task: t("ai.eval.task_" + p.id), n: p.report.tasks.length + 1, total: state.selected.length });
  375. if (p.type === "event" && p.event.type === "tool_run") state.log = t("ai.eval.running_tool", { task: t("ai.eval.task_" + p.id), tool: p.event.name });
  376. if (p.type === "done") {
  377. resultBox.innerHTML = "";
  378. resultBox.appendChild(resultTable(p.report));
  379. }
  380. progress.textContent = state.log;
  381. });
  382. state.report = report;
  383. state.log = t("ai.eval.finished", { score: report.score, cost: money(report.cost, report.known), dir: report.root });
  384. } catch (e) {
  385. state.log = e.message;
  386. }
  387. ui.refresh();
  388. }, ai.eval.busy() ? "x" : "power");
  389. box.appendChild(el("div", { class: "ath-ai-actions" }, [runBtn, ui.button(t("ai.eval.hide"), "ghost", function () {
  390. ai.set("evalPanel", false);
  391. A.aiUi.open("model");
  392. })]));
  393. box.appendChild(progress);
  394. box.appendChild(resultBox);
  395. var history = await ai.eval.history();
  396. box.appendChild(ui.heading(t("ai.eval.history")));
  397. if (!history.length) box.appendChild(el("p", { class: "ath-set-empty" }, t("ai.eval.history_empty")));
  398. else {
  399. box.appendChild(el("div", { class: "ath-ai-eval-history" }, history.map(function (h) {
  400. return el("div", { class: "ath-ai-eval-run" }, [
  401. el("strong", {}, h.score + "% · " + money(h.cost, h.known) + " · " + h.tasks.length + " " + t("ai.eval.tasks_short")),
  402. el("small", {}, new Date(h.at).toLocaleString(document.documentElement.lang || undefined) + " · " + configText(h.config))
  403. ]);
  404. })));
  405. box.appendChild(el("div", { class: "ath-ai-actions" }, [ui.button(t("ai.eval.clear"), "ghost", function () {
  406. ai.eval.clearHistory().then(function () { ui.refresh(); });
  407. }, "trash")]));
  408. }
  409. }
  410. });
  411. })();
  412. ​