omni-notify-mcp 1.3.424 โ 1.3.425
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.
- package/dist/gateway/panelPage.js +216 -216
- package/package.json +1 -1
- package/scripts/shared/ownerGuard.cs +0 -665
- package/scripts/shared/ownerGuard.ps1 +0 -31
|
@@ -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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.425",
|
|
4
4
|
"description": "Reach your AI agents from anywhere โ and let them reach you. One resident process on 127.0.0.1:7475 serves the whole tool surface to Claude Code, GitHub Copilot Chat and Codex: desktop, Telegram, Slack, ntfy, Discord, Teams and SMS are configured in one file, and agents notify you when long work finishes or a decision is needed, ask you a question and wait for your answer, and receive and reply to the messages you send them โ with Do Not Disturb and idle detection deciding what actually gets through.",
|
|
5
5
|
"main": "dist/daemon.js",
|
|
6
6
|
"type": "module",
|
|
@@ -1,665 +0,0 @@
|
|
|
1
|
-
// OWNER-BOUND JOB (#1968, #1983): the ONE source of the kill-on-close Job Object that ends a process tree
|
|
2
|
-
// with its owner. Loaded by ownerGuard.ps1 through Add-Type and called as OwnerJob.Run(...) for FleetView's
|
|
3
|
-
// own launches.
|
|
4
|
-
//
|
|
5
|
-
// #2925: it is NO LONGER compiled into ~/.bullseye/bin/ownerGuard.exe for `claudeCode.claudeProcessWrapper`.
|
|
6
|
-
// That build ran the .NET Framework's csc.exe at every activation, which made a compiler a dependency of a
|
|
7
|
-
// marketplace install; the wrapper is now POSIX-only (media/shared/claudeWrapper.sh, a shell script that needs
|
|
8
|
-
// nothing but /bin/sh) and Windows installs none. Nothing in this file may be re-wired into that setting.
|
|
9
|
-
// Language level is C# 5 (the csc.exe that ships with Windows).
|
|
10
|
-
//
|
|
11
|
-
// THE MECHANISM: the target is created SUSPENDED, assigned to a job carrying KILL_ON_JOB_CLOSE, and only then
|
|
12
|
-
// resumed, so no child can be born outside the job. The guard waits on the owner and the target and, when
|
|
13
|
-
// EITHER ends, terminates the job. BREAKAWAY_OK is set on purpose and SILENT_BREAKAWAY is not: a process that
|
|
14
|
-
// asks for CREATE_BREAKAWAY_FROM_JOB may leave, but nothing leaves by accident - except under `contain`, which leaves
|
|
15
|
-
// BREAKAWAY_OK off because the msys2 runtime asks to break away from every job that allows it (spawn.cc), so a
|
|
16
|
-
// Git Bash tree would otherwise leave the job whole. A child that asks then stays (Microsoft, "Nested Jobs").
|
|
17
|
-
//
|
|
18
|
-
// usage (wrapper mode, owner = the parent process, which is the extension host): ownerGuard.exe <exe> [args...]
|
|
19
|
-
// (explicit owner): ownerGuard.exe --owner <pid> <exe> [args...]
|
|
20
|
-
using System;
|
|
21
|
-
using System.Collections.Generic;
|
|
22
|
-
using System.IO;
|
|
23
|
-
using System.Runtime.InteropServices;
|
|
24
|
-
using System.Text;
|
|
25
|
-
using System.Text.RegularExpressions;
|
|
26
|
-
using System.Threading;
|
|
27
|
-
|
|
28
|
-
public static class OwnerJob
|
|
29
|
-
{
|
|
30
|
-
const uint KILL_ON_JOB_CLOSE = 0x2000;
|
|
31
|
-
const uint BREAKAWAY_OK = 0x800;
|
|
32
|
-
const int EXTENDED_LIMIT_INFORMATION = 9;
|
|
33
|
-
const uint CREATE_SUSPENDED = 0x00000004;
|
|
34
|
-
const int STARTF_USESTDHANDLES = 0x00000100;
|
|
35
|
-
const uint SYNCHRONIZE = 0x00100000;
|
|
36
|
-
const uint PROCESS_QUERY_LIMITED_INFORMATION = 0x1000;
|
|
37
|
-
const uint INFINITE = 0xFFFFFFFF;
|
|
38
|
-
|
|
39
|
-
public const int EXIT_NO_TARGET = 90;
|
|
40
|
-
public const int EXIT_NO_JOB = 91;
|
|
41
|
-
public const int EXIT_NO_LIMIT = 92;
|
|
42
|
-
public const int EXIT_NOT_CREATED = 93;
|
|
43
|
-
public const int EXIT_NOT_ASSIGNED = 94;
|
|
44
|
-
public const int EXIT_OWNER_GONE = 95;
|
|
45
|
-
public const int EXIT_NOT_FOUND = 96;
|
|
46
|
-
public const int EXIT_BATCH_LINE_BREAK = 97;
|
|
47
|
-
public const int EXIT_NOT_RESUMED = 98;
|
|
48
|
-
public const int EXIT_WAIT_FAILED = 99;
|
|
49
|
-
public const int EXIT_NO_EXIT_CODE = 100;
|
|
50
|
-
public const int EXIT_DEADLINE = 101;
|
|
51
|
-
public const int EXIT_ALREADY_RUNNING = 102;
|
|
52
|
-
public const int FRAME_OWNERS = -1;
|
|
53
|
-
const uint WAIT_TIMEOUT = 0x102;
|
|
54
|
-
const uint STILL_ACTIVE = 259;
|
|
55
|
-
const int ERROR_INVALID_PARAMETER = 87;
|
|
56
|
-
|
|
57
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
58
|
-
struct STARTUPINFO
|
|
59
|
-
{
|
|
60
|
-
public int cb;
|
|
61
|
-
public string lpReserved;
|
|
62
|
-
public string lpDesktop;
|
|
63
|
-
public string lpTitle;
|
|
64
|
-
public int dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags;
|
|
65
|
-
public short wShowWindow, cbReserved2;
|
|
66
|
-
public IntPtr lpReserved2, hStdInput, hStdOutput, hStdError;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
70
|
-
struct PROCESS_INFORMATION
|
|
71
|
-
{
|
|
72
|
-
public IntPtr hProcess, hThread;
|
|
73
|
-
public int dwProcessId, dwThreadId;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
77
|
-
struct IO_COUNTERS
|
|
78
|
-
{
|
|
79
|
-
public ulong a, b, c, d, e, f;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
83
|
-
struct JOBOBJECT_BASIC_LIMIT_INFORMATION
|
|
84
|
-
{
|
|
85
|
-
public long PerProcessUserTimeLimit, PerJobUserTimeLimit;
|
|
86
|
-
public uint LimitFlags;
|
|
87
|
-
public UIntPtr MinimumWorkingSetSize, MaximumWorkingSetSize;
|
|
88
|
-
public uint ActiveProcessLimit;
|
|
89
|
-
public UIntPtr Affinity;
|
|
90
|
-
public uint PriorityClass, SchedulingClass;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
94
|
-
struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION
|
|
95
|
-
{
|
|
96
|
-
public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
|
|
97
|
-
public IO_COUNTERS IoInfo;
|
|
98
|
-
public UIntPtr ProcessMemoryLimit, JobMemoryLimit, PeakProcessMemoryUsed, PeakJobMemoryUsed;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
102
|
-
struct PROCESS_BASIC_INFORMATION
|
|
103
|
-
{
|
|
104
|
-
public IntPtr ExitStatus, PebBaseAddress, AffinityMask, BasePriority, UniqueProcessId, InheritedFromUniqueProcessId;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
108
|
-
static extern IntPtr CreateJobObject(IntPtr attributes, string name);
|
|
109
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
110
|
-
static extern bool SetInformationJobObject(IntPtr job, int infoClass, IntPtr info, uint length);
|
|
111
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
112
|
-
static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
113
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
114
|
-
static extern bool TerminateJobObject(IntPtr job, uint exitCode);
|
|
115
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
116
|
-
static extern bool CreateProcess(string application, string commandLine, IntPtr processAttributes, IntPtr threadAttributes,
|
|
117
|
-
bool inheritHandles, uint creationFlags, IntPtr environment, string currentDirectory, ref STARTUPINFO startupInfo,
|
|
118
|
-
out PROCESS_INFORMATION processInformation);
|
|
119
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
120
|
-
static extern IntPtr GetStdHandle(int which);
|
|
121
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
122
|
-
static extern bool CloseHandle(IntPtr handle);
|
|
123
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
124
|
-
static extern uint WaitForMultipleObjects(uint count, IntPtr[] handles, bool waitAll, uint milliseconds);
|
|
125
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
126
|
-
static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
127
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
128
|
-
static extern bool GetExitCodeProcess(IntPtr process, out uint exitCode);
|
|
129
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
130
|
-
static extern uint ResumeThread(IntPtr thread);
|
|
131
|
-
[DllImport("kernel32.dll")]
|
|
132
|
-
static extern IntPtr GetCurrentProcess();
|
|
133
|
-
[DllImport("kernel32.dll")]
|
|
134
|
-
static extern int GetCurrentProcessId();
|
|
135
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
136
|
-
static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
|
|
137
|
-
[DllImport("ntdll.dll")]
|
|
138
|
-
static extern int NtQueryInformationProcess(IntPtr process, int infoClass, ref PROCESS_BASIC_INFORMATION info, int length, out int returned);
|
|
139
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
140
|
-
static extern bool QueryFullProcessImageName(IntPtr process, int flags, StringBuilder name, ref int size);
|
|
141
|
-
|
|
142
|
-
// One argument as CommandLineToArgvW reads it back: quoted only when it must be, a quote escaped by
|
|
143
|
-
// backslashes per the Windows rules, so a path with spaces stays ONE argument.
|
|
144
|
-
public static string QuoteArg(string arg)
|
|
145
|
-
{
|
|
146
|
-
if (arg.Length > 0 && arg.IndexOfAny(new char[] { ' ', '\t', '\n', '\v', '"' }) < 0)
|
|
147
|
-
{
|
|
148
|
-
return arg;
|
|
149
|
-
}
|
|
150
|
-
StringBuilder sb = new StringBuilder("\"");
|
|
151
|
-
int slashes = 0;
|
|
152
|
-
foreach (char ch in arg)
|
|
153
|
-
{
|
|
154
|
-
if (ch == '\\') { slashes++; continue; }
|
|
155
|
-
if (ch == '"') { sb.Append('\\', 2 * slashes + 1); sb.Append('"'); }
|
|
156
|
-
else { sb.Append('\\', slashes); sb.Append(ch); }
|
|
157
|
-
slashes = 0;
|
|
158
|
-
}
|
|
159
|
-
sb.Append('\\', 2 * slashes);
|
|
160
|
-
sb.Append('"');
|
|
161
|
-
return sb.ToString();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// cmd.exe reads its command line by rules of its own: every character it treats as special, the quote and the
|
|
165
|
-
// space included, is escaped with a caret so the whole argument is literal text to it.
|
|
166
|
-
static string EscapeCmd(string text)
|
|
167
|
-
{
|
|
168
|
-
return Regex.Replace(text, "([()\\]\\[%!^\"`<>&|;, *?])", "^$1");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
static int ParentOf(IntPtr process)
|
|
172
|
-
{
|
|
173
|
-
PROCESS_BASIC_INFORMATION info = new PROCESS_BASIC_INFORMATION();
|
|
174
|
-
int returned;
|
|
175
|
-
if (NtQueryInformationProcess(process, 0, ref info, Marshal.SizeOf(info), out returned) != 0)
|
|
176
|
-
{
|
|
177
|
-
return 0;
|
|
178
|
-
}
|
|
179
|
-
return (int)info.InheritedFromUniqueProcessId.ToInt64();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
static int ParentPid()
|
|
183
|
-
{
|
|
184
|
-
return ParentOf(GetCurrentProcess());
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
static long StartOf(IntPtr process, int pid)
|
|
188
|
-
{
|
|
189
|
-
long start, ignored;
|
|
190
|
-
if (!GetProcessTimes(process, out start, out ignored, out ignored, out ignored))
|
|
191
|
-
{
|
|
192
|
-
throw new InvalidOperationException("the start time of process " + pid + " could not be read (win32 " + Marshal.GetLastWin32Error() + ")");
|
|
193
|
-
}
|
|
194
|
-
return start;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// A pid names an ancestor only if that process STARTED BEFORE the younger one: a recycled pid belongs to a
|
|
198
|
-
// younger process, and then the real ancestor is already dead.
|
|
199
|
-
static IntPtr OpenGone(int pid, uint access)
|
|
200
|
-
{
|
|
201
|
-
IntPtr process = OpenProcess(access, false, pid);
|
|
202
|
-
if (process == IntPtr.Zero)
|
|
203
|
-
{
|
|
204
|
-
int why = Marshal.GetLastWin32Error();
|
|
205
|
-
if (why != ERROR_INVALID_PARAMETER)
|
|
206
|
-
{
|
|
207
|
-
throw new InvalidOperationException("process " + pid + " could not be opened (win32 " + why + ")");
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return process;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
static IntPtr OpenOlderThan(int pid, IntPtr younger, int youngerPid)
|
|
214
|
-
{
|
|
215
|
-
IntPtr process = OpenGone(pid, SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION);
|
|
216
|
-
if (process == IntPtr.Zero)
|
|
217
|
-
{
|
|
218
|
-
return process;
|
|
219
|
-
}
|
|
220
|
-
if (StartOf(process, pid) > StartOf(younger, youngerPid))
|
|
221
|
-
{
|
|
222
|
-
CloseHandle(process);
|
|
223
|
-
return IntPtr.Zero;
|
|
224
|
-
}
|
|
225
|
-
return process;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
static IntPtr OpenOwner(int ownerPid, bool mustPredateSelf)
|
|
229
|
-
{
|
|
230
|
-
return mustPredateSelf
|
|
231
|
-
? OpenOlderThan(ownerPid, GetCurrentProcess(), GetCurrentProcessId())
|
|
232
|
-
: OpenProcess(SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION, false, ownerPid);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
static string ImageOf(IntPtr process, int pid)
|
|
236
|
-
{
|
|
237
|
-
StringBuilder name = new StringBuilder(1024);
|
|
238
|
-
int size = name.Capacity;
|
|
239
|
-
if (!QueryFullProcessImageName(process, 0, name, ref size))
|
|
240
|
-
{
|
|
241
|
-
throw new InvalidOperationException("the image of process " + pid + " could not be read (win32 " + Marshal.GetLastWin32Error() + ")");
|
|
242
|
-
}
|
|
243
|
-
return name.ToString(0, size);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
static List<IntPtr> ShellFrame()
|
|
247
|
-
{
|
|
248
|
-
List<IntPtr> frame = new List<IntPtr>();
|
|
249
|
-
IntPtr child = GetCurrentProcess();
|
|
250
|
-
int childPid = GetCurrentProcessId();
|
|
251
|
-
while (true)
|
|
252
|
-
{
|
|
253
|
-
int parentPid = ParentOf(child);
|
|
254
|
-
if (parentPid == 0)
|
|
255
|
-
{
|
|
256
|
-
throw new InvalidOperationException("the parent of process " + childPid + " could not be read");
|
|
257
|
-
}
|
|
258
|
-
IntPtr parent = OpenOlderThan(parentPid, child, childPid);
|
|
259
|
-
if (parent == IntPtr.Zero)
|
|
260
|
-
{
|
|
261
|
-
return frame;
|
|
262
|
-
}
|
|
263
|
-
frame.Add(parent);
|
|
264
|
-
string image = Path.GetFileName(ImageOf(parent, parentPid)).ToLowerInvariant();
|
|
265
|
-
if (image != "bash.exe" && image != "sh.exe")
|
|
266
|
-
{
|
|
267
|
-
return frame;
|
|
268
|
-
}
|
|
269
|
-
child = parent;
|
|
270
|
-
childPid = parentPid;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
static string ReadLock(string path)
|
|
275
|
-
{
|
|
276
|
-
try
|
|
277
|
-
{
|
|
278
|
-
using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)))
|
|
279
|
-
{
|
|
280
|
-
return reader.ReadToEnd().Trim();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
catch (FileNotFoundException)
|
|
284
|
-
{
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
static bool StillHolds(int pid, long start)
|
|
290
|
-
{
|
|
291
|
-
IntPtr process = OpenGone(pid, PROCESS_QUERY_LIMITED_INFORMATION);
|
|
292
|
-
if (process == IntPtr.Zero)
|
|
293
|
-
{
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
uint code;
|
|
297
|
-
bool alive = StartOf(process, pid) == start && GetExitCodeProcess(process, out code) && code == STILL_ACTIVE;
|
|
298
|
-
CloseHandle(process);
|
|
299
|
-
return alive;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
static bool ParseLock(string held, out int pid, out long start)
|
|
303
|
-
{
|
|
304
|
-
string[] parts = held.Split(' ');
|
|
305
|
-
start = 0;
|
|
306
|
-
pid = 0;
|
|
307
|
-
return parts.Length == 2 && int.TryParse(parts[0], out pid) && long.TryParse(parts[1], out start);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
static int TakeLock(string path, out string mine)
|
|
311
|
-
{
|
|
312
|
-
mine = GetCurrentProcessId() + " " + StartOf(GetCurrentProcess(), GetCurrentProcessId());
|
|
313
|
-
for (int attempt = 0; attempt < 2; attempt++)
|
|
314
|
-
{
|
|
315
|
-
if (!File.Exists(path))
|
|
316
|
-
{
|
|
317
|
-
try
|
|
318
|
-
{
|
|
319
|
-
using (FileStream file = new FileStream(path, FileMode.CreateNew, FileAccess.Write, FileShare.Read))
|
|
320
|
-
{
|
|
321
|
-
byte[] bytes = Encoding.ASCII.GetBytes(mine);
|
|
322
|
-
file.Write(bytes, 0, bytes.Length);
|
|
323
|
-
}
|
|
324
|
-
return 0;
|
|
325
|
-
}
|
|
326
|
-
catch (IOException)
|
|
327
|
-
{
|
|
328
|
-
if (!File.Exists(path))
|
|
329
|
-
{
|
|
330
|
-
throw;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
string held = ReadLock(path);
|
|
335
|
-
int pid;
|
|
336
|
-
long start;
|
|
337
|
-
if (held != null && !ParseLock(held, out pid, out start))
|
|
338
|
-
{
|
|
339
|
-
Thread.Sleep(1000);
|
|
340
|
-
held = ReadLock(path);
|
|
341
|
-
}
|
|
342
|
-
if (held == null)
|
|
343
|
-
{
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
bool parsed = ParseLock(held, out pid, out start);
|
|
347
|
-
if (parsed && StillHolds(pid, start))
|
|
348
|
-
{
|
|
349
|
-
Say("REFUSED - an earlier run (pid " + pid + ", started " + DateTime.FromFileTime(start).ToString("yyyy-MM-dd HH:mm:ss") + ") still holds " + path + " - this launch did not run");
|
|
350
|
-
return EXIT_ALREADY_RUNNING;
|
|
351
|
-
}
|
|
352
|
-
try
|
|
353
|
-
{
|
|
354
|
-
File.Delete(path);
|
|
355
|
-
}
|
|
356
|
-
catch (IOException e)
|
|
357
|
-
{
|
|
358
|
-
Say("REFUSED - " + path + " named '" + held + "' and could not be replaced (" + e.Message + ") - this launch did not run");
|
|
359
|
-
return EXIT_ALREADY_RUNNING;
|
|
360
|
-
}
|
|
361
|
-
Say("STALE LOCK - " + path + " named '" + held + "', which " + (parsed ? "no longer runs" : "is not a pid and start time") + " - taken over");
|
|
362
|
-
}
|
|
363
|
-
Say("REFUSED - " + path + " was taken by another launch while its stale holder was being replaced - this launch did not run");
|
|
364
|
-
return EXIT_ALREADY_RUNNING;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
static void ReleaseLock(string path, string mine)
|
|
368
|
-
{
|
|
369
|
-
if (ReadLock(path) == mine)
|
|
370
|
-
{
|
|
371
|
-
File.Delete(path);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
static void Say(string text)
|
|
376
|
-
{
|
|
377
|
-
Console.Error.WriteLine("ownerGuard: " + text);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// The target as the launch has always resolved it (Get-Command -CommandType Application): a name with a folder is
|
|
381
|
-
// taken as given, a bare name is searched along PATH, and a name without a PATHEXT extension tries each one.
|
|
382
|
-
static string Resolve(string exe)
|
|
383
|
-
{
|
|
384
|
-
List<string> extensions = new List<string>((Environment.GetEnvironmentVariable("PATHEXT") ?? ".COM;.EXE;.BAT;.CMD")
|
|
385
|
-
.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
|
386
|
-
List<string> folders = new List<string>();
|
|
387
|
-
if (exe.IndexOfAny(new char[] { '\\', '/', ':' }) >= 0)
|
|
388
|
-
{
|
|
389
|
-
folders.Add(null);
|
|
390
|
-
}
|
|
391
|
-
else
|
|
392
|
-
{
|
|
393
|
-
foreach (string dir in (Environment.GetEnvironmentVariable("PATH") ?? "").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
394
|
-
{
|
|
395
|
-
folders.Add(dir.Trim('"'));
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
foreach (string folder in folders)
|
|
399
|
-
{
|
|
400
|
-
string stem = folder == null ? exe : Path.Combine(folder, exe);
|
|
401
|
-
if (File.Exists(stem) && extensions.Exists(delegate(string e) { return stem.EndsWith(e, StringComparison.OrdinalIgnoreCase); }))
|
|
402
|
-
{
|
|
403
|
-
return Path.GetFullPath(stem);
|
|
404
|
-
}
|
|
405
|
-
foreach (string ext in extensions)
|
|
406
|
-
{
|
|
407
|
-
if (File.Exists(stem + ext))
|
|
408
|
-
{
|
|
409
|
-
return Path.GetFullPath(stem + ext);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// The command line the target is created with, or null (and a refusal said) when it cannot be carried.
|
|
417
|
-
static string CommandLine(ref string exe, string[] args, out int refusal)
|
|
418
|
-
{
|
|
419
|
-
refusal = 0;
|
|
420
|
-
string ext = Path.GetExtension(exe).ToLowerInvariant();
|
|
421
|
-
StringBuilder line = new StringBuilder();
|
|
422
|
-
if (ext == ".cmd" || ext == ".bat")
|
|
423
|
-
{
|
|
424
|
-
foreach (string arg in args)
|
|
425
|
-
{
|
|
426
|
-
if (arg.IndexOfAny(new char[] { '\r', '\n' }) >= 0)
|
|
427
|
-
{
|
|
428
|
-
Say("the target '" + exe + "' is a batch file and one of its arguments holds a line break, which cmd.exe cannot carry - nothing was started");
|
|
429
|
-
refusal = EXIT_BATCH_LINE_BREAK;
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
StringBuilder inner = new StringBuilder(EscapeCmd(exe));
|
|
434
|
-
foreach (string arg in args)
|
|
435
|
-
{
|
|
436
|
-
inner.Append(' ').Append(EscapeCmd(EscapeCmd(QuoteArg(arg))));
|
|
437
|
-
}
|
|
438
|
-
exe = Path.Combine(Environment.SystemDirectory, "cmd.exe");
|
|
439
|
-
return QuoteArg(exe) + " /d /s /v:off /c \"" + inner + "\"";
|
|
440
|
-
}
|
|
441
|
-
line.Append(QuoteArg(exe));
|
|
442
|
-
foreach (string arg in args)
|
|
443
|
-
{
|
|
444
|
-
line.Append(' ').Append(QuoteArg(arg));
|
|
445
|
-
}
|
|
446
|
-
return line.ToString();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
public static int Run(int ownerPid, string exe, string[] args, string cwd)
|
|
450
|
-
{
|
|
451
|
-
return Run(ownerPid, exe, args, cwd, 0, false, null);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Runs the target inside a kill-on-close job and answers the target's own exit code. ownerPid <= 0 means
|
|
455
|
-
// "the parent process owns this launch", FRAME_OWNERS means "the shell frame owns it" (ShellFrame). cwd null or
|
|
456
|
-
// empty starts the target where this process runs. deadlineSeconds > 0 ends the whole job at that age
|
|
457
|
-
// (EXIT_DEADLINE). contain leaves BREAKAWAY_OK off, so no process inside can leave the job, Git Bash's
|
|
458
|
-
// included. lockFile, when given, admits one launch at a time (TakeLock).
|
|
459
|
-
public static int Run(int ownerPid, string exe, string[] args, string cwd, int deadlineSeconds, bool contain, string lockFile)
|
|
460
|
-
{
|
|
461
|
-
if (string.IsNullOrEmpty(exe) || exe.Trim().Length == 0)
|
|
462
|
-
{
|
|
463
|
-
Say("the target executable is empty - nothing was started");
|
|
464
|
-
return EXIT_NO_TARGET;
|
|
465
|
-
}
|
|
466
|
-
if (string.IsNullOrEmpty(cwd))
|
|
467
|
-
{
|
|
468
|
-
cwd = null;
|
|
469
|
-
}
|
|
470
|
-
string resolved = Resolve(exe);
|
|
471
|
-
if (resolved == null)
|
|
472
|
-
{
|
|
473
|
-
Say("the target '" + exe + "' is not an executable on PATH or on disk - nothing was started");
|
|
474
|
-
return EXIT_NOT_FOUND;
|
|
475
|
-
}
|
|
476
|
-
exe = resolved;
|
|
477
|
-
int refusal;
|
|
478
|
-
string line = CommandLine(ref exe, args, out refusal);
|
|
479
|
-
if (line == null)
|
|
480
|
-
{
|
|
481
|
-
return refusal;
|
|
482
|
-
}
|
|
483
|
-
string mine = null;
|
|
484
|
-
if (!string.IsNullOrEmpty(lockFile))
|
|
485
|
-
{
|
|
486
|
-
int refused = TakeLock(lockFile, out mine);
|
|
487
|
-
if (refused != 0)
|
|
488
|
-
{
|
|
489
|
-
return refused;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
try
|
|
493
|
-
{
|
|
494
|
-
return Launch(ownerPid, exe, line, cwd, deadlineSeconds, contain);
|
|
495
|
-
}
|
|
496
|
-
finally
|
|
497
|
-
{
|
|
498
|
-
if (mine != null)
|
|
499
|
-
{
|
|
500
|
-
ReleaseLock(lockFile, mine);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
static int Launch(int ownerPid, string exe, string line, string cwd, int deadlineSeconds, bool contain)
|
|
506
|
-
{
|
|
507
|
-
bool frame = ownerPid == FRAME_OWNERS;
|
|
508
|
-
bool viaParent = !frame && ownerPid <= 0;
|
|
509
|
-
if (viaParent)
|
|
510
|
-
{
|
|
511
|
-
ownerPid = ParentPid();
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
IntPtr job = CreateJobObject(IntPtr.Zero, null);
|
|
515
|
-
if (job == IntPtr.Zero)
|
|
516
|
-
{
|
|
517
|
-
Say("the job object could not be created (win32 " + Marshal.GetLastWin32Error() + ") - the target was NOT started unguarded");
|
|
518
|
-
return EXIT_NO_JOB;
|
|
519
|
-
}
|
|
520
|
-
JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION();
|
|
521
|
-
limits.BasicLimitInformation.LimitFlags = contain ? KILL_ON_JOB_CLOSE : KILL_ON_JOB_CLOSE | BREAKAWAY_OK;
|
|
522
|
-
int size = Marshal.SizeOf(limits);
|
|
523
|
-
IntPtr buffer = Marshal.AllocHGlobal(size);
|
|
524
|
-
try
|
|
525
|
-
{
|
|
526
|
-
Marshal.StructureToPtr(limits, buffer, false);
|
|
527
|
-
if (!SetInformationJobObject(job, EXTENDED_LIMIT_INFORMATION, buffer, (uint)size))
|
|
528
|
-
{
|
|
529
|
-
Say("the job could not be told to kill on close (win32 " + Marshal.GetLastWin32Error() + ") - the target was NOT started unguarded");
|
|
530
|
-
CloseHandle(job);
|
|
531
|
-
return EXIT_NO_LIMIT;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
finally
|
|
535
|
-
{
|
|
536
|
-
Marshal.FreeHGlobal(buffer);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
STARTUPINFO startup = new STARTUPINFO();
|
|
540
|
-
startup.cb = Marshal.SizeOf(startup);
|
|
541
|
-
IntPtr stdin = GetStdHandle(-10), stdout = GetStdHandle(-11), stderr = GetStdHandle(-12);
|
|
542
|
-
if (stdin != IntPtr.Zero && stdout != IntPtr.Zero && stderr != IntPtr.Zero)
|
|
543
|
-
{
|
|
544
|
-
startup.dwFlags = STARTF_USESTDHANDLES;
|
|
545
|
-
startup.hStdInput = stdin;
|
|
546
|
-
startup.hStdOutput = stdout;
|
|
547
|
-
startup.hStdError = stderr;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
PROCESS_INFORMATION process;
|
|
551
|
-
if (!CreateProcess(exe, line, IntPtr.Zero, IntPtr.Zero, true, CREATE_SUSPENDED, IntPtr.Zero, cwd, ref startup, out process))
|
|
552
|
-
{
|
|
553
|
-
Say("the target could not be created (win32 " + Marshal.GetLastWin32Error() + ") - nothing was started");
|
|
554
|
-
CloseHandle(job);
|
|
555
|
-
return EXIT_NOT_CREATED;
|
|
556
|
-
}
|
|
557
|
-
if (!AssignProcessToJobObject(job, process.hProcess))
|
|
558
|
-
{
|
|
559
|
-
int error = Marshal.GetLastWin32Error();
|
|
560
|
-
TerminateJobObject(job, EXIT_NOT_ASSIGNED);
|
|
561
|
-
CloseHandle(process.hThread);
|
|
562
|
-
CloseHandle(process.hProcess);
|
|
563
|
-
CloseHandle(job);
|
|
564
|
-
Say("the target could not be put under the job that ends it with its owner (win32 " + error + ") - it was stopped rather than left unguarded");
|
|
565
|
-
return EXIT_NOT_ASSIGNED;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// The owner is opened AFTER the target sits in the job and BEFORE it runs, so a dead owner stops it unrun.
|
|
569
|
-
List<IntPtr> owners = new List<IntPtr>();
|
|
570
|
-
if (frame)
|
|
571
|
-
{
|
|
572
|
-
owners = ShellFrame();
|
|
573
|
-
}
|
|
574
|
-
else if (ownerPid > 0)
|
|
575
|
-
{
|
|
576
|
-
IntPtr owner = OpenOwner(ownerPid, viaParent);
|
|
577
|
-
if (owner != IntPtr.Zero)
|
|
578
|
-
{
|
|
579
|
-
owners.Add(owner);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
if (owners.Count == 0)
|
|
583
|
-
{
|
|
584
|
-
int why = Marshal.GetLastWin32Error();
|
|
585
|
-
TerminateJobObject(job, EXIT_OWNER_GONE);
|
|
586
|
-
CloseHandle(process.hThread);
|
|
587
|
-
CloseHandle(process.hProcess);
|
|
588
|
-
CloseHandle(job);
|
|
589
|
-
Say((frame ? "the shell frame above this guard" : "the owner process " + ownerPid) + " cannot be watched (win32 " + why + ") - the target was stopped before it ran");
|
|
590
|
-
return EXIT_OWNER_GONE;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if (ResumeThread(process.hThread) == 0xFFFFFFFF)
|
|
594
|
-
{
|
|
595
|
-
int why = Marshal.GetLastWin32Error();
|
|
596
|
-
TerminateJobObject(job, EXIT_NOT_RESUMED);
|
|
597
|
-
Say("the target could not be resumed (win32 " + why + ") - it was stopped rather than left suspended");
|
|
598
|
-
return EXIT_NOT_RESUMED;
|
|
599
|
-
}
|
|
600
|
-
CloseHandle(process.hThread);
|
|
601
|
-
|
|
602
|
-
List<IntPtr> watched = new List<IntPtr>(owners);
|
|
603
|
-
watched.Insert(0, process.hProcess);
|
|
604
|
-
uint waited = WaitForMultipleObjects((uint)watched.Count, watched.ToArray(), false, deadlineSeconds > 0 ? (uint)deadlineSeconds * 1000 : INFINITE);
|
|
605
|
-
int waitError = Marshal.GetLastWin32Error();
|
|
606
|
-
foreach (IntPtr owner in owners)
|
|
607
|
-
{
|
|
608
|
-
CloseHandle(owner);
|
|
609
|
-
}
|
|
610
|
-
if (waited == 0xFFFFFFFF)
|
|
611
|
-
{
|
|
612
|
-
TerminateJobObject(job, EXIT_WAIT_FAILED);
|
|
613
|
-
Say("the wait on the target and its owner failed (win32 " + waitError + ") - the target was stopped rather than left unwatched");
|
|
614
|
-
return EXIT_WAIT_FAILED;
|
|
615
|
-
}
|
|
616
|
-
if (waited == WAIT_TIMEOUT)
|
|
617
|
-
{
|
|
618
|
-
TerminateJobObject(job, EXIT_DEADLINE);
|
|
619
|
-
Say("DEADLINE - the target ran past its " + deadlineSeconds + " s; its whole job was ended");
|
|
620
|
-
return EXIT_DEADLINE;
|
|
621
|
-
}
|
|
622
|
-
if (waited != 0)
|
|
623
|
-
{
|
|
624
|
-
TerminateJobObject(job, EXIT_OWNER_GONE);
|
|
625
|
-
Say("OWNER GONE - a process this launch was bound to ended; the target's whole job was ended");
|
|
626
|
-
return EXIT_OWNER_GONE;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
uint code = 0;
|
|
630
|
-
if (!GetExitCodeProcess(process.hProcess, out code))
|
|
631
|
-
{
|
|
632
|
-
int why = Marshal.GetLastWin32Error();
|
|
633
|
-
TerminateJobObject(job, EXIT_NO_EXIT_CODE);
|
|
634
|
-
Say("the target's exit code could not be read (win32 " + why + ") - the target was stopped");
|
|
635
|
-
return EXIT_NO_EXIT_CODE;
|
|
636
|
-
}
|
|
637
|
-
TerminateJobObject(job, 1);
|
|
638
|
-
CloseHandle(process.hProcess);
|
|
639
|
-
CloseHandle(job);
|
|
640
|
-
return (int)code;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
public static int Main(string[] argv)
|
|
644
|
-
{
|
|
645
|
-
List<string> rest = new List<string>(argv);
|
|
646
|
-
int ownerPid = 0;
|
|
647
|
-
if (rest.Count >= 2 && rest[0] == "--owner")
|
|
648
|
-
{
|
|
649
|
-
if (!int.TryParse(rest[1], out ownerPid) || ownerPid <= 0)
|
|
650
|
-
{
|
|
651
|
-
Say("--owner needs a process id");
|
|
652
|
-
return EXIT_NO_TARGET;
|
|
653
|
-
}
|
|
654
|
-
rest.RemoveRange(0, 2);
|
|
655
|
-
}
|
|
656
|
-
if (rest.Count == 0)
|
|
657
|
-
{
|
|
658
|
-
Say("usage: ownerGuard.exe [--owner <pid>] <exe> [args...]");
|
|
659
|
-
return EXIT_NO_TARGET;
|
|
660
|
-
}
|
|
661
|
-
string exe = rest[0];
|
|
662
|
-
rest.RemoveAt(0);
|
|
663
|
-
return Run(ownerPid, exe, rest.ToArray(), null);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# OWNER-BOUND LAUNCH (#1968): start one target so that it can never outlive its owner, and so that nothing it
|
|
2
|
-
# started can outlive IT. This script is only the PowerShell door onto ownerGuard.cs, which holds the whole job.
|
|
3
|
-
# #2925: the same source is no longer compiled into an ownerGuard.exe for `claudeCode.claudeProcessWrapper` โ that
|
|
4
|
-
# build ran csc.exe at every activation, and the .NET compiler is not a dependency a marketplace install may carry.
|
|
5
|
-
# The target's own exit code is answered as this script's exit code.
|
|
6
|
-
param(
|
|
7
|
-
[Parameter(Mandatory = $true)][int]$OwnerPid,
|
|
8
|
-
[Parameter(Mandatory = $true)][string]$ExeB64,
|
|
9
|
-
[Parameter(Mandatory = $true)][string]$ArgsB64,
|
|
10
|
-
[Parameter(Mandatory = $true)][AllowEmptyString()][string]$CwdB64,
|
|
11
|
-
[switch]$ShellFrame,
|
|
12
|
-
[int]$DeadlineSeconds = 0,
|
|
13
|
-
[switch]$Contain,
|
|
14
|
-
[string]$LockFile = ""
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
$ErrorActionPreference = "Stop"
|
|
18
|
-
|
|
19
|
-
Add-Type -Path (Join-Path $PSScriptRoot "ownerGuard.cs")
|
|
20
|
-
|
|
21
|
-
$exe = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($ExeB64))
|
|
22
|
-
# ConvertFrom-Json hands back the WHOLE array as one object on Windows PowerShell, so iterate it with
|
|
23
|
-
# foreach: a one-element array arrives as the element itself and a longer one as the array, both right.
|
|
24
|
-
$argv = New-Object System.Collections.Generic.List[string]
|
|
25
|
-
foreach ($item in ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($ArgsB64)) | ConvertFrom-Json)) {
|
|
26
|
-
$argv.Add([string]$item)
|
|
27
|
-
}
|
|
28
|
-
$cwd = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($CwdB64))
|
|
29
|
-
|
|
30
|
-
if ($ShellFrame) { $OwnerPid = [OwnerJob]::FRAME_OWNERS }
|
|
31
|
-
exit ([OwnerJob]::Run($OwnerPid, $exe, $argv.ToArray(), $cwd, $DeadlineSeconds, $Contain.IsPresent, $LockFile))
|