omni-notify-mcp 1.3.423 β 1.3.424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,237 +13,237 @@ const LINKS = {
|
|
|
13
13
|
domains: "https://dash.cloudflare.com/?to=/:account/domains/overview",
|
|
14
14
|
domainDocs: "https://developers.cloudflare.com/fundamentals/manage-domains/add-site/",
|
|
15
15
|
};
|
|
16
|
-
const STEPS_HTML = `
|
|
17
|
-
<section id="s0"><h3><span class="mark"></span>0 Β· A domain on Cloudflare</h3>
|
|
18
|
-
<p>Your public address is a hostname on a domain whose DNS Cloudflare runs, e.g. <code>bn.example.com</code>. If you have none yet, onboard one first (or buy one there).</p>
|
|
19
|
-
<div class="row"><button data-cmd="open" data-link="domains" title="Opens Cloudflare's Domains page in your browser">π Open Cloudflare Domains</button><button data-cmd="open" data-link="domainDocs" title="Cloudflare's own guide to onboarding a domain">π How to add a domain</button></div></section>
|
|
20
|
-
<section id="s1"><h3><span class="mark"></span>1 Β· BN's gateway door</h3>
|
|
21
|
-
<p>The tunnel carries the internet to BN's gateway door on this machine. The door opens only once it has a gateway token.</p>
|
|
22
|
-
<div class="row"><button data-cmd="createGatewayToken" id="b-gw" title="Writes a random agentGateway.token into config.json; BN's background process opens the door within 10 seconds">π Create gateway token</button></div>
|
|
23
|
-
<div class="note"></div></section>
|
|
24
|
-
<section id="s2"><h3><span class="mark"></span>2 Β· Create the tunnel in Cloudflare</h3>
|
|
25
|
-
<ol><li>Click <b>Open Cloudflare Tunnels</b> and log in.</li><li>You land on <b>Networking βΊ Tunnels</b>. Select <b>Create a tunnel</b>.</li><li>Name it, e.g. <code>bullseye-notify</code>, and select <b>Create Tunnel</b>.</li><li>Choose your operating system. Cloudflare shows an install command β <b>copy it, do not run it</b>: BN runs the connector itself.</li><li>Paste it below (the whole command, or just the long code starting <code>eyJ</code>) and select <b>Save token</b>.</li></ol>
|
|
26
|
-
<div class="row"><button data-cmd="open" data-link="tunnels" title="Opens Networking βΊ Tunnels in the Cloudflare dashboard">βοΈ Open Cloudflare Tunnels</button></div>
|
|
27
|
-
<textarea id="paste" class="f" rows="3" autocapitalize="none" autocorrect="off" spellcheck="false" placeholder="Paste the install command or the eyJ⦠token"></textarea>
|
|
28
|
-
<div class="row"><button class="go" data-cmd="saveToken" id="b-token" title="Checks the token decodes to an account, a tunnel and a secret, saves it, and installs cloudflared if it is missing">πΎ Save token</button></div>
|
|
29
|
-
<div class="note"></div></section>
|
|
30
|
-
<section id="s3"><h3><span class="mark"></span>3 Β· Install cloudflared</h3>
|
|
31
|
-
<p>BN downloads Cloudflare's own cloudflared for this computer from its GitHub releases into BN's folder β no admin rights, no package manager β checks its sha256 and runs <code>cloudflared --version</code>.</p>
|
|
32
|
-
<div class="row"><button data-cmd="install" id="b-install" title="Downloads the latest cloudflared release for this OS into BN's folder">β¬οΈ Install cloudflared</button></div>
|
|
33
|
-
<div class="note"></div></section>
|
|
34
|
-
<section id="s4"><h3><span class="mark"></span>4 Β· The connector</h3>
|
|
35
|
-
<p>BN's background process runs cloudflared with your token. Once it shows <b>Connected</b>, Cloudflare's page shows the tunnel connected too β select <b>Continue</b> there.</p>
|
|
36
|
-
<div class="row"><button data-cmd="restartConnector" id="b-restart" title="Starts the connector again with the saved token">π Start again</button><button data-cmd="turnOff" id="b-off" title="Removes the saved token; BN stops its connector within 10 seconds">βΉοΈ Turn off public access</button></div>
|
|
37
|
-
<div class="note"></div></section>
|
|
38
|
-
<section id="s5"><h3><span class="mark"></span>5 Β· Route your hostname to BN</h3>
|
|
39
|
-
<ol><li>In Cloudflare open your tunnel's <b>Routes</b> tab, select <b>Add route</b>, then <b>Published application</b>.</li><li>Enter a subdomain, e.g. <code>bn</code>, and pick your domain.</li><li>In <b>Service URL</b> enter <code id="svc">β</code> <button data-cmd="copy" data-what="serviceUrl" id="b-svc" title="Copies the Service URL">π Copy</button></li><li>Select <b>Add route</b>, then type the full hostname here and select <b>Save hostname</b>.</li></ol>
|
|
40
|
-
<div class="row"><input id="host" class="f" placeholder="bn.example.com" inputmode="url" autocapitalize="none" autocorrect="off" spellcheck="false" enterkeyhint="go"><button class="go" data-cmd="saveHostname" id="b-host" title="Saves the hostname the health check and the connector URL use">πΎ Save hostname</button></div>
|
|
41
|
-
<div class="note"></div></section>
|
|
42
|
-
<section id="s6"><h3><span class="mark"></span>6 Β· Check it from the internet</h3>
|
|
43
|
-
<p>BN asks your public hostname for its sign-in metadata and for <code>/mcp</code>, exactly as ChatGPT or claude.ai will.</p>
|
|
44
|
-
<div class="row"><button class="go" data-cmd="check" id="b-check" title="GETs /.well-known/oauth-protected-resource and /mcp on your hostname">π©Ί Check now</button></div>
|
|
45
|
-
<div class="row" id="done" hidden><span>Connector URL</span> <code id="mcpUrl"></code><button data-cmd="copy" data-what="connectorUrl" title="Copies the URL to paste into a ChatGPT or claude.ai connector">π Copy URL</button><button data-cmd="copy" data-what="gatewayToken" title="Copies agentGateway.token β the sign-in page asks for it once">π Copy gateway token</button></div>
|
|
46
|
-
<div class="note"></div></section>
|
|
16
|
+
const STEPS_HTML = `
|
|
17
|
+
<section id="s0"><h3><span class="mark"></span>0 Β· A domain on Cloudflare</h3>
|
|
18
|
+
<p>Your public address is a hostname on a domain whose DNS Cloudflare runs, e.g. <code>bn.example.com</code>. If you have none yet, onboard one first (or buy one there).</p>
|
|
19
|
+
<div class="row"><button data-cmd="open" data-link="domains" title="Opens Cloudflare's Domains page in your browser">π Open Cloudflare Domains</button><button data-cmd="open" data-link="domainDocs" title="Cloudflare's own guide to onboarding a domain">π How to add a domain</button></div></section>
|
|
20
|
+
<section id="s1"><h3><span class="mark"></span>1 Β· BN's gateway door</h3>
|
|
21
|
+
<p>The tunnel carries the internet to BN's gateway door on this machine. The door opens only once it has a gateway token.</p>
|
|
22
|
+
<div class="row"><button data-cmd="createGatewayToken" id="b-gw" title="Writes a random agentGateway.token into config.json; BN's background process opens the door within 10 seconds">π Create gateway token</button></div>
|
|
23
|
+
<div class="note"></div></section>
|
|
24
|
+
<section id="s2"><h3><span class="mark"></span>2 Β· Create the tunnel in Cloudflare</h3>
|
|
25
|
+
<ol><li>Click <b>Open Cloudflare Tunnels</b> and log in.</li><li>You land on <b>Networking βΊ Tunnels</b>. Select <b>Create a tunnel</b>.</li><li>Name it, e.g. <code>bullseye-notify</code>, and select <b>Create Tunnel</b>.</li><li>Choose your operating system. Cloudflare shows an install command β <b>copy it, do not run it</b>: BN runs the connector itself.</li><li>Paste it below (the whole command, or just the long code starting <code>eyJ</code>) and select <b>Save token</b>.</li></ol>
|
|
26
|
+
<div class="row"><button data-cmd="open" data-link="tunnels" title="Opens Networking βΊ Tunnels in the Cloudflare dashboard">βοΈ Open Cloudflare Tunnels</button></div>
|
|
27
|
+
<textarea id="paste" class="f" rows="3" autocapitalize="none" autocorrect="off" spellcheck="false" placeholder="Paste the install command or the eyJ⦠token"></textarea>
|
|
28
|
+
<div class="row"><button class="go" data-cmd="saveToken" id="b-token" title="Checks the token decodes to an account, a tunnel and a secret, saves it, and installs cloudflared if it is missing">πΎ Save token</button></div>
|
|
29
|
+
<div class="note"></div></section>
|
|
30
|
+
<section id="s3"><h3><span class="mark"></span>3 Β· Install cloudflared</h3>
|
|
31
|
+
<p>BN downloads Cloudflare's own cloudflared for this computer from its GitHub releases into BN's folder β no admin rights, no package manager β checks its sha256 and runs <code>cloudflared --version</code>.</p>
|
|
32
|
+
<div class="row"><button data-cmd="install" id="b-install" title="Downloads the latest cloudflared release for this OS into BN's folder">β¬οΈ Install cloudflared</button></div>
|
|
33
|
+
<div class="note"></div></section>
|
|
34
|
+
<section id="s4"><h3><span class="mark"></span>4 Β· The connector</h3>
|
|
35
|
+
<p>BN's background process runs cloudflared with your token. Once it shows <b>Connected</b>, Cloudflare's page shows the tunnel connected too β select <b>Continue</b> there.</p>
|
|
36
|
+
<div class="row"><button data-cmd="restartConnector" id="b-restart" title="Starts the connector again with the saved token">π Start again</button><button data-cmd="turnOff" id="b-off" title="Removes the saved token; BN stops its connector within 10 seconds">βΉοΈ Turn off public access</button></div>
|
|
37
|
+
<div class="note"></div></section>
|
|
38
|
+
<section id="s5"><h3><span class="mark"></span>5 Β· Route your hostname to BN</h3>
|
|
39
|
+
<ol><li>In Cloudflare open your tunnel's <b>Routes</b> tab, select <b>Add route</b>, then <b>Published application</b>.</li><li>Enter a subdomain, e.g. <code>bn</code>, and pick your domain.</li><li>In <b>Service URL</b> enter <code id="svc">β</code> <button data-cmd="copy" data-what="serviceUrl" id="b-svc" title="Copies the Service URL">π Copy</button></li><li>Select <b>Add route</b>, then type the full hostname here and select <b>Save hostname</b>.</li></ol>
|
|
40
|
+
<div class="row"><input id="host" class="f" placeholder="bn.example.com" inputmode="url" autocapitalize="none" autocorrect="off" spellcheck="false" enterkeyhint="go"><button class="go" data-cmd="saveHostname" id="b-host" title="Saves the hostname the health check and the connector URL use">πΎ Save hostname</button></div>
|
|
41
|
+
<div class="note"></div></section>
|
|
42
|
+
<section id="s6"><h3><span class="mark"></span>6 Β· Check it from the internet</h3>
|
|
43
|
+
<p>BN asks your public hostname for its sign-in metadata and for <code>/mcp</code>, exactly as ChatGPT or claude.ai will.</p>
|
|
44
|
+
<div class="row"><button class="go" data-cmd="check" id="b-check" title="GETs /.well-known/oauth-protected-resource and /mcp on your hostname">π©Ί Check now</button></div>
|
|
45
|
+
<div class="row" id="done" hidden><span>Connector URL</span> <code id="mcpUrl"></code><button data-cmd="copy" data-what="connectorUrl" title="Copies the URL to paste into a ChatGPT or claude.ai connector">π Copy URL</button><button data-cmd="copy" data-what="gatewayToken" title="Copies agentGateway.token β the sign-in page asks for it once">π Copy gateway token</button></div>
|
|
46
|
+
<div class="note"></div></section>
|
|
47
47
|
`;
|
|
48
|
-
const PANEL_STYLE = `
|
|
49
|
-
#bullseye-workspace{flex:none}#bullseye-workspace label{display:inline;margin:0;font-size:inherit;color:inherit}
|
|
50
|
-
nav{display:flex;gap:14px;padding:8px 12px;border-bottom:1px solid var(--line)}nav a{color:inherit;text-decoration:none;font-weight:600}nav a.here{color:var(--me)}
|
|
51
|
-
.wrap{padding:12px;max-width:880px;margin:0 auto}
|
|
52
|
-
.pill{display:inline-block;padding:2px 8px;border-radius:10px;border:1px solid var(--line);font-weight:600}
|
|
53
|
-
.pill[data-severity=good]{color:#1a7f37}.pill[data-severity=warning]{color:#9a6700}.pill[data-severity=error]{color:var(--bad)}
|
|
54
|
-
.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}
|
|
55
|
-
table{border-collapse:collapse;width:100%}th,td{border:1px solid var(--line);padding:5px 8px;text-align:left;vertical-align:top}
|
|
56
|
-
tr.group td{background:#f3f5f8;font-weight:700}td.name{white-space:nowrap;color:var(--mut);width:1%}
|
|
57
|
-
.hint{color:var(--mut);font-size:12px;overflow-wrap:anywhere}.next{font-weight:600;margin-top:2px}
|
|
58
|
-
.seg button{margin:0 2px;padding:3px 9px;border:1px solid var(--line);border-radius:4px;background:#fff;cursor:pointer}.seg button.on{background:var(--me);color:#fff}
|
|
59
|
-
input.f{box-sizing:border-box;width:100%;min-width:140px;padding:4px 6px;border:1px solid var(--line);border-radius:4px}
|
|
60
|
-
button:disabled{opacity:.5;cursor:not-allowed}
|
|
61
|
-
section{border:1px solid var(--line);border-radius:6px;padding:8px 12px;margin:0 0 12px}section.next{border-color:var(--me)}section.off{opacity:.55}
|
|
62
|
-
h3{margin:0 0 6px;font-size:14px}.mark{display:inline-block;width:1.6em}
|
|
63
|
-
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:6px 0}
|
|
64
|
-
textarea{width:100%;box-sizing:border-box}
|
|
65
|
-
.note{overflow-wrap:anywhere}.note:empty{display:none}.note[data-severity=good]{color:#1a7f37}.note[data-severity=warning]{color:#9a6700}.note[data-severity=error]{color:var(--bad)}
|
|
66
|
-
#banner{border-left:4px solid #d4a72c;background:#fff8e1;padding:6px 10px;margin:0 0 12px}#banner:empty{display:none}
|
|
67
|
-
#signin{display:none;margin:12px 0}#signin.show{display:block}
|
|
68
|
-
code{background:#eef1f5;padding:0 4px;border-radius:3px;overflow-wrap:anywhere}
|
|
69
|
-
@media(max-width:480px) and (pointer:coarse){
|
|
70
|
-
nav{flex:none;overflow-x:auto;gap:4px;padding:2px 8px;-webkit-overflow-scrolling:touch}nav a{flex:none;display:inline-flex;align-items:center;min-height:40px;padding:0 8px;white-space:nowrap}
|
|
71
|
-
#bullseye-workspace{display:flex;align-items:center;min-height:40px}#bullseye-workspace select{min-height:40px;max-width:100%}
|
|
72
|
-
.wrap{padding:8px}.wrap table,.wrap tbody{display:block}.wrap tr{display:block;border-bottom:1px solid var(--line);padding:4px 0}.wrap tr.head{display:none}
|
|
73
|
-
.wrap th,.wrap td{display:block;border:0;padding:2px 4px}.wrap td.name{width:auto;white-space:normal}.wrap tr.group{border-bottom:0}
|
|
74
|
-
.wrap td>span{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.seg{display:flex;flex-wrap:wrap;gap:4px}.seg button{margin:0;padding:0 12px}
|
|
75
|
-
input.f{min-width:0;flex:1 1 12rem;min-height:40px;font-size:16px}textarea{font-size:16px}
|
|
76
|
-
.row button,.bar button{min-height:40px}.row code{flex:1 1 100%}
|
|
77
|
-
section{padding:8px}
|
|
78
|
-
}
|
|
48
|
+
const PANEL_STYLE = `
|
|
49
|
+
#bullseye-workspace{flex:none}#bullseye-workspace label{display:inline;margin:0;font-size:inherit;color:inherit}
|
|
50
|
+
nav{display:flex;gap:14px;padding:8px 12px;border-bottom:1px solid var(--line)}nav a{color:inherit;text-decoration:none;font-weight:600}nav a.here{color:var(--me)}
|
|
51
|
+
.wrap{padding:12px;max-width:880px;margin:0 auto}
|
|
52
|
+
.pill{display:inline-block;padding:2px 8px;border-radius:10px;border:1px solid var(--line);font-weight:600}
|
|
53
|
+
.pill[data-severity=good]{color:#1a7f37}.pill[data-severity=warning]{color:#9a6700}.pill[data-severity=error]{color:var(--bad)}
|
|
54
|
+
.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}
|
|
55
|
+
table{border-collapse:collapse;width:100%}th,td{border:1px solid var(--line);padding:5px 8px;text-align:left;vertical-align:top}
|
|
56
|
+
tr.group td{background:#f3f5f8;font-weight:700}td.name{white-space:nowrap;color:var(--mut);width:1%}
|
|
57
|
+
.hint{color:var(--mut);font-size:12px;overflow-wrap:anywhere}.next{font-weight:600;margin-top:2px}
|
|
58
|
+
.seg button{margin:0 2px;padding:3px 9px;border:1px solid var(--line);border-radius:4px;background:#fff;cursor:pointer}.seg button.on{background:var(--me);color:#fff}
|
|
59
|
+
input.f{box-sizing:border-box;width:100%;min-width:140px;padding:4px 6px;border:1px solid var(--line);border-radius:4px}
|
|
60
|
+
button:disabled{opacity:.5;cursor:not-allowed}
|
|
61
|
+
section{border:1px solid var(--line);border-radius:6px;padding:8px 12px;margin:0 0 12px}section.next{border-color:var(--me)}section.off{opacity:.55}
|
|
62
|
+
h3{margin:0 0 6px;font-size:14px}.mark{display:inline-block;width:1.6em}
|
|
63
|
+
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:6px 0}
|
|
64
|
+
textarea{width:100%;box-sizing:border-box}
|
|
65
|
+
.note{overflow-wrap:anywhere}.note:empty{display:none}.note[data-severity=good]{color:#1a7f37}.note[data-severity=warning]{color:#9a6700}.note[data-severity=error]{color:var(--bad)}
|
|
66
|
+
#banner{border-left:4px solid #d4a72c;background:#fff8e1;padding:6px 10px;margin:0 0 12px}#banner:empty{display:none}
|
|
67
|
+
#signin{display:none;margin:12px 0}#signin.show{display:block}
|
|
68
|
+
code{background:#eef1f5;padding:0 4px;border-radius:3px;overflow-wrap:anywhere}
|
|
69
|
+
@media(max-width:480px) and (pointer:coarse){
|
|
70
|
+
nav{flex:none;overflow-x:auto;gap:4px;padding:2px 8px;-webkit-overflow-scrolling:touch}nav a{flex:none;display:inline-flex;align-items:center;min-height:40px;padding:0 8px;white-space:nowrap}
|
|
71
|
+
#bullseye-workspace{display:flex;align-items:center;min-height:40px}#bullseye-workspace select{min-height:40px;max-width:100%}
|
|
72
|
+
.wrap{padding:8px}.wrap table,.wrap tbody{display:block}.wrap tr{display:block;border-bottom:1px solid var(--line);padding:4px 0}.wrap tr.head{display:none}
|
|
73
|
+
.wrap th,.wrap td{display:block;border:0;padding:2px 4px}.wrap td.name{width:auto;white-space:normal}.wrap tr.group{border-bottom:0}
|
|
74
|
+
.wrap td>span{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.seg{display:flex;flex-wrap:wrap;gap:4px}.seg button{margin:0;padding:0 12px}
|
|
75
|
+
input.f{min-width:0;flex:1 1 12rem;min-height:40px;font-size:16px}textarea{font-size:16px}
|
|
76
|
+
.row button,.bar button{min-height:40px}.row code{flex:1 1 100%}
|
|
77
|
+
section{padding:8px}
|
|
78
|
+
}
|
|
79
79
|
`;
|
|
80
80
|
/** The sign-in every page of the service shares: the gateway token handed over once in the address fragment, else the one `/` stored in this browser (a passkey session or the token), else a box to type it. */
|
|
81
|
-
const SIGN_IN = `
|
|
82
|
-
var KEY = "bn-chat-token", token = "";
|
|
83
|
-
(function () {
|
|
84
|
-
var m = /#token=([^&]*)/.exec(location.hash);
|
|
85
|
-
if (m) { token = decodeURIComponent(m[1]); try { localStorage.setItem(KEY, token); } catch (e) { token = token; } history.replaceState(null, "", location.pathname + location.search); }
|
|
86
|
-
else { try { token = localStorage.getItem(KEY) || ""; } catch (e) { token = ""; } }
|
|
87
|
-
})();
|
|
88
|
-
function el(tag, cls, text) { var n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = text; return n; }
|
|
89
|
-
function needSignIn(why) {
|
|
90
|
-
var box = document.getElementById("signin"); box.className = "show"; box.textContent = "";
|
|
91
|
-
box.append(el("p", "", why || "Sign in with the gateway token (agentGateway.token), or sign in on the conversation page first and come back."));
|
|
92
|
-
var input = el("input", "f"); input.type = "password"; input.autocomplete = "off"; input.autocapitalize = "none"; input.spellcheck = false; input.enterKeyHint = "go";
|
|
93
|
-
var go = el("button", "", "Sign in");
|
|
94
|
-
go.onclick = function () { token = input.value.trim(); try { localStorage.setItem(KEY, token); } catch (e) { token = token; } box.className = ""; start(); };
|
|
95
|
-
box.append(input, go);
|
|
96
|
-
}
|
|
97
|
-
async function call(method, path, body) {
|
|
98
|
-
function scoped(h) { var p = new URLSearchParams(location.search).get("project"); if (p !== null) h["x-bullseye-project"] = p; return h; }
|
|
99
|
-
var r;
|
|
100
|
-
try { r = await fetch(path, { method: method, headers: scoped({ authorization: "Bearer " + token, "content-type": "application/json" }), body: body === undefined ? undefined : JSON.stringify(body) }); }
|
|
101
|
-
catch (e) { window.bullseyeConnection.reconnecting("this page's connection to the Notify service", location.pathname.indexOf("public-access") >= 0 ? 2000 : 5000); throw e; }
|
|
102
|
-
if (r.status >= 502) window.bullseyeConnection.reconnecting("this page's connection to the Notify service (HTTP " + r.status + ")", location.pathname.indexOf("public-access") >= 0 ? 2000 : 5000); else window.bullseyeConnection.live();
|
|
103
|
-
var j = await r.json().catch(function () { return {}; });
|
|
104
|
-
if (r.status === 401) { needSignIn("This sign-in was not accepted. Sign in again."); throw new Error("not signed in"); }
|
|
105
|
-
if (!r.ok) throw new Error(j.error || ("HTTP " + r.status));
|
|
106
|
-
return j;
|
|
107
|
-
}
|
|
81
|
+
const SIGN_IN = `
|
|
82
|
+
var KEY = "bn-chat-token", token = "";
|
|
83
|
+
(function () {
|
|
84
|
+
var m = /#token=([^&]*)/.exec(location.hash);
|
|
85
|
+
if (m) { token = decodeURIComponent(m[1]); try { localStorage.setItem(KEY, token); } catch (e) { token = token; } history.replaceState(null, "", location.pathname + location.search); }
|
|
86
|
+
else { try { token = localStorage.getItem(KEY) || ""; } catch (e) { token = ""; } }
|
|
87
|
+
})();
|
|
88
|
+
function el(tag, cls, text) { var n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = text; return n; }
|
|
89
|
+
function needSignIn(why) {
|
|
90
|
+
var box = document.getElementById("signin"); box.className = "show"; box.textContent = "";
|
|
91
|
+
box.append(el("p", "", why || "Sign in with the gateway token (agentGateway.token), or sign in on the conversation page first and come back."));
|
|
92
|
+
var input = el("input", "f"); input.type = "password"; input.autocomplete = "off"; input.autocapitalize = "none"; input.spellcheck = false; input.enterKeyHint = "go";
|
|
93
|
+
var go = el("button", "", "Sign in");
|
|
94
|
+
go.onclick = function () { token = input.value.trim(); try { localStorage.setItem(KEY, token); } catch (e) { token = token; } box.className = ""; start(); };
|
|
95
|
+
box.append(input, go);
|
|
96
|
+
}
|
|
97
|
+
async function call(method, path, body) {
|
|
98
|
+
function scoped(h) { var p = new URLSearchParams(location.search).get("project"); if (p !== null) h["x-bullseye-project"] = p; return h; }
|
|
99
|
+
var r;
|
|
100
|
+
try { r = await fetch(path, { method: method, headers: scoped({ authorization: "Bearer " + token, "content-type": "application/json" }), body: body === undefined ? undefined : JSON.stringify(body) }); }
|
|
101
|
+
catch (e) { window.bullseyeConnection.reconnecting("this page's connection to the Notify service", location.pathname.indexOf("public-access") >= 0 ? 2000 : 5000); throw e; }
|
|
102
|
+
if (r.status >= 502) window.bullseyeConnection.reconnecting("this page's connection to the Notify service (HTTP " + r.status + ")", location.pathname.indexOf("public-access") >= 0 ? 2000 : 5000); else window.bullseyeConnection.live();
|
|
103
|
+
var j = await r.json().catch(function () { return {}; });
|
|
104
|
+
if (r.status === 401) { needSignIn("This sign-in was not accepted. Sign in again."); throw new Error("not signed in"); }
|
|
105
|
+
if (!r.ok) throw new Error(j.error || ("HTTP " + r.status));
|
|
106
|
+
return j;
|
|
107
|
+
}
|
|
108
108
|
`;
|
|
109
109
|
/** Both service screens draw the same hold and measured delivery contract. */
|
|
110
110
|
export function notificationStatusScript(request) {
|
|
111
|
-
return `(function(){
|
|
112
|
-
var box=document.createElement('section');box.id='notification-status';box.setAttribute('aria-label','Notification delivery');box.style.cssText='flex:none;margin:8px 12px;padding:8px;border:1px solid var(--line);border-radius:6px;overflow-wrap:anywhere';
|
|
113
|
-
(document.querySelector('header')||document.querySelector('nav')).after(box);
|
|
114
|
-
async function refresh(){
|
|
115
|
-
if(!token){box.hidden=true;return;}box.hidden=false;
|
|
116
|
-
try{
|
|
117
|
-
var model=await ${request}('GET','/v1/panel');box.replaceChildren();
|
|
118
|
-
if(!model.hold||!model.delivery){box.textContent='β οΈ Notification status is unavailable β the service did not answer the hold and delivery reading.';return;}
|
|
119
|
-
if(model.hold.active){
|
|
120
|
-
var held=document.createElement('p');held.textContent='π '+model.hold.text;held.setAttribute('role','status');held.style.fontWeight='700';
|
|
121
|
-
var release=document.createElement('button');release.textContent='π Release notifications';release.onclick=async function(){release.disabled=true;try{for(var path of model.hold.release)await ${request}('POST','/v1/settings',{path:path,value:false});await refresh();}catch(error){box.textContent='β οΈ Hold was not released β '+error.message;}};box.append(held,release);
|
|
122
|
-
}
|
|
123
|
-
var state=document.createElement('p');state.textContent='π’ Process: '+model.delivery.process+' Β· Delivery: '+(model.delivery.healthy?'all configured channels measured able to carry':'needs a channel reading or repair');box.append(state);
|
|
124
|
-
var details=document.createElement('details'),summary=document.createElement('summary');summary.textContent='π Channel readings';details.append(summary);
|
|
125
|
-
var reason=document.createElement('p');reason.textContent=model.delivery.reason;details.append(reason);
|
|
126
|
-
var table=document.createElement('table');table.style.cssText='width:100%;table-layout:fixed;border-collapse:collapse';var head=document.createElement('tr');['Channel','Measured state'].forEach(function(text){var cell=document.createElement('th');cell.textContent=text;head.append(cell);});table.append(head);
|
|
127
|
-
model.delivery.carriage.forEach(function(reading){var row=document.createElement('tr');[reading.channel,reading.state==='unmeasured'?'UNMEASURED β no carriage reading':reading.state+(reading.detail?' β '+reading.detail:'')].forEach(function(text){var cell=document.createElement('td');cell.textContent=text;cell.style.cssText='padding:4px;vertical-align:top;overflow-wrap:anywhere';row.append(cell);});table.append(row);});details.append(table);box.append(details);
|
|
128
|
-
}catch(error){box.replaceChildren();box.textContent='β οΈ Notification status could not be read β '+error.message;}
|
|
129
|
-
}
|
|
130
|
-
refresh();setInterval(refresh,5000);
|
|
111
|
+
return `(function(){
|
|
112
|
+
var box=document.createElement('section');box.id='notification-status';box.setAttribute('aria-label','Notification delivery');box.style.cssText='flex:none;margin:8px 12px;padding:8px;border:1px solid var(--line);border-radius:6px;overflow-wrap:anywhere';
|
|
113
|
+
(document.querySelector('header')||document.querySelector('nav')).after(box);
|
|
114
|
+
async function refresh(){
|
|
115
|
+
if(!token){box.hidden=true;return;}box.hidden=false;
|
|
116
|
+
try{
|
|
117
|
+
var model=await ${request}('GET','/v1/panel');box.replaceChildren();
|
|
118
|
+
if(!model.hold||!model.delivery){box.textContent='β οΈ Notification status is unavailable β the service did not answer the hold and delivery reading.';return;}
|
|
119
|
+
if(model.hold.active){
|
|
120
|
+
var held=document.createElement('p');held.textContent='π '+model.hold.text;held.setAttribute('role','status');held.style.fontWeight='700';
|
|
121
|
+
var release=document.createElement('button');release.textContent='π Release notifications';release.onclick=async function(){release.disabled=true;try{for(var path of model.hold.release)await ${request}('POST','/v1/settings',{path:path,value:false});await refresh();}catch(error){box.textContent='β οΈ Hold was not released β '+error.message;}};box.append(held,release);
|
|
122
|
+
}
|
|
123
|
+
var state=document.createElement('p');state.textContent='π’ Process: '+model.delivery.process+' Β· Delivery: '+(model.delivery.healthy?'all configured channels measured able to carry':'needs a channel reading or repair');box.append(state);
|
|
124
|
+
var details=document.createElement('details'),summary=document.createElement('summary');summary.textContent='π Channel readings';details.append(summary);
|
|
125
|
+
var reason=document.createElement('p');reason.textContent=model.delivery.reason;details.append(reason);
|
|
126
|
+
var table=document.createElement('table');table.style.cssText='width:100%;table-layout:fixed;border-collapse:collapse';var head=document.createElement('tr');['Channel','Measured state'].forEach(function(text){var cell=document.createElement('th');cell.textContent=text;head.append(cell);});table.append(head);
|
|
127
|
+
model.delivery.carriage.forEach(function(reading){var row=document.createElement('tr');[reading.channel,reading.state==='unmeasured'?'UNMEASURED β no carriage reading':reading.state+(reading.detail?' β '+reading.detail:'')].forEach(function(text){var cell=document.createElement('td');cell.textContent=text;cell.style.cssText='padding:4px;vertical-align:top;overflow-wrap:anywhere';row.append(cell);});table.append(row);});details.append(table);box.append(details);
|
|
128
|
+
}catch(error){box.replaceChildren();box.textContent='β οΈ Notification status could not be read β '+error.message;}
|
|
129
|
+
}
|
|
130
|
+
refresh();setInterval(refresh,5000);
|
|
131
131
|
})();`;
|
|
132
132
|
}
|
|
133
|
-
const NAV_KEEPS_WORKSPACE = `
|
|
134
|
-
document.querySelectorAll("nav a").forEach(function (a) { a.search = location.search; });
|
|
133
|
+
const NAV_KEEPS_WORKSPACE = `
|
|
134
|
+
document.querySelectorAll("nav a").forEach(function (a) { a.search = location.search; });
|
|
135
135
|
`;
|
|
136
136
|
function shell(title, here, body, script) {
|
|
137
137
|
const nav = [["/", "π¬ Conversations"], ["/settings", "βοΈ Settings"], ["/public-access", "π Public access"]]
|
|
138
138
|
.map(([href, text]) => `<a href="${href}"${href === here ? ' class="here"' : ""}>${text}</a>`).join("");
|
|
139
139
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title}</title>${ICON_HEAD}<style>${PAGE_STYLE}${PANEL_STYLE}</style></head><body><nav>${nav}</nav><div class="wrap"><div id="signin"></div>${body}</div><script>${CONNECTION_SOURCE}</script><script>${SIGN_IN}${NAV_KEEPS_WORKSPACE}${script}${notificationStatusScript("call")}</script><script data-page="${here.slice(1)}">${PICKER_PAGE_SOURCE}</script></body></html>`;
|
|
140
140
|
}
|
|
141
|
-
const SETTINGS_SCRIPT = `
|
|
142
|
-
var root = document.getElementById("root"), said = document.getElementById("said");
|
|
143
|
-
function say(severity, text) { said.textContent = text; said.dataset.severity = severity; }
|
|
144
|
-
async function save(path, value, control) {
|
|
145
|
-
control.disabled = true;
|
|
146
|
-
try { var r = await call("POST", "/v1/settings", { path: path, value: value }); say("good", "β
Saved " + r.path + " β re-read from the config file: " + (r.kind === "secret" ? (r.value ? "set" : "cleared") : JSON.stringify(r.value))); }
|
|
147
|
-
catch (e) { say("error", "β οΈ Not saved β " + e.message); }
|
|
148
|
-
await load();
|
|
149
|
-
}
|
|
150
|
-
function control(row) {
|
|
151
|
-
var wrap = el("span", ""), value = row.value, unset = value === undefined ? el("span", "hint", " not set β server default") : null;
|
|
152
|
-
if (row.kind === "toggle") {
|
|
153
|
-
var seg = el("span", "seg");
|
|
154
|
-
[[true, "π’ On"], [false, "β« Off"]].forEach(function (o) { var b = el("button", value === o[0] ? "on" : "", o[1]); b.onclick = function () { save(row.path, o[0], b); }; seg.append(b); });
|
|
155
|
-
wrap.append(seg);
|
|
156
|
-
} else if (row.kind === "choice") {
|
|
157
|
-
var segc = el("span", "seg");
|
|
158
|
-
row.choices.forEach(function (c) { var b = el("button", value === c ? "on" : "", c); b.onclick = function () { save(row.path, c, b); }; segc.append(b); });
|
|
159
|
-
wrap.append(segc);
|
|
160
|
-
} else if (row.kind === "days") {
|
|
161
|
-
var days = Array.isArray(value) ? value.slice() : [], names = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], segd = el("span", "seg");
|
|
162
|
-
names.forEach(function (n, i) { var b = el("button", days.indexOf(i) >= 0 ? "on" : "", n); b.onclick = function () { var next = days.slice(), at = next.indexOf(i); if (at >= 0) next.splice(at, 1); else next.push(i); save(row.path, next, b); }; segd.append(b); });
|
|
163
|
-
wrap.append(segd);
|
|
164
|
-
} else {
|
|
165
|
-
var input = el("input", "f"); input.type = row.kind === "secret" ? "password" : row.kind === "number" ? "number" : "text";
|
|
166
|
-
input.autocapitalize = "none"; input.spellcheck = false; input.enterKeyHint = "done";
|
|
167
|
-
input.value = value === undefined ? "" : Array.isArray(value) ? value.join(", ") : String(value);
|
|
168
|
-
input.placeholder = value === undefined ? "not set β server default" : "";
|
|
169
|
-
input.onchange = function () { save(row.path, row.kind === "list" ? input.value.split(/[,\\n]/) : row.kind === "number" ? Number(input.value) : input.value, input); };
|
|
170
|
-
input.onkeydown = function (e) { if (e.key === "Enter") input.blur(); };
|
|
171
|
-
wrap.append(input);
|
|
172
|
-
if (row.kind === "secret") { var show = el("button", "", "ποΈ Show"); show.onclick = function () { var on = input.type === "password"; input.type = on ? "text" : "password"; show.textContent = on ? "π Hide" : "ποΈ Show"; }; wrap.append(show); }
|
|
173
|
-
}
|
|
174
|
-
if (unset) wrap.append(unset);
|
|
175
|
-
return wrap;
|
|
176
|
-
}
|
|
177
|
-
function draw(s) {
|
|
178
|
-
root.textContent = "";
|
|
179
|
-
var pill = el("span", "pill", s.state.icon + " " + s.state.label); pill.dataset.severity = s.state.severity;
|
|
180
|
-
var bar = el("div", "bar"); bar.append(pill, el("span", "", s.state.text));
|
|
181
|
-
var unavailable = el("button", "", "π Open config file"); unavailable.disabled = true; unavailable.title = "Opening a file in the editor needs a VS Code window, so it is not offered on this page. The file is " + s.configPath;
|
|
182
|
-
bar.append(unavailable);
|
|
183
|
-
root.append(bar);
|
|
184
|
-
var conv = el("div", "bar"), seg = el("span", "seg"), cp = el("span", "pill", "π€ Agent conversations"); cp.dataset.severity = "good";
|
|
185
|
-
[[true, "π’ On"], [false, "β« Off"]].forEach(function (o) { var b = el("button", s.conversation.enabled === o[0] ? "on" : "", o[1]); b.onclick = async function () { b.disabled = true; try { await call("POST", "/v1/conversation-switch", { enabled: o[0] }); say("good", "β
Agent conversations " + (o[0] ? "On" : "Off")); } catch (e) { say("error", "β οΈ Not saved β " + e.message); } await load(); }; seg.append(b); });
|
|
186
|
-
conv.append(cp, seg);
|
|
187
|
-
if (s.conversation.unreadable) conv.append(el("span", "hint", "β οΈ The switch could not be read β " + s.conversation.unreadable + " Press On or Off to write it again."));
|
|
188
|
-
else if (!s.conversation.enabled) conv.append(el("span", "hint", "The agent conversation is switched off. Press On to use it."));
|
|
189
|
-
root.append(conv);
|
|
190
|
-
var table = el("table"), head = el("tr", "head"); head.append(el("th", "", "Setting"), el("th", "", "Value")); table.append(head);
|
|
191
|
-
s.groups.forEach(function (g) {
|
|
192
|
-
var gr = el("tr", "group"), gc = el("td", "", g.title); gc.colSpan = 2; gr.append(gc); table.append(gr);
|
|
193
|
-
if (g.guide) {
|
|
194
|
-
var tr = el("tr"), td = el("td"); td.colSpan = 2;
|
|
195
|
-
var d = el("details"); d.append(el("summary", "", g.guide.summary)); var ol = el("ol"); g.guide.steps.forEach(function (t) { ol.append(el("li", "", t.replace(/\`/g, ""))); }); d.append(ol);
|
|
196
|
-
td.append(d, el("div", "next", g.guide.next)); tr.append(td); table.append(tr);
|
|
197
|
-
}
|
|
198
|
-
g.rows.forEach(function (r) {
|
|
199
|
-
var row = el("tr"), name = el("td", "name", r.label), cell = el("td"); cell.append(control(r));
|
|
200
|
-
if (r.hint) cell.append(el("div", "hint", r.hint));
|
|
201
|
-
row.append(name, cell); table.append(row);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
root.append(table, el("p", "hint", "Configured in " + s.configPath));
|
|
205
|
-
}
|
|
206
|
-
async function load() { try { draw(await call("GET", "/v1/panel")); } catch (e) { if (e.message !== "not signed in") root.textContent = "β οΈ " + e.message; } }
|
|
207
|
-
function start() { load(); }
|
|
208
|
-
if (!token) needSignIn(); else start();
|
|
141
|
+
const SETTINGS_SCRIPT = `
|
|
142
|
+
var root = document.getElementById("root"), said = document.getElementById("said");
|
|
143
|
+
function say(severity, text) { said.textContent = text; said.dataset.severity = severity; }
|
|
144
|
+
async function save(path, value, control) {
|
|
145
|
+
control.disabled = true;
|
|
146
|
+
try { var r = await call("POST", "/v1/settings", { path: path, value: value }); say("good", "β
Saved " + r.path + " β re-read from the config file: " + (r.kind === "secret" ? (r.value ? "set" : "cleared") : JSON.stringify(r.value))); }
|
|
147
|
+
catch (e) { say("error", "β οΈ Not saved β " + e.message); }
|
|
148
|
+
await load();
|
|
149
|
+
}
|
|
150
|
+
function control(row) {
|
|
151
|
+
var wrap = el("span", ""), value = row.value, unset = value === undefined ? el("span", "hint", " not set β server default") : null;
|
|
152
|
+
if (row.kind === "toggle") {
|
|
153
|
+
var seg = el("span", "seg");
|
|
154
|
+
[[true, "π’ On"], [false, "β« Off"]].forEach(function (o) { var b = el("button", value === o[0] ? "on" : "", o[1]); b.onclick = function () { save(row.path, o[0], b); }; seg.append(b); });
|
|
155
|
+
wrap.append(seg);
|
|
156
|
+
} else if (row.kind === "choice") {
|
|
157
|
+
var segc = el("span", "seg");
|
|
158
|
+
row.choices.forEach(function (c) { var b = el("button", value === c ? "on" : "", c); b.onclick = function () { save(row.path, c, b); }; segc.append(b); });
|
|
159
|
+
wrap.append(segc);
|
|
160
|
+
} else if (row.kind === "days") {
|
|
161
|
+
var days = Array.isArray(value) ? value.slice() : [], names = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], segd = el("span", "seg");
|
|
162
|
+
names.forEach(function (n, i) { var b = el("button", days.indexOf(i) >= 0 ? "on" : "", n); b.onclick = function () { var next = days.slice(), at = next.indexOf(i); if (at >= 0) next.splice(at, 1); else next.push(i); save(row.path, next, b); }; segd.append(b); });
|
|
163
|
+
wrap.append(segd);
|
|
164
|
+
} else {
|
|
165
|
+
var input = el("input", "f"); input.type = row.kind === "secret" ? "password" : row.kind === "number" ? "number" : "text";
|
|
166
|
+
input.autocapitalize = "none"; input.spellcheck = false; input.enterKeyHint = "done";
|
|
167
|
+
input.value = value === undefined ? "" : Array.isArray(value) ? value.join(", ") : String(value);
|
|
168
|
+
input.placeholder = value === undefined ? "not set β server default" : "";
|
|
169
|
+
input.onchange = function () { save(row.path, row.kind === "list" ? input.value.split(/[,\\n]/) : row.kind === "number" ? Number(input.value) : input.value, input); };
|
|
170
|
+
input.onkeydown = function (e) { if (e.key === "Enter") input.blur(); };
|
|
171
|
+
wrap.append(input);
|
|
172
|
+
if (row.kind === "secret") { var show = el("button", "", "ποΈ Show"); show.onclick = function () { var on = input.type === "password"; input.type = on ? "text" : "password"; show.textContent = on ? "π Hide" : "ποΈ Show"; }; wrap.append(show); }
|
|
173
|
+
}
|
|
174
|
+
if (unset) wrap.append(unset);
|
|
175
|
+
return wrap;
|
|
176
|
+
}
|
|
177
|
+
function draw(s) {
|
|
178
|
+
root.textContent = "";
|
|
179
|
+
var pill = el("span", "pill", s.state.icon + " " + s.state.label); pill.dataset.severity = s.state.severity;
|
|
180
|
+
var bar = el("div", "bar"); bar.append(pill, el("span", "", s.state.text));
|
|
181
|
+
var unavailable = el("button", "", "π Open config file"); unavailable.disabled = true; unavailable.title = "Opening a file in the editor needs a VS Code window, so it is not offered on this page. The file is " + s.configPath;
|
|
182
|
+
bar.append(unavailable);
|
|
183
|
+
root.append(bar);
|
|
184
|
+
var conv = el("div", "bar"), seg = el("span", "seg"), cp = el("span", "pill", "π€ Agent conversations"); cp.dataset.severity = "good";
|
|
185
|
+
[[true, "π’ On"], [false, "β« Off"]].forEach(function (o) { var b = el("button", s.conversation.enabled === o[0] ? "on" : "", o[1]); b.onclick = async function () { b.disabled = true; try { await call("POST", "/v1/conversation-switch", { enabled: o[0] }); say("good", "β
Agent conversations " + (o[0] ? "On" : "Off")); } catch (e) { say("error", "β οΈ Not saved β " + e.message); } await load(); }; seg.append(b); });
|
|
186
|
+
conv.append(cp, seg);
|
|
187
|
+
if (s.conversation.unreadable) conv.append(el("span", "hint", "β οΈ The switch could not be read β " + s.conversation.unreadable + " Press On or Off to write it again."));
|
|
188
|
+
else if (!s.conversation.enabled) conv.append(el("span", "hint", "The agent conversation is switched off. Press On to use it."));
|
|
189
|
+
root.append(conv);
|
|
190
|
+
var table = el("table"), head = el("tr", "head"); head.append(el("th", "", "Setting"), el("th", "", "Value")); table.append(head);
|
|
191
|
+
s.groups.forEach(function (g) {
|
|
192
|
+
var gr = el("tr", "group"), gc = el("td", "", g.title); gc.colSpan = 2; gr.append(gc); table.append(gr);
|
|
193
|
+
if (g.guide) {
|
|
194
|
+
var tr = el("tr"), td = el("td"); td.colSpan = 2;
|
|
195
|
+
var d = el("details"); d.append(el("summary", "", g.guide.summary)); var ol = el("ol"); g.guide.steps.forEach(function (t) { ol.append(el("li", "", t.replace(/\`/g, ""))); }); d.append(ol);
|
|
196
|
+
td.append(d, el("div", "next", g.guide.next)); tr.append(td); table.append(tr);
|
|
197
|
+
}
|
|
198
|
+
g.rows.forEach(function (r) {
|
|
199
|
+
var row = el("tr"), name = el("td", "name", r.label), cell = el("td"); cell.append(control(r));
|
|
200
|
+
if (r.hint) cell.append(el("div", "hint", r.hint));
|
|
201
|
+
row.append(name, cell); table.append(row);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
root.append(table, el("p", "hint", "Configured in " + s.configPath));
|
|
205
|
+
}
|
|
206
|
+
async function load() { try { draw(await call("GET", "/v1/panel")); } catch (e) { if (e.message !== "not signed in") root.textContent = "β οΈ " + e.message; } }
|
|
207
|
+
function start() { load(); }
|
|
208
|
+
if (!token) needSignIn(); else start();
|
|
209
209
|
`;
|
|
210
|
-
const PUBLIC_ACCESS_SCRIPT = `
|
|
211
|
-
var LINKS = ${JSON.stringify(LINKS)}, model = null, beat = null;
|
|
212
|
-
function paint(m) {
|
|
213
|
-
model = m;
|
|
214
|
-
document.getElementById("banner").textContent = m.banner;
|
|
215
|
-
m.steps.forEach(function (s, i) {
|
|
216
|
-
var sec = document.getElementById("s" + i);
|
|
217
|
-
sec.querySelector(".mark").textContent = s.mark;
|
|
218
|
-
sec.classList.toggle("next", i === m.next);
|
|
219
|
-
sec.classList.toggle("off", !!s.off);
|
|
220
|
-
var note = sec.querySelector(".note");
|
|
221
|
-
if (note) { note.textContent = s.note ? s.note.text : ""; if (s.note) note.dataset.severity = s.note.severity; }
|
|
222
|
-
});
|
|
223
|
-
Object.keys(m.buttons).forEach(function (id) { var b = document.getElementById(id); b.disabled = !m.buttons[id].on; b.title = m.buttons[id].tip; });
|
|
224
|
-
document.getElementById("svc").textContent = m.serviceUrl || "β (BN's gateway port is not known until step 1 is done)";
|
|
225
|
-
document.getElementById("done").hidden = !m.connectorUrl;
|
|
226
|
-
document.getElementById("mcpUrl").textContent = m.connectorUrl || "";
|
|
227
|
-
var host = document.getElementById("host");
|
|
228
|
-
if (document.activeElement !== host && m.hostname && !host.value) host.value = m.hostname;
|
|
229
|
-
}
|
|
230
|
-
function fail(text) { document.getElementById("fail").textContent = text; }
|
|
231
|
-
var pollFailed = false;
|
|
232
|
-
async function refresh() { try { paint(await call("GET", "/v1/public-access")); if (pollFailed) { pollFailed = false; fail(""); } } catch (e) { if (e.message !== "not signed in") { pollFailed = true; fail("β οΈ " + e.message); } } }
|
|
233
|
-
document.addEventListener("click", async function (e) {
|
|
234
|
-
var b = e.target.closest("button[data-cmd]");
|
|
235
|
-
if (!b || b.disabled) return;
|
|
236
|
-
var cmd = b.dataset.cmd;
|
|
237
|
-
if (cmd === "open") { window.open(LINKS[b.dataset.link], "_blank", "noopener"); return; }
|
|
238
|
-
if (cmd === "copy") { try { await navigator.clipboard.writeText(model.copy[b.dataset.what]); } catch (err) { fail("β οΈ The browser refused the copy β " + err.message); } return; }
|
|
239
|
-
var body = {};
|
|
240
|
-
if (cmd === "saveToken") body.paste = document.getElementById("paste").value;
|
|
241
|
-
if (cmd === "saveHostname") body.hostname = document.getElementById("host").value;
|
|
242
|
-
b.disabled = true; fail("");
|
|
243
|
-
try { paint(await call("POST", "/v1/public-access/" + cmd, body)); } catch (err) { if (err.message !== "not signed in") fail("β οΈ " + err.message); await refresh(); }
|
|
244
|
-
});
|
|
245
|
-
function start() { clearInterval(beat); call("POST", "/v1/public-access/ready", {}).then(paint, function (e) { if (e.message !== "not signed in") fail("β οΈ " + e.message); }); beat = setInterval(refresh, 2000); }
|
|
246
|
-
if (!token) needSignIn(); else start();
|
|
210
|
+
const PUBLIC_ACCESS_SCRIPT = `
|
|
211
|
+
var LINKS = ${JSON.stringify(LINKS)}, model = null, beat = null;
|
|
212
|
+
function paint(m) {
|
|
213
|
+
model = m;
|
|
214
|
+
document.getElementById("banner").textContent = m.banner;
|
|
215
|
+
m.steps.forEach(function (s, i) {
|
|
216
|
+
var sec = document.getElementById("s" + i);
|
|
217
|
+
sec.querySelector(".mark").textContent = s.mark;
|
|
218
|
+
sec.classList.toggle("next", i === m.next);
|
|
219
|
+
sec.classList.toggle("off", !!s.off);
|
|
220
|
+
var note = sec.querySelector(".note");
|
|
221
|
+
if (note) { note.textContent = s.note ? s.note.text : ""; if (s.note) note.dataset.severity = s.note.severity; }
|
|
222
|
+
});
|
|
223
|
+
Object.keys(m.buttons).forEach(function (id) { var b = document.getElementById(id); b.disabled = !m.buttons[id].on; b.title = m.buttons[id].tip; });
|
|
224
|
+
document.getElementById("svc").textContent = m.serviceUrl || "β (BN's gateway port is not known until step 1 is done)";
|
|
225
|
+
document.getElementById("done").hidden = !m.connectorUrl;
|
|
226
|
+
document.getElementById("mcpUrl").textContent = m.connectorUrl || "";
|
|
227
|
+
var host = document.getElementById("host");
|
|
228
|
+
if (document.activeElement !== host && m.hostname && !host.value) host.value = m.hostname;
|
|
229
|
+
}
|
|
230
|
+
function fail(text) { document.getElementById("fail").textContent = text; }
|
|
231
|
+
var pollFailed = false;
|
|
232
|
+
async function refresh() { try { paint(await call("GET", "/v1/public-access")); if (pollFailed) { pollFailed = false; fail(""); } } catch (e) { if (e.message !== "not signed in") { pollFailed = true; fail("β οΈ " + e.message); } } }
|
|
233
|
+
document.addEventListener("click", async function (e) {
|
|
234
|
+
var b = e.target.closest("button[data-cmd]");
|
|
235
|
+
if (!b || b.disabled) return;
|
|
236
|
+
var cmd = b.dataset.cmd;
|
|
237
|
+
if (cmd === "open") { window.open(LINKS[b.dataset.link], "_blank", "noopener"); return; }
|
|
238
|
+
if (cmd === "copy") { try { await navigator.clipboard.writeText(model.copy[b.dataset.what]); } catch (err) { fail("β οΈ The browser refused the copy β " + err.message); } return; }
|
|
239
|
+
var body = {};
|
|
240
|
+
if (cmd === "saveToken") body.paste = document.getElementById("paste").value;
|
|
241
|
+
if (cmd === "saveHostname") body.hostname = document.getElementById("host").value;
|
|
242
|
+
b.disabled = true; fail("");
|
|
243
|
+
try { paint(await call("POST", "/v1/public-access/" + cmd, body)); } catch (err) { if (err.message !== "not signed in") fail("β οΈ " + err.message); await refresh(); }
|
|
244
|
+
});
|
|
245
|
+
function start() { clearInterval(beat); call("POST", "/v1/public-access/ready", {}).then(paint, function (e) { if (e.message !== "not signed in") fail("β οΈ " + e.message); }); beat = setInterval(refresh, 2000); }
|
|
246
|
+
if (!token) needSignIn(); else start();
|
|
247
247
|
`;
|
|
248
248
|
export function settingsHtml() {
|
|
249
249
|
return shell("BN Settings", "/settings", `<div id="said" class="note" role="status"></div><div id="root">β³ Loadingβ¦</div>`, SETTINGS_SCRIPT);
|
|
@@ -74,8 +74,8 @@ function publicBase(request) {
|
|
|
74
74
|
/**
|
|
75
75
|
* The live windows serving `extension` on this machine, grouped by the workspace each runs in: label -> { page -> entry
|
|
76
76
|
* address }. On this machine the address carries that window's key on the loopback port; through the gateway (`base`
|
|
77
|
-
* is its public address)
|
|
78
|
-
* windows on one workspace answer with the newest record.
|
|
77
|
+
* is its public address) only this process's own window is listed, at its public address, because the gateway reaches
|
|
78
|
+
* one port per public host and no other window behind it. Two windows on one workspace answer with the newest record.
|
|
79
79
|
*/
|
|
80
80
|
function workspacesServed(extension, base) {
|
|
81
81
|
const directory = recordDirectory(extension);
|
|
@@ -86,7 +86,7 @@ function workspacesServed(extension, base) {
|
|
|
86
86
|
const newest = new Map();
|
|
87
87
|
for (const name of fs.readdirSync(directory)) {
|
|
88
88
|
const match = /^(\d+)\.json$/.exec(name);
|
|
89
|
-
if (match === null || !alive(Number(match[1]))) {
|
|
89
|
+
if (match === null || !alive(Number(match[1])) || (base !== undefined && Number(match[1]) !== process.pid)) {
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
92
|
let record;
|
|
@@ -108,8 +108,8 @@ function workspacesServed(extension, base) {
|
|
|
108
108
|
served.set(label, Object.fromEntries(Object.entries(record.pages).map(([page, info]) => {
|
|
109
109
|
// NULL-OK: field search is OPTIONAL and therefore it is ok to check for NULL
|
|
110
110
|
const search = info.search ?? "";
|
|
111
|
-
const at = `/${encodeURIComponent(page)}/${search}
|
|
112
|
-
return [page, base === undefined ? `http://127.0.0.1:${record.port}${at}${TOKEN_PARAMETER}=${record.token}` : `${base}${at}
|
|
111
|
+
const at = `/${encodeURIComponent(page)}/${search}`;
|
|
112
|
+
return [page, base === undefined ? `http://127.0.0.1:${record.port}${at}${search === "" ? "?" : "&"}${TOKEN_PARAMETER}=${record.token}` : `${base}${at}`];
|
|
113
113
|
})));
|
|
114
114
|
}
|
|
115
115
|
return served;
|
|
@@ -917,7 +917,17 @@ class WebHost {
|
|
|
917
917
|
}
|
|
918
918
|
const home = url.searchParams.get("bullseye-peek");
|
|
919
919
|
if (home !== null && ROSTER_EXTENSIONS.has(this.extension)) {
|
|
920
|
-
|
|
920
|
+
let back;
|
|
921
|
+
try {
|
|
922
|
+
back = this.peekedFrom(base).get(home)?.[page.name];
|
|
923
|
+
}
|
|
924
|
+
catch (err) {
|
|
925
|
+
if (!(err instanceof SyntaxError))
|
|
926
|
+
throw err;
|
|
927
|
+
// OWNER: the peek read is this request's trigger root β a workspace list that is not defined or cannot be read draws the peek with its reason in place of the way back, and the process serving it goes on.
|
|
928
|
+
return send(response, 200, MIME[".html"], peekedRosterPage(this.label, home, undefined, err.message), { "Cache-Control": "no-store" });
|
|
929
|
+
}
|
|
930
|
+
return send(response, 200, MIME[".html"], peekedRosterPage(this.label, home, back), { "Cache-Control": "no-store" });
|
|
921
931
|
}
|
|
922
932
|
return this.serveDocument(page, response);
|
|
923
933
|
}
|
|
@@ -933,6 +943,11 @@ class WebHost {
|
|
|
933
943
|
listed.set(this.label, windows.get(this.label));
|
|
934
944
|
return listed;
|
|
935
945
|
}
|
|
946
|
+
/** The addresses a peek's way back can name: the service's for an extension whose service draws its pages, else the live windows'. */
|
|
947
|
+
peekedFrom(base) {
|
|
948
|
+
// NULL-OK: field service is OPTIONAL and therefore it is ok to check for NULL
|
|
949
|
+
return this.service === undefined ? workspacesServed(this.extension, base) : this.workspaces(base);
|
|
950
|
+
}
|
|
936
951
|
level() {
|
|
937
952
|
return this.machine ? { machine: true } : {};
|
|
938
953
|
}
|
|
@@ -1180,6 +1195,9 @@ class ServiceHost extends WebHost {
|
|
|
1180
1195
|
workspaces() {
|
|
1181
1196
|
return this.listed();
|
|
1182
1197
|
}
|
|
1198
|
+
peekedFrom() {
|
|
1199
|
+
return this.listed();
|
|
1200
|
+
}
|
|
1183
1201
|
/** The service is on no workspace of its own: with no workspace list to read it is on none. */
|
|
1184
1202
|
ownLabel() {
|
|
1185
1203
|
return "";
|
|
@@ -1211,8 +1229,10 @@ function indexPage(host, base) {
|
|
|
1211
1229
|
}
|
|
1212
1230
|
/** The extensions whose page is a roster of work this window owns: another workspace's roster is not shown from here, so a peek at one answers in words instead of a page that could start work. */
|
|
1213
1231
|
const ROSTER_EXTENSIONS = new Set(["fleetview"]);
|
|
1214
|
-
function peekedRosterPage(label, home, back) {
|
|
1215
|
-
|
|
1232
|
+
function peekedRosterPage(label, home, back, listUnreadable) {
|
|
1233
|
+
// NULL-OK: field listUnreadable is OPTIONAL and therefore it is ok to check for NULL
|
|
1234
|
+
const unread = listUnreadable === undefined ? "" : `<p>π΄ No way back to ${escapeAttribute(home)}: the workspace list cannot be read β ${escapeAttribute(listUnreadable)}</p>`;
|
|
1235
|
+
const link = back === undefined ? unread : `<p><a href="${escapeAttribute(back)}" style="color:#9cdcfe">β¬
Back to ${escapeAttribute(home)}</a></p>`;
|
|
1216
1236
|
return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>Fleet Β· peeking</title></head>
|
|
1217
1237
|
<body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div style="background:#5a3d00;color:#fff;padding:6px 10px;border-radius:4px">π Peeking at ${escapeAttribute(label)} β look only</div>
|
|
1218
1238
|
<p>This workspace's Fleet roster and queue belong to its own VS Code window, and they are not shown from another workspace yet β so there is nothing here to read, and nothing here can start work or reach that window's main.</p>${link}</body></html>`;
|