| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"><head><meta charset="utf-8"> |
| 3 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 4 | <title>github</title> |
| 5 | <!--TOKENS--> |
| 6 | <style> |
| 7 | *{box-sizing:border-box} |
| 8 | html,body{margin:0} |
| 9 | body{background:var(--bg);color:var(--text);font-size:14px;line-height:1.5; |
| 10 | -webkit-font-smoothing:antialiased} |
| 11 | .wrap{max-width:980px;margin:0 auto;padding:16px} |
| 12 | .head{display:flex;align-items:center;gap:12px;margin-bottom:14px;flex-wrap:wrap} |
| 13 | h1{font-size:20px;margin:0;font-weight:650;letter-spacing:-.01em} |
| 14 | .sub{color:var(--text-2);font-size:12.5px} |
| 15 | .spacer{flex:1} |
| 16 | .card{background:var(--bg-card);border:1px solid var(--line);border-radius:14px; |
| 17 | padding:16px;margin-bottom:14px;box-shadow:var(--shadow)} |
| 18 | .card h2{font-size:13px;font-weight:650;margin:0 0 12px;color:var(--text-2); |
| 19 | text-transform:uppercase;letter-spacing:.06em} |
| 20 | .row{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end} |
| 21 | .f{display:flex;flex-direction:column;gap:4px;min-width:140px;flex:1 1 220px} |
| 22 | label{font-size:11.5px;color:var(--text-2);text-transform:uppercase;letter-spacing:.05em} |
| 23 | input{background:var(--input-bg);border:1px solid var(--line);color:var(--text); |
| 24 | border-radius:9px;padding:7px 10px;font-size:13.5px;outline:none;min-width:0;width:100%} |
| 25 | input:focus{border-color:var(--blue)} |
| 26 | button{background:var(--blue);color:#fff;border:0;border-radius:980px;padding:7px 16px; |
| 27 | font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap} |
| 28 | button.ghost{background:transparent;color:var(--blue);border:1px solid var(--line-2)} |
| 29 | button.danger{background:transparent;color:var(--red);border:1px solid var(--line-2)} |
| 30 | button:active{transform:scale(.98)} |
| 31 | button:disabled{opacity:.55;cursor:default} |
| 32 | .pill{display:inline-block;font-size:11px;font-weight:700;letter-spacing:.04em; |
| 33 | text-transform:uppercase;border-radius:980px;padding:2px 9px;border:1px solid var(--line-2); |
| 34 | color:var(--text-2)} |
| 35 | .pill.ok{color:var(--green);border-color:var(--green)} |
| 36 | .pill.miss{color:var(--orange);border-color:var(--orange)} |
| 37 | .pill.mcp{color:var(--blue);border-color:var(--blue)} |
| 38 | .kv{display:grid;grid-template-columns:130px 1fr;gap:6px 12px;font-size:13px} |
| 39 | .kv b{color:var(--text-2);font-weight:600} |
| 40 | .kv code,.hint code{font-family:var(--mono);font-size:12px;background:var(--code-bg); |
| 41 | padding:1px 5px;border-radius:5px;word-break:break-all} |
| 42 | .hint{color:var(--text-2);font-size:12.5px;margin-top:8px} |
| 43 | .err{color:var(--red);font-size:13px;margin-top:10px;white-space:pre-wrap;word-break:break-word} |
| 44 | .okline{color:var(--green);font-size:13px;margin-top:10px;white-space:pre-wrap;word-break:break-word} |
| 45 | .meta{color:var(--text-2);font-size:12px} |
| 46 | .tools{display:flex;flex-direction:column;gap:8px} |
| 47 | .tool{border:1px solid var(--line);border-radius:10px;padding:9px 12px;background:var(--surface-2)} |
| 48 | .tool code{font-family:var(--mono);font-size:12.5px;color:var(--blue);background:none;padding:0} |
| 49 | .tool p{margin:3px 0 0;color:var(--text-2);font-size:12.5px} |
| 50 | .spin{display:inline-block;width:12px;height:12px;border:2px solid var(--line-2); |
| 51 | border-top-color:var(--blue);border-radius:50%;animation:sp .7s linear infinite; |
| 52 | vertical-align:-2px;margin-right:6px} |
| 53 | @keyframes sp{to{transform:rotate(360deg)}} |
| 54 | @media(max-width:700px){.kv{grid-template-columns:1fr}.wrap{padding:12px}} |
| 55 | </style> |
| 56 | </head> |
| 57 | <body> |
| 58 | <div class="wrap"> |
| 59 | <div class="head"> |
| 60 | <div> |
| 61 | <h1>GitHub</h1> |
| 62 | <div class="sub">Five agent tools over MCP · |
| 63 | <span class="pill mcp">mcp</span> |
| 64 | <span class="pill" id="statePill">checking…</span></div> |
| 65 | </div> |
| 66 | <div class="spacer"></div> |
| 67 | <span class="meta embed-hide" id="ver"></span> |
| 68 | </div> |
| 69 | |
| 70 | <div class="card"> |
| 71 | <h2>Credential</h2> |
| 72 | <div class="row"> |
| 73 | <div class="f" style="flex:2 1 300px"> |
| 74 | <label for="token">Personal access token (classic or fine-grained)</label> |
| 75 | <input id="token" type="password" placeholder="unset" autocomplete="off" spellcheck="false"> |
| 76 | <span class="hint" id="tokenHint">checking…</span> |
| 77 | </div> |
| 78 | <div class="f"> |
| 79 | <label for="apiBase">API base URL</label> |
| 80 | <input id="apiBase" type="text" placeholder="https://api.github.com" autocomplete="off" spellcheck="false"> |
| 81 | <span class="hint">Leave empty for <code>https://api.github.com</code>, or set your GitHub Enterprise base.</span> |
| 82 | </div> |
| 83 | </div> |
| 84 | <div class="row" style="margin-top:14px"> |
| 85 | <button id="save" type="button">Save</button> |
| 86 | <button class="ghost" id="test" type="button">Test connection</button> |
| 87 | <button class="danger" id="clear" type="button">Disconnect</button> |
| 88 | <div class="spacer"></div> |
| 89 | <span class="meta" id="saveMeta"></span> |
| 90 | </div> |
| 91 | <div class="err" id="err"></div> |
| 92 | <div class="okline" id="okline"></div> |
| 93 | <div class="hint">The token is written to <code>config.json</code> at mode <code>0600</code> |
| 94 | in the connector directory and is never sent back to this page — only whether one is |
| 95 | set, and which account it belongs to. <b>Disconnect</b> deletes the stored token and keeps |
| 96 | the API base. The environment variables <code>GITHUB_TOKEN</code> and |
| 97 | <code>GITHUB_API_BASE</code> override the stored values.</div> |
| 98 | </div> |
| 99 | |
| 100 | <div class="card"> |
| 101 | <h2>Status</h2> |
| 102 | <div class="kv"> |
| 103 | <b>API base</b><span><code id="sBase">…</code></span> |
| 104 | <b>Token</b><span id="sToken">…</span> |
| 105 | <b>Account</b><span id="sUser">—</span> |
| 106 | <b>State dir</b><span><code id="sDir">…</code></span> |
| 107 | </div> |
| 108 | </div> |
| 109 | |
| 110 | <div class="card"> |
| 111 | <h2>Agent tools (MCP stdio)</h2> |
| 112 | <div class="tools" id="tools"><span class="meta">loading…</span></div> |
| 113 | <div class="hint">The single <code>sx-connector-mcp</code> router serves these over |
| 114 | <code>plugin_github --mcp</code>, so nothing needs a restart after a change here.</div> |
| 115 | </div> |
| 116 | </div> |
| 117 | <script> |
| 118 | (function () { |
| 119 | function $(id) { return document.getElementById(id); } |
| 120 | function esc(s) { |
| 121 | return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { |
| 122 | return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; |
| 123 | }); |
| 124 | } |
| 125 | function pwd() { |
| 126 | var m = /[?&]pwd=([^&]*)/.exec(location.search); |
| 127 | return m ? 'pwd=' + encodeURIComponent(decodeURIComponent(m[1])) + '&' : ''; |
| 128 | } |
| 129 | function api(action) { |
| 130 | return fetch('?action=' + action + '&' + pwd() + 'format=json', |
| 131 | { credentials: 'same-origin' }) |
| 132 | .then(function (r) { return r.json(); }); |
| 133 | } |
| 134 | function post(action, payload) { |
| 135 | return fetch('?action=' + action + '&' + pwd() + 'format=json', { |
| 136 | method: 'POST', |
| 137 | credentials: 'same-origin', |
| 138 | headers: { 'Content-Type': 'application/json' }, |
| 139 | body: JSON.stringify(payload) |
| 140 | }).then(function (r) { return r.json(); }); |
| 141 | } |
| 142 | |
| 143 | function fillStatus(d) { |
| 144 | if (!d || d.ok !== true) return; |
| 145 | $('sBase').textContent = d.api_base || ''; |
| 146 | $('sToken').innerHTML = d.has_token |
| 147 | ? '<span class="pill ok">saved</span>' |
| 148 | : '<span class="pill miss">none</span>'; |
| 149 | $('sUser').textContent = d.user || (d.has_token ? 'unknown (test connection)' : '—'); |
| 150 | $('sDir').textContent = d.connector_dir || ''; |
| 151 | $('statePill').textContent = d.has_token ? 'ready' : 'no token'; |
| 152 | $('statePill').className = 'pill ' + (d.has_token ? 'ok' : 'miss'); |
| 153 | $('tokenHint').textContent = d.has_token |
| 154 | ? 'A token is saved on this node. Leave blank to keep it.' |
| 155 | : 'No token saved. Public reads work without one; create_issue needs one.'; |
| 156 | if (!d.user && d.has_token) $('sUser').textContent = '— (click Test connection)'; |
| 157 | } |
| 158 | |
| 159 | function refresh() { |
| 160 | api('status').then(fillStatus).catch(function (e) { |
| 161 | $('err').textContent = 'status: ' + e; |
| 162 | }); |
| 163 | } |
| 164 | |
| 165 | function save() { |
| 166 | var body = {}; |
| 167 | var t = $('token').value.trim(), b = $('apiBase').value.trim(); |
| 168 | if (t) body.token = t; |
| 169 | if (b) body.api_base = b; |
| 170 | if (!t && !b) { $('err').textContent = 'Nothing to save — type a token or an API base.'; return; } |
| 171 | $('err').textContent = ''; $('okline').textContent = ''; |
| 172 | $('saveMeta').innerHTML = '<span class="spin"></span>saving…'; |
| 173 | post('save', body).then(function (d) { |
| 174 | $('saveMeta').textContent = ''; |
| 175 | if (!d || d.ok !== true) { $('err').textContent = (d && d.error) || 'save failed'; return; } |
| 176 | $('token').value = ''; |
| 177 | $('okline').textContent = 'Saved.'; |
| 178 | fillStatus(d); |
| 179 | }).catch(function (e) { $('saveMeta').textContent = ''; $('err').textContent = String(e); }); |
| 180 | } |
| 181 | |
| 182 | function test() { |
| 183 | $('err').textContent = ''; $('okline').textContent = ''; |
| 184 | $('saveMeta').innerHTML = '<span class="spin"></span>testing…'; |
| 185 | api('test').then(function (d) { |
| 186 | $('saveMeta').textContent = ''; |
| 187 | if (!d || d.ok !== true) { |
| 188 | $('err').textContent = ((d && d.error) || 'test failed') + |
| 189 | (d && d.status ? ' (HTTP ' + d.status + ')' : ''); |
| 190 | return; |
| 191 | } |
| 192 | $('okline').textContent = 'Connected as ' + (d.user || '?') + |
| 193 | (d.user_type ? ' (' + d.user_type + ')' : '') + ' — GitHub answered ' + d.status + '.'; |
| 194 | refresh(); |
| 195 | }).catch(function (e) { $('saveMeta').textContent = ''; $('err').textContent = String(e); }); |
| 196 | } |
| 197 | |
| 198 | function clear() { |
| 199 | if (!window.confirm('Delete the stored token on this node? The API base is kept.')) return; |
| 200 | $('saveMeta').innerHTML = '<span class="spin"></span>clearing…'; |
| 201 | api('clear').then(function (d) { |
| 202 | $('saveMeta').textContent = ''; |
| 203 | $('token').value = ''; |
| 204 | if (!d || d.ok !== true) { $('err').textContent = (d && d.error) || 'clear failed'; return; } |
| 205 | $('okline').textContent = 'Token deleted.'; |
| 206 | fillStatus(d); |
| 207 | }).catch(function (e) { $('saveMeta').textContent = ''; $('err').textContent = String(e); }); |
| 208 | } |
| 209 | |
| 210 | function loadTools() { |
| 211 | api('tools').then(function (d) { |
| 212 | var html = ''; |
| 213 | if (!d || d.ok !== true) { $('tools').innerHTML = '<span class="meta">tools unavailable</span>'; return; } |
| 214 | (d.tools || []).forEach(function (t) { |
| 215 | var req = ((t.inputSchema || {}).required || []).join(', '); |
| 216 | html += '<div class="tool"><code>' + esc(t.name) + '</code>' + |
| 217 | (req ? ' <span class="meta">(' + esc(req) + ')</span>' : '') + |
| 218 | '<p>' + esc(t.description || '') + '</p></div>'; |
| 219 | }); |
| 220 | $('tools').innerHTML = html || '<span class="meta">no tools</span>'; |
| 221 | }).catch(function () { |
| 222 | $('tools').innerHTML = '<span class="meta">tools unavailable</span>'; |
| 223 | }); |
| 224 | } |
| 225 | |
| 226 | $('save').onclick = save; |
| 227 | $('test').onclick = test; |
| 228 | $('clear').onclick = clear; |
| 229 | refresh(); |
| 230 | loadTools(); |
| 231 | })(); |
| 232 | </script> |
| 233 | </body> |
| 234 | </html> |