scorpiox-bot-plugin-websearch
←ui_html.hc
340 lines · 18 KBHEADBlameDownload
1/* Generated by tools/gen_ui.py from src/ui.html. Do not edit by hand. */
2#ifndef SX_WEBSEARCH_UI_HTML_H
3#define SX_WEBSEARCH_UI_HTML_H
4
5static const char *UI_HTML =
6 "<!DOCTYPE html>\n"
7 "<html lang=\"en\"><head><meta charset=\"utf-8\">\n"
8 "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n"
9 "<title>websearch</title>\n"
10 "\001\n"
11 "<style>\n"
12 "*{box-sizing:border-box}\n"
13 "html,body{margin:0}\n"
14 "body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px;\n"
15 " line-height:1.5;-webkit-font-smoothing:antialiased}\n"
16 ".wrap{max-width:1100px;margin:0 auto;padding:16px}\n"
17 ".head{display:flex;align-items:center;gap:12px;margin-bottom:14px;flex-wrap:wrap}\n"
18 "h1{font-size:20px;margin:0;font-weight:650;letter-spacing:-.01em}\n"
19 ".sub{color:var(--mu);font-size:12.5px}\n"
20 ".spacer{flex:1}\n"
21 ".card{background:var(--surface);border:1px solid var(--ln);border-radius:14px;\n"
22 " padding:16px;margin-bottom:14px}\n"
23 ".card h2{font-size:13px;font-weight:650;margin:0 0 12px;color:var(--mu);\n"
24 " text-transform:uppercase;letter-spacing:.06em}\n"
25 ".row{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end}\n"
26 ".f{display:flex;flex-direction:column;gap:4px;min-width:140px;flex:1 1 160px}\n"
27 "label{font-size:11.5px;color:var(--mu);text-transform:uppercase;letter-spacing:.05em}\n"
28 "input,select{background:var(--input-bg);border:1px solid var(--ln);color:var(--text);\n"
29 " border-radius:9px;padding:7px 10px;font-size:13.5px;font-family:var(--font);\n"
30 " outline:none;min-width:0;width:100%}\n"
31 "input:focus,select:focus{border-color:var(--ac)}\n"
32 "button{background:var(--ac);color:#fff;border:0;border-radius:980px;padding:7px 16px;\n"
33 " font-size:13px;font-weight:600;cursor:pointer;font-family:var(--font);white-space:nowrap}\n"
34 "button.ghost{background:var(--surface-2);color:var(--text)}\n"
35 "button.mini{padding:4px 11px;font-size:12px}\n"
36 "button:active{transform:scale(.98)}\n"
37 "button:disabled{opacity:.55;cursor:default}\n"
38 ".providers{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:10px}\n"
39 ".prov{border:1px solid var(--ln);border-radius:12px;padding:12px;background:var(--surface-2);\n"
40 " cursor:pointer;transition:border-color .15s var(--ease),transform .15s var(--ease)}\n"
41 ".prov:hover{border-color:var(--ln2)}\n"
42 ".prov.on{border-color:var(--ac);box-shadow:0 0 0 1px var(--ac) inset}\n"
43 ".prov-top{display:flex;align-items:center;gap:8px;margin-bottom:4px}\n"
44 ".prov-name{font-weight:650;font-size:14px}\n"
45 ".prov-hint{color:var(--mu);font-size:12px}\n"
46 ".pill{font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;\n"
47 " border-radius:980px;padding:2px 8px;border:1px solid var(--ln);color:var(--mu)}\n"
48 ".pill.ok{color:var(--ok);border-color:color-mix(in srgb,var(--ok) 45%,transparent)}\n"
49 ".pill.miss{color:var(--warn);border-color:color-mix(in srgb,var(--warn) 45%,transparent)}\n"
50 ".pill.mcp{color:var(--ac);border-color:color-mix(in srgb,var(--ac) 45%,transparent)}\n"
51 ".results{margin-top:12px;display:flex;flex-direction:column;gap:10px}\n"
52 ".res{border:1px solid var(--ln);border-radius:12px;padding:12px;background:var(--surface-2)}\n"
53 ".res a{color:var(--ac);font-weight:650;font-size:14px;word-break:break-word}\n"
54 ".res .site{color:var(--mu);font-size:11.5px;margin-left:6px}\n"
55 ".res p{margin:6px 0 0;color:var(--tx);font-size:13px;opacity:.9}\n"
56 ".answer{border-left:3px solid var(--ac);padding:8px 12px;background:var(--surface-2);\n"
57 " border-radius:8px;margin-bottom:10px;font-size:13.5px;white-space:pre-wrap}\n"
58 ".meta{color:var(--mu);font-size:12px;margin-top:8px}\n"
59 ".err{color:var(--err);font-size:13px;margin-top:10px;white-space:pre-wrap;word-break:break-word}\n"
60 ".hint{color:var(--mu);font-size:12px;margin-top:6px}\n"
61 ".hint code{font-family:var(--mono);font-size:11.5px;background:var(--code-bg);\n"
62 " padding:1px 5px;border-radius:5px}\n"
63 ".kv{display:grid;grid-template-columns:1fr 1fr;gap:10px}\n"
64 "@media(max-width:700px){.kv{grid-template-columns:1fr}.wrap{padding:12px}}\n"
65 ".spin{display:inline-block;width:12px;height:12px;border:2px solid var(--ln2);\n"
66 " border-top-color:var(--ac);border-radius:50%;animation:sp .7s linear infinite;\n"
67 " vertical-align:-2px;margin-right:6px}\n"
68 "@keyframes sp{to{transform:rotate(360deg)}}\n"
69 "</style>\n"
70 "</head>\n"
71 "<body>\n"
72 "<div class=\"wrap\">\n"
73 " <div class=\"head\">\n"
74 " <div>\n"
75 " <h1>Web search</h1>\n"
76 " <div class=\"sub\">Six backends, one tool: <code>web_search</code></div>\n"
77 " </div>\n"
78 " <div class=\"spacer\"></div>\n"
79 " <button class=\"ghost embed-hide\" id=\"themeToggle\" type=\"button\">Theme</button>\n"
80 " </div>\n"
81 "\n"
82 " <div class=\"card\">\n"
83 " <h2>Backends</h2>\n"
84 " <div class=\"providers\" id=\"providers\"></div>\n"
85 " <div class=\"hint\">Click a backend to make it the default. Providers that need a key stay\n"
86 " selectable &mdash; the search below will tell you exactly what is missing.</div>\n"
87 " </div>\n"
88 "\n"
89 " <div class=\"card\">\n"
90 " <h2>Search</h2>\n"
91 " <div class=\"row\">\n"
92 " <div class=\"f\" style=\"flex:2 1 280px\">\n"
93 " <label for=\"q\">Query</label>\n"
94 " <input id=\"q\" type=\"text\" placeholder=\"what are you looking for?\" autocomplete=\"off\">\n"
95 " </div>\n"
96 " <div class=\"f\" style=\"flex:0 1 110px\">\n"
97 " <label for=\"count\">Results</label>\n"
98 " <input id=\"count\" type=\"number\" min=\"1\" max=\"20\" value=\"5\">\n"
99 " </div>\n"
100 " <div class=\"f\" style=\"flex:0 1 150px\">\n"
101 " <label for=\"providerSel\">Backend</label>\n"
102 " <select id=\"providerSel\"></select>\n"
103 " </div>\n"
104 " <div class=\"f\" style=\"flex:0 0 auto\">\n"
105 " <label>&nbsp;</label>\n"
106 " <button id=\"go\" type=\"button\">Search</button>\n"
107 " </div>\n"
108 " </div>\n"
109 " <div class=\"meta\" id=\"runMeta\"></div>\n"
110 " <div class=\"err\" id=\"err\"></div>\n"
111 " <div class=\"results\" id=\"results\"></div>\n"
112 " </div>\n"
113 "\n"
114 " <div class=\"card\">\n"
115 " <h2>Keys &amp; defaults</h2>\n"
116 " <div class=\"kv\">\n"
117 " <div class=\"f\"><label for=\"k_brave\">Brave API key</label>\n"
118 " <input id=\"k_brave\" type=\"password\" placeholder=\"unset\" autocomplete=\"off\">\n"
119 " <span class=\"hint\" id=\"h_brave\"></span></div>\n"
120 " <div class=\"f\"><label for=\"k_tavily\">Tavily API key</label>\n"
121 " <input id=\"k_tavily\" type=\"password\" placeholder=\"unset\" autocomplete=\"off\">\n"
122 " <span class=\"hint\" id=\"h_tavily\"></span></div>\n"
123 " <div class=\"f\"><label for=\"k_exa\">Exa API key</label>\n"
124 " <input id=\"k_exa\" type=\"password\" placeholder=\"unset\" autocomplete=\"off\">\n"
125 " <span class=\"hint\" id=\"h_exa\"></span></div>\n"
126 " <div class=\"f\"><label for=\"k_pplx\">Perplexity API key</label>\n"
127 " <input id=\"k_pplx\" type=\"password\" placeholder=\"unset\" autocomplete=\"off\">\n"
128 " <span class=\"hint\" id=\"h_pplx\"></span></div>\n"
129 " <div class=\"f\"><label for=\"searxng\">SearXNG base URL</label>\n"
130 " <input id=\"searxng\" type=\"text\" placeholder=\"http://127.0.0.1:8888\" autocomplete=\"off\">\n"
131 " <span class=\"hint\">Self-hosted instance with <code>format=json</code> enabled.</span></div>\n"
132 " <div class=\"f\"><label for=\"region\">DuckDuckGo region</label>\n"
133 " <input id=\"region\" type=\"text\" placeholder=\"nz-en (empty = default)\" autocomplete=\"off\">\n"
134 " <span class=\"hint\">Two-letter region plus language, e.g. <code>nz-en</code>.</span></div>\n"
135 " <div class=\"f\"><label for=\"safe\">Safe search</label>\n"
136 " <select id=\"safe\">\n"
137 " <option value=\"strict\">Strict</option>\n"
138 " <option value=\"moderate\">Moderate</option>\n"
139 " <option value=\"off\">Off</option>\n"
140 " </select></div>\n"
141 " <div class=\"f\"><label for=\"language\">Language</label>\n"
142 " <input id=\"language\" type=\"text\" placeholder=\"en (empty = provider default)\" autocomplete=\"off\"></div>\n"
143 " <div class=\"f\"><label for=\"categories\">SearXNG categories</label>\n"
144 " <input id=\"categories\" type=\"text\" placeholder=\"general\" autocomplete=\"off\"></div>\n"
145 " <div class=\"f\"><label for=\"tavily_answer\">Tavily answer</label>\n"
146 " <select id=\"tavily_answer\">\n"
147 " <option value=\"0\">Off</option>\n"
148 " <option value=\"1\">On</option>\n"
149 " </select></div>\n"
150 " </div>\n"
151 " <div class=\"row\" style=\"margin-top:14px\">\n"
152 " <button id=\"save\" type=\"button\">Save</button>\n"
153 " <button class=\"ghost\" id=\"clearKeys\" type=\"button\">Clear all keys</button>\n"
154 " <div class=\"spacer\"></div>\n"
155 " <span class=\"meta\" id=\"saveMeta\"></span>\n"
156 " </div>\n"
157 " <div class=\"hint\">Keys are written to <code>config.json</code> at mode <code>0600</code> in the\n"
158 " connector directory and are never sent back to this page &mdash; only whether one is set.</div>\n"
159 " </div>\n"
160 "\n"
161 " <div class=\"card\">\n"
162 " <h2>Agent tools</h2>\n"
163 " <div class=\"hint\"><code>web_search</code> takes <code>query</code>, and optionally\n"
164 " <code>provider</code>, <code>count</code>, <code>country</code>, <code>language</code> and\n"
165 " <code>freshness</code>. <code>web_search_providers</code> reports which backends are ready.\n"
166 " Both are served over MCP stdio through the single <code>sx-connector-mcp</code> router, so\n"
167 " nothing has to be restarted after a change here.</div>\n"
168 " </div>\n"
169 "</div>\n"
170 "<script>\n"
171 "(function () {\n"
172 " var P = null, active = 'duckduckgo';\n"
173 " function $(id) { return document.getElementById(id); }\n"
174 " function esc(s) {\n"
175 " return String(s == null ? '' : s).replace(/[&<>\"']/g, function (c) {\n"
176 " return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' }[c];\n"
177 " });\n"
178 " }\n"
179 " function pwd() {\n"
180 " var m = /[?&]pwd=([^&]*)/.exec(location.search);\n"
181 " return m ? 'pwd=' + encodeURIComponent(decodeURIComponent(m[1])) + '&' : '';\n"
182 " }\n"
183 " function api(suffix) {\n"
184 " return fetch('?action=' + suffix + '&' + pwd() + 'format=json',\n"
185 " { credentials: 'same-origin' })\n"
186 " .then(function (r) { return r.json(); });\n"
187 " }\n"
188 " function post(payload) {\n"
189 " return fetch('?' + pwd() + 'format=json', {\n"
190 " method: 'POST',\n"
191 " credentials: 'same-origin',\n"
192 " headers: { 'Content-Type': 'application/json' },\n"
193 " body: JSON.stringify(payload)\n"
194 " }).then(function (r) { return r.json(); });\n"
195 " }\n"
196 "\n"
197 " function renderProviders() {\n"
198 " var host = $('providers'), sel = $('providerSel'), html = '', opts = '';\n"
199 " (P.providers || []).forEach(function (p) {\n"
200 " var pill = p.ready\n"
201 " ? '<span class=\"pill ok\">' + (p.needs_key ? 'key set' : 'ready') + '</span>'\n"
202 " : '<span class=\"pill miss\">' + (p.needs_key ? 'no key' : 'no URL') + '</span>';\n"
203 " html += '<div class=\"prov' + (p.id === active ? ' on' : '') + '\" data-id=\"' + esc(p.id) + '\">' +\n"
204 " '<div class=\"prov-top\"><span class=\"prov-name\">' + esc(p.label) + '</span>' + pill + '</div>' +\n"
205 " '<div class=\"prov-hint\">' + esc(p.hint) + '</div>' +\n"
206 " (p.signup ? '<div class=\"prov-hint\"><a href=\"' + esc(p.signup) +\n"
207 " '\" target=\"_blank\" rel=\"noopener\">' +\n"
208 " (p.needs_key ? 'Get a key' : 'Info') + '</a></div>' : '') +\n"
209 " '</div>';\n"
210 " opts += '<option value=\"' + esc(p.id) + '\"' + (p.id === active ? ' selected' : '') + '>' +\n"
211 " esc(p.label) + '</option>';\n"
212 " });\n"
213 " host.innerHTML = html;\n"
214 " sel.innerHTML = opts;\n"
215 " Array.prototype.forEach.call(host.querySelectorAll('.prov'), function (el) {\n"
216 " el.onclick = function () {\n"
217 " active = el.getAttribute('data-id');\n"
218 " renderProviders();\n"
219 " $('providerSel').value = active;\n"
220 " };\n"
221 " });\n"
222 " }\n"
223 "\n"
224 " function fill(p) {\n"
225 " P = p;\n"
226 " active = p.active || 'duckduckgo';\n"
227 " renderProviders();\n"
228 " $('count').value = p.default_count || 5;\n"
229 " $('region').value = p.region || '';\n"
230 " $('safe').value = p.safe || 'moderate';\n"
231 " $('language').value = p.language || '';\n"
232 " $('categories').value = p.searxng_categories || 'general';\n"
233 " $('tavily_answer').value = p.tavily_answer ? '1' : '0';\n"
234 " (p.providers || []).forEach(function (x) {\n"
235 " var k = $('k_' + x.id.replace('perplexity', 'pplx'));\n"
236 " if (k) { k.value = ''; k.placeholder = x.has_key ? 'set (leave blank to keep)' : 'unset'; }\n"
237 " var h = $('h_' + x.id.replace('perplexity', 'pplx'));\n"
238 " if (h) h.textContent = x.has_key ? 'A key is saved on this node.' : 'No key saved.';\n"
239 " if (x.id === 'searxng') $('searxng').value = x.base || '';\n"
240 " });\n"
241 " }\n"
242 "\n"
243 " function search() {\n"
244 " var q = $('q').value.trim();\n"
245 " if (!q) { $('q').focus(); return; }\n"
246 " $('err').textContent = '';\n"
247 " $('results').innerHTML = '';\n"
248 " $('runMeta').innerHTML = '<span class=\"spin\"></span>searching with ' + esc($('providerSel').value) + '…';\n"
249 " $('go').disabled = true;\n"
250 " post({ action: 'search', q: q, provider: $('providerSel').value,\n"
251 " count: parseInt($('count').value, 10) || 5 })\n"
252 " .then(function (d) {\n"
253 " $('go').disabled = false;\n"
254 " if (!d || d.ok !== true) {\n"
255 " $('runMeta').textContent = '';\n"
256 " $('err').textContent = (d && d.error ? d.error : 'search failed') +\n"
257 " (d && d.status ? ' (HTTP ' + d.status + ')' : '');\n"
258 " return;\n"
259 " }\n"
260 " $('runMeta').textContent = d.count + ' result' + (d.count === 1 ? '' : 's') +\n"
261 " ' from ' + d.provider + ' in ' + d.took_ms + ' ms';\n"
262 " var html = '';\n"
263 " if (d.answer) html += '<div class=\"answer\">' + esc(d.answer) + '</div>';\n"
264 " (d.results || []).forEach(function (r) {\n"
265 " html += '<div class=\"res\">' +\n"
266 " '<div><a href=\"' + esc(r.url) + '\" target=\"_blank\" rel=\"noopener noreferrer\">' +\n"
267 " esc(r.title || r.url) + '</a>' +\n"
268 " (r.site ? '<span class=\"site\">' + esc(r.site) + '</span>' : '') + '</div>' +\n"
269 " (r.snippet ? '<p>' + esc(r.snippet) + '</p>' : '') +\n"
270 " (r.published ? '<div class=\"meta\">' + esc(r.published) + '</div>' : '') +\n"
271 " '</div>';\n"
272 " });\n"
273 " if (!d.count) html = '<div class=\"hint\">No results. Try a different backend or query.</div>';\n"
274 " $('results').innerHTML = html;\n"
275 " })\n"
276 " .catch(function (e) {\n"
277 " $('go').disabled = false;\n"
278 " $('runMeta').textContent = '';\n"
279 " $('err').textContent = String(e);\n"
280 " });\n"
281 " }\n"
282 "\n"
283 " function save() {\n"
284 " var body = {\n"
285 " action: 'save',\n"
286 " provider: active,\n"
287 " count: parseInt($('count').value, 10) || 5,\n"
288 " region: $('region').value,\n"
289 " safe: $('safe').value,\n"
290 " language: $('language').value,\n"
291 " searxng_categories: $('categories').value,\n"
292 " tavily_answer: $('tavily_answer').value === '1' ? 1 : 0,\n"
293 " searxng_base: $('searxng').value\n"
294 " };\n"
295 " [['brave', 'k_brave'], ['tavily', 'k_tavily'], ['exa', 'k_exa'],\n"
296 " ['pplx', 'k_pplx']].forEach(function (pair) {\n"
297 " var v = $(pair[1]).value.trim();\n"
298 " if (v) body[pair[0] + '_key'] = v;\n"
299 " });\n"
300 " $('saveMeta').innerHTML = '<span class=\"spin\"></span>saving…';\n"
301 " post(body).then(function (d) {\n"
302 " if (d && d.providers) { fill(d); $('saveMeta').textContent = 'Saved.'; }\n"
303 " else $('saveMeta').textContent = (d && d.error) ? d.error : 'Save failed.';\n"
304 " }).catch(function (e) { $('saveMeta').textContent = String(e); });\n"
305 " }\n"
306 "\n"
307 " function clearKeys() {\n"
308 " if (!confirm('Remove every saved API key from this node?')) return;\n"
309 " post({ action: 'save', clear_brave_key: 1, clear_tavily_key: 1,\n"
310 " clear_exa_key: 1, clear_pplx_key: 1 })\n"
311 " .then(function (d) { if (d && d.providers) { fill(d); $('saveMeta').textContent = 'Keys cleared.'; } });\n"
312 " }\n"
313 "\n"
314 " $('go').onclick = search;\n"
315 " $('q').addEventListener('keydown', function (e) { if (e.key === 'Enter') search(); });\n"
316 " $('save').onclick = save;\n"
317 " $('clearKeys').onclick = clearKeys;\n"
318 " $('providerSel').addEventListener('change', function () {\n"
319 " active = $('providerSel').value;\n"
320 " renderProviders();\n"
321 " $('providerSel').value = active;\n"
322 " });\n"
323 "\n"
324 " var tb = $('themeToggle');\n"
325 " if (tb) tb.onclick = function () {\n"
326 " var cur = document.documentElement.getAttribute('data-theme') === 'light' ? 'dark' : 'light';\n"
327 " document.documentElement.setAttribute('data-theme', cur);\n"
328 " try { localStorage.setItem('bot_theme', cur); } catch (e) {}\n"
329 " };\n"
330 "\n"
331 " api('config').then(fill).catch(function (e) {\n"
332 " $('err').textContent = 'cannot load the configuration: ' + e;\n"
333 " });\n"
334 "})();\n"
335 "</script>\n"
336 "\002</body>\n"
337 "</html>\n"
338 ;
339
340#endif /* SX_WEBSEARCH_UI_HTML_H */