| 1 | /* Generated by tools/gen_ui.py from src/ui.html. Do not edit by hand. */ |
| 2 | #ifndef SX_FILESYSTEM_UI_HTML_H |
| 3 | #define SX_FILESYSTEM_UI_HTML_H |
| 4 | |
| 5 | static 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>filesystem</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:1080px;margin:0 auto;padding:16px}\n" |
| 17 | ".card{background:var(--surface);border:1px solid var(--line);border-radius:14px;\n" |
| 18 | " padding:16px;margin-bottom:14px}\n" |
| 19 | "h1{font-size:17px;margin:0 0 2px;letter-spacing:-.01em}\n" |
| 20 | "h2{font-size:12px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;\n" |
| 21 | " color:var(--text-2);margin:0 0 12px}\n" |
| 22 | ".sub{color:var(--text-2);font-size:12.5px;margin:0 0 14px}\n" |
| 23 | ".grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:14px}\n" |
| 24 | "@media(max-width:860px){.grid{grid-template-columns:minmax(0,1fr)}}\n" |
| 25 | ".row{display:flex;gap:8px;align-items:center}\n" |
| 26 | ".row.wraprow{flex-wrap:wrap}\n" |
| 27 | "input[type=text]{flex:1;min-width:0;background:var(--input-bg);color:var(--text);\n" |
| 28 | " border:1px solid var(--line);border-radius:9px;padding:8px 10px;font-family:var(--mono);\n" |
| 29 | " font-size:12.5px;outline:none}\n" |
| 30 | "input[type=text]:focus{border-color:var(--blue)}\n" |
| 31 | "button{background:var(--surface-2);color:var(--text);border:1px solid var(--line);\n" |
| 32 | " border-radius:9px;padding:7px 12px;font-family:inherit;font-size:12.5px;font-weight:600;\n" |
| 33 | " cursor:pointer;flex:0 0 auto}\n" |
| 34 | "button:hover{background:var(--surface-hover);border-color:var(--line-2)}\n" |
| 35 | "button:active{transform:scale(.98)}\n" |
| 36 | "button.primary{background:var(--blue);border-color:transparent;color:#fff}\n" |
| 37 | "button.danger{color:var(--red)}\n" |
| 38 | "ul.roots{list-style:none;margin:0;padding:0}\n" |
| 39 | "ul.roots li{display:flex;align-items:center;gap:10px;padding:9px 10px;\n" |
| 40 | " border:1px solid var(--line);border-radius:10px;margin-bottom:7px;background:var(--bg-2)}\n" |
| 41 | "ul.roots li .p{flex:1;min-width:0;font-family:var(--mono);font-size:12.5px;\n" |
| 42 | " overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n" |
| 43 | "ul.roots li .note{font-size:11px;color:var(--text-2);flex:0 0 auto}\n" |
| 44 | "ul.roots li .note.warn{color:var(--orange)}\n" |
| 45 | "ul.roots li .note.bad{color:var(--red)}\n" |
| 46 | ".pill{font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;\n" |
| 47 | " padding:2px 7px;border-radius:980px;border:1px solid var(--line);color:var(--text-2);flex:0 0 auto}\n" |
| 48 | ".pill.rw{color:var(--green);border-color:rgba(48,209,88,.35)}\n" |
| 49 | ".pill.ro{color:var(--teal);border-color:rgba(100,210,255,.35)}\n" |
| 50 | "table.tools{width:100%;border-collapse:collapse;font-size:12.5px}\n" |
| 51 | "table.tools th{text-align:left;font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;\n" |
| 52 | " color:var(--text-2);font-weight:700;padding:0 8px 6px 0;border-bottom:1px solid var(--line)}\n" |
| 53 | "table.tools td{padding:7px 8px 7px 0;border-bottom:1px solid var(--line);vertical-align:top}\n" |
| 54 | "table.tools tr:last-child td{border-bottom:0}\n" |
| 55 | "table.tools td.n{font-family:var(--mono);font-size:12px;white-space:nowrap}\n" |
| 56 | "table.tools td.d{color:var(--text-2);font-size:11.5px}\n" |
| 57 | ".sw{position:relative;width:38px;height:22px;flex:0 0 auto;border-radius:980px;\n" |
| 58 | " background:var(--surface-2);border:1px solid var(--line);cursor:pointer;padding:0}\n" |
| 59 | ".sw[aria-checked=true]{background:var(--green);border-color:transparent}\n" |
| 60 | ".sw i{position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;\n" |
| 61 | " background:#fff;transition:transform .16s var(--ease)}\n" |
| 62 | ".sw[aria-checked=true] i{transform:translateX(16px)}\n" |
| 63 | "pre{margin:0;background:var(--code-bg);border:1px solid var(--line);border-radius:10px;\n" |
| 64 | " padding:10px 12px;font-family:var(--mono);font-size:11.5px;white-space:pre-wrap;\n" |
| 65 | " word-break:break-all;max-height:220px;overflow:auto}\n" |
| 66 | ".kv{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:12px;color:var(--text-2);margin:0 0 12px}\n" |
| 67 | ".kv b{color:var(--text);font-weight:600;font-family:var(--mono)}\n" |
| 68 | ".msg{font-size:12.5px;padding:8px 10px;border-radius:9px;margin:0 0 10px;display:none}\n" |
| 69 | ".msg.show{display:block}\n" |
| 70 | ".msg.ok{background:rgba(48,209,88,.12);color:var(--green);border:1px solid rgba(48,209,88,.3)}\n" |
| 71 | ".msg.err{background:rgba(255,69,58,.12);color:var(--red);border:1px solid rgba(255,69,58,.3)}\n" |
| 72 | ".msg.warn{background:rgba(255,159,10,.12);color:var(--orange);border:1px solid rgba(255,159,10,.3)}\n" |
| 73 | "a{color:var(--blue);text-decoration:none}\n" |
| 74 | ".hint{font-size:11.5px;color:var(--text-2);margin:8px 0 0}\n" |
| 75 | ".nomargin{margin-bottom:0}\n" |
| 76 | "</style>\n" |
| 77 | "</head><body>\n" |
| 78 | "<div class=\"wrap\">\n" |
| 79 | "\n" |
| 80 | "<div class=\"card\">\n" |
| 81 | " <h1>filesystem</h1>\n" |
| 82 | " <p class=\"sub\">Allowlisted filesystem tools for your node, over MCP. Every path is\n" |
| 83 | " canonicalised on disk and must land inside a directory you list here. Nothing\n" |
| 84 | " outside them is readable or writable, and symlinks that point out are refused.</p>\n" |
| 85 | " <div class=\"kv\" id=\"kv\">\n" |
| 86 | " <span>plugin <b>plugin_filesystem</b></span>\n" |
| 87 | " <span>version <b id=\"kver\">–</b></span>\n" |
| 88 | " <span>kind <b>mcp</b></span>\n" |
| 89 | " <span>config <b id=\"kfile\">–</b></span>\n" |
| 90 | " </div>\n" |
| 91 | " <div class=\"msg\" id=\"msg\"></div>\n" |
| 92 | " <div class=\"hint\">Server-rendered summary below; the controls need JavaScript and the\n" |
| 93 | " node password the bot already holds.</div>\n" |
| 94 | " <pre id=\"noscript\">Allowed roots and permissions are read from\n" |
| 95 | "~/.scorpiox/connectors/plugin_filesystem/roots.json\n" |
| 96 | "(override with the FS_ALLOWED_ROOTS environment variable).</pre>\n" |
| 97 | "</div>\n" |
| 98 | "\n" |
| 99 | "<div class=\"grid\">\n" |
| 100 | "\n" |
| 101 | " <div class=\"card\">\n" |
| 102 | " <h2>Allowed directories</h2>\n" |
| 103 | " <ul class=\"roots\" id=\"roots\"><li><span class=\"p\">loading…</span></li></ul>\n" |
| 104 | " <div class=\"row\" style=\"margin-top:10px\">\n" |
| 105 | " <input type=\"text\" id=\"newroot\" placeholder=\"/absolute/path/to/a/directory\"\n" |
| 106 | " autocomplete=\"off\" spellcheck=\"false\">\n" |
| 107 | " <button class=\"primary\" id=\"btnadd\">Allow</button>\n" |
| 108 | " </div>\n" |
| 109 | " <p class=\"hint\">Absolute paths only, no <code>..</code>. A directory that does not\n" |
| 110 | " exist yet is refused here so a typo cannot quietly widen the sandbox. Paths shown\n" |
| 111 | " in orange resolve elsewhere (a symlink or a mount) — the canonical form is what the\n" |
| 112 | " tools check.</p>\n" |
| 113 | " </div>\n" |
| 114 | "\n" |
| 115 | " <div class=\"card\">\n" |
| 116 | " <h2>Tool permissions</h2>\n" |
| 117 | " <table class=\"tools\"><thead><tr><th>Tool</th><th></th></tr></thead>\n" |
| 118 | " <tbody id=\"tools\"><tr><td class=\"d\" colspan=\"2\">loading…</td></tr></tbody></table>\n" |
| 119 | " <p class=\"hint\">Disabled tools answer with a refusal instead of running, so an agent\n" |
| 120 | " gets an explanation rather than a missing tool. <b>list_allowed_directories</b>\n" |
| 121 | " cannot be switched off — it is how you diagnose a refusal.</p>\n" |
| 122 | " </div>\n" |
| 123 | "\n" |
| 124 | "</div>\n" |
| 125 | "\n" |
| 126 | "<div class=\"card\">\n" |
| 127 | " <h2>Sandbox boundary test</h2>\n" |
| 128 | " <div class=\"row wraprow\">\n" |
| 129 | " <input type=\"text\" id=\"testpath\" placeholder=\"/absolute/path/you/want/to/check\"\n" |
| 130 | " autocomplete=\"off\" spellcheck=\"false\">\n" |
| 131 | " <button id=\"btntest\">Test path</button>\n" |
| 132 | " </div>\n" |
| 133 | " <div id=\"testout\" style=\"margin-top:10px\"></div>\n" |
| 134 | " <p class=\"hint\">Reports exactly what a tool would see: allowed or not, the canonical\n" |
| 135 | " path, and the rule that refused it. Use it before blaming a tool for a path that\n" |
| 136 | " was never in scope.</p>\n" |
| 137 | "</div>\n" |
| 138 | "\n" |
| 139 | "<div class=\"card\">\n" |
| 140 | " <h2>Register with the connector router</h2>\n" |
| 141 | " <pre id=\"snippet\">{}</pre>\n" |
| 142 | " <p class=\"hint\">The node's single <b>sx-connector-mcp</b> router reads this file and\n" |
| 143 | " exposes every installed MCP connector through four meta-tools, so the agent's tool\n" |
| 144 | " budget stays flat no matter how many connectors you install.</p>\n" |
| 145 | "</div>\n" |
| 146 | "\n" |
| 147 | "</div>\n" |
| 148 | "<script>\n" |
| 149 | "var q=new URLSearchParams(location.search);\n" |
| 150 | "var node=q.get('node')||'';\n" |
| 151 | "var sid=q.get('id')||'';\n" |
| 152 | "var pwd=q.get('pwd')||(node&&localStorage.getItem('bot_pwd_'+node))||\n" |
| 153 | " localStorage.getItem('bot_active_pwd')||'';\n" |
| 154 | "var HUB=q.get('plugin')||'';\n" |
| 155 | "\n" |
| 156 | "/* Two call routes; this is the most common plugin bug.\n" |
| 157 | " * served through the hub (/plugins?plugin=plugin_filesystem&node=..)\n" |
| 158 | " * -> call the hub proxy back: /plugins?plugin=..&action=..\n" |
| 159 | " * opened directly on the node\n" |
| 160 | " * -> the plugin IS the route: /plugin_filesystem?action=..\n" |
| 161 | " * Calling /plugins?plugin= on the node returns the discovery list, not us. */\n" |
| 162 | "function url(action,extra){\n" |
| 163 | " return (HUB?'/plugins?plugin='+encodeURIComponent(HUB):'/plugin_filesystem')+\n" |
| 164 | " '?action='+encodeURIComponent(action)+\n" |
| 165 | " (extra?('&'+extra):'')+\n" |
| 166 | " (node?'&node='+encodeURIComponent(node):'')+\n" |
| 167 | " (sid?'&id='+encodeURIComponent(sid):'')+\n" |
| 168 | " (pwd?'&pwd='+encodeURIComponent(pwd):'');\n" |
| 169 | "}\n" |
| 170 | "function api(action,extra){\n" |
| 171 | " var h=pwd?{'X-Bot-Password':pwd}:{};\n" |
| 172 | " return fetch(url(action,extra),{headers:h}).then(function(r){\n" |
| 173 | " return r.json().then(function(j){return {status:r.status,body:j};});\n" |
| 174 | " });\n" |
| 175 | "}\n" |
| 176 | "var msgEl=document.getElementById('msg');\n" |
| 177 | "function say(text,kind){\n" |
| 178 | " msgEl.textContent=text;\n" |
| 179 | " msgEl.className='msg show '+(kind||'ok');\n" |
| 180 | " clearTimeout(say._t);\n" |
| 181 | " say._t=setTimeout(function(){msgEl.className='msg';},4200);\n" |
| 182 | "}\n" |
| 183 | "function esc(s){\n" |
| 184 | " return String(s==null?'':s).replace(/[&<>\"]/g,function(c){\n" |
| 185 | " return {'&':'&','<':'<','>':'>','\"':'"'}[c];\n" |
| 186 | " });\n" |
| 187 | "}\n" |
| 188 | "\n" |
| 189 | "function renderStatus(st){\n" |
| 190 | " document.getElementById('kver').textContent=st.version||'';\n" |
| 191 | " document.getElementById('kfile').textContent=st.roots_file||'';\n" |
| 192 | " document.getElementById('noscript').textContent=\n" |
| 193 | " 'config: '+(st.roots_file||'(not yet written)')+'\\n'+\n" |
| 194 | " 'source: '+(st.config_source||'')+'\\n'+\n" |
| 195 | " 'roots: '+((st.roots||[]).length\n" |
| 196 | " ? (st.roots||[]).map(function(r){return r.canonical;}).join('\\n ')\n" |
| 197 | " : '(none - nothing is reachable)');\n" |
| 198 | " document.getElementById('snippet').textContent=JSON.stringify(\n" |
| 199 | " {mcpServers:{filesystem:{\n" |
| 200 | " command:'~/.scorpiox/plugins/plugin_filesystem',\n" |
| 201 | " args:['--mcp'],\n" |
| 202 | " slug:'filesystem'}}},null,2);\n" |
| 203 | "}\n" |
| 204 | "function renderRoots(roots){\n" |
| 205 | " var ul=document.getElementById('roots');\n" |
| 206 | " ul.innerHTML='';\n" |
| 207 | " if(!roots||!roots.length){\n" |
| 208 | " ul.innerHTML='<li><span class=\"p\">No allowed directories — the plugin can read and '+\n" |
| 209 | " 'write nothing. Add one below.</span></li>';\n" |
| 210 | " return;\n" |
| 211 | " }\n" |
| 212 | " roots.forEach(function(r){\n" |
| 213 | " var li=document.createElement('li');\n" |
| 214 | " var note='',cls='';\n" |
| 215 | " if(!r.exists){note='missing';cls='bad';}\n" |
| 216 | " else if(!r.is_dir){note='not a directory';cls='bad';}\n" |
| 217 | " else if(r.drift){note='→ '+r.canonical;cls='warn';}\n" |
| 218 | " li.innerHTML='<span class=\"p\" title=\"'+esc(r.canonical)+'\">'+esc(r.configured||r.canonical)+\n" |
| 219 | " '</span>'+(note?'<span class=\"note '+cls+'\">'+esc(note)+'</span>':'')+\n" |
| 220 | " '<button class=\"danger\" data-rm=\"'+esc(r.canonical)+'\">Remove</button>';\n" |
| 221 | " ul.appendChild(li);\n" |
| 222 | " });\n" |
| 223 | " Array.prototype.forEach.call(ul.querySelectorAll('[data-rm]'),function(b){\n" |
| 224 | " b.addEventListener('click',function(){\n" |
| 225 | " api('roots_remove','path='+encodeURIComponent(b.getAttribute('data-rm'))).then(function(x){\n" |
| 226 | " if(x.body&&x.body.ok){say('Removed '+b.getAttribute('data-rm'));refresh();}\n" |
| 227 | " else say((x.body&&x.body.error)||('HTTP '+x.status),'err');\n" |
| 228 | " });\n" |
| 229 | " });\n" |
| 230 | " });\n" |
| 231 | "}\n" |
| 232 | "function renderTools(tools){\n" |
| 233 | " var tb=document.getElementById('tools');\n" |
| 234 | " tb.innerHTML='';\n" |
| 235 | " tools.forEach(function(t){\n" |
| 236 | " var tr=document.createElement('tr');\n" |
| 237 | " tr.innerHTML='<td class=\"n\">'+esc(t.name)+'</td>'+\n" |
| 238 | " '<td class=\"d\">'+esc(t.read_only?'read-only':(t.destructive?'writes':'creates'))+'</td>'+\n" |
| 239 | " '<td class=\"d\">'+esc(t.description.slice(0,64))+'…</td>'+\n" |
| 240 | " '<td style=\"text-align:right\"><button class=\"sw\" role=\"switch\" data-t=\"'+esc(t.name)+\n" |
| 241 | " '\" aria-checked=\"'+(t.enabled?'true':'false')+'\"><i></i></button></td>';\n" |
| 242 | " tb.appendChild(tr);\n" |
| 243 | " });\n" |
| 244 | " Array.prototype.forEach.call(tb.querySelectorAll('.sw'),function(b){\n" |
| 245 | " b.addEventListener('click',function(){\n" |
| 246 | " var on=b.getAttribute('aria-checked')!=='true';\n" |
| 247 | " api('permissions_set','tool='+encodeURIComponent(b.getAttribute('data-t'))+\n" |
| 248 | " '&enabled='+(on?'true':'false')).then(function(x){\n" |
| 249 | " if(x.body&&x.body.ok){b.setAttribute('aria-checked',on?'true':'false');\n" |
| 250 | " say((on?'Enabled ':'Disabled ')+b.getAttribute('data-t'));}\n" |
| 251 | " else say((x.body&&x.body.error)||('HTTP '+x.status),'err');\n" |
| 252 | " });\n" |
| 253 | " });\n" |
| 254 | " });\n" |
| 255 | "}\n" |
| 256 | "function renderTest(x){\n" |
| 257 | " var el=document.getElementById('testout');\n" |
| 258 | " if(!x||!x.body||!x.body.ok){el.innerHTML='';return;}\n" |
| 259 | " var b=x.body;\n" |
| 260 | " el.innerHTML='<div class=\"msg show '+(b.allowed?'ok':'warn')+'\">'+\n" |
| 261 | " (b.allowed?'ALLOWED':'REFUSED')+' — '+esc(b.path)+\n" |
| 262 | " (b.canonical?(' → <span style=\"font-family:var(--mono)\">'+esc(b.canonical)+'</span>'):'')+\n" |
| 263 | " ' — '+esc(b.reason||'')+'</div>';\n" |
| 264 | "}\n" |
| 265 | "function refresh(){\n" |
| 266 | " api('status').then(function(x){\n" |
| 267 | " if(!x.body||!x.body.ok){say((x.body&&x.body.error)||('HTTP '+x.status),'err');return;}\n" |
| 268 | " renderStatus(x.body);\n" |
| 269 | " });\n" |
| 270 | " api('roots').then(function(x){if(x.body&&x.body.ok)renderRoots(x.body.roots);});\n" |
| 271 | " api('tools').then(function(x){if(x.body&&x.body.ok)renderTools(x.body.tools);});\n" |
| 272 | "}\n" |
| 273 | "document.getElementById('btnadd').addEventListener('click',function(){\n" |
| 274 | " var v=document.getElementById('newroot').value.trim();\n" |
| 275 | " if(!v){say('Type a directory path first','warn');return;}\n" |
| 276 | " api('roots_add','path='+encodeURIComponent(v)).then(function(x){\n" |
| 277 | " if(x.body&&x.body.ok){say('Allowed '+x.body.added);\n" |
| 278 | " document.getElementById('newroot').value='';refresh();}\n" |
| 279 | " else say((x.body&&x.body.error)||('HTTP '+x.status),'err');\n" |
| 280 | " });\n" |
| 281 | "});\n" |
| 282 | "document.getElementById('newroot').addEventListener('keydown',function(e){\n" |
| 283 | " if(e.key==='Enter')document.getElementById('btnadd').click();\n" |
| 284 | "});\n" |
| 285 | "document.getElementById('btntest').addEventListener('click',function(){\n" |
| 286 | " var v=document.getElementById('testpath').value.trim();\n" |
| 287 | " if(!v){say('Type a path to test','warn');return;}\n" |
| 288 | " api('sandbox_test','path='+encodeURIComponent(v)).then(function(x){renderTest(x);});\n" |
| 289 | "});\n" |
| 290 | "document.getElementById('testpath').addEventListener('keydown',function(e){\n" |
| 291 | " if(e.key==='Enter')document.getElementById('btntest').click();\n" |
| 292 | "});\n" |
| 293 | "refresh();\n" |
| 294 | "</script>\n" |
| 295 | "\002</body></html>\n" |
| 296 | ; |
| 297 | |
| 298 | #endif /* SX_FILESYSTEM_UI_HTML_H */ |