omni-notify-mcp 1.3.493 → 1.3.495
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/daemon.js +6 -2
- package/dist/gateway/package.json +23 -0
- package/dist/gateway/panelPage.js +2 -2
- package/dist/gateway/restDoor.js +4 -4
- package/dist/gateway/{chatPage.js → signInDoor/chatPage.js} +3 -3
- package/dist/gateway/signInDoor/doorSettings.js +36 -0
- package/dist/gateway/{oauthDoor.js → signInDoor/oauthDoor.js} +1 -1
- package/dist/gateway/{passkeyDoor.js → signInDoor/passkeyDoor.js} +21 -7
- package/dist/gateway/signInDoor/shared/package.json +1 -0
- package/dist/gateway/signInDoor/shared/webviewShim.js +996 -0
- package/dist/gatewaySettings.js +7 -33
- package/package.json +3 -3
- /package/dist/gateway/{iconData.js → signInDoor/iconData.js} +0 -0
- /package/dist/gateway/{iconDoor.js → signInDoor/iconDoor.js} +0 -0
- /package/dist/gateway/{passkeyClient.js → signInDoor/passkeyClient.js} +0 -0
package/dist/daemon.js
CHANGED
|
@@ -12,7 +12,7 @@ import { spawn } from "child_process";
|
|
|
12
12
|
import { createWriteStream, existsSync, readFileSync, mkdirSync, renameSync } from "fs";
|
|
13
13
|
import { join } from "path";
|
|
14
14
|
import { fileURLToPath } from "url";
|
|
15
|
-
import { DAEMON_BEAT_PATH, CONFIG_DIR, DAEMON_TAG, PACKAGE_VERSION, startNotifyServer, takePendingInbox, writeRecordFile, yieldGateway } from "./notify.js";
|
|
15
|
+
import { DAEMON_BEAT_PATH, CONFIG_DIR, DAEMON_TAG, PACKAGE_VERSION, smsReachesOwner, startNotifyServer, takePendingInbox, textOwner, writeRecordFile, yieldGateway } from "./notify.js";
|
|
16
16
|
import { startNotifyDoor } from "./gateway/notifyDoor.js";
|
|
17
17
|
import { announceTakeover, inThisBoot } from "./shared/webhost/originHandover.js";
|
|
18
18
|
import { TunnelRunner } from "./gateway/tunnel.js";
|
|
@@ -140,7 +140,11 @@ let handedOver;
|
|
|
140
140
|
const tunnel = new TunnelRunner();
|
|
141
141
|
const daemonHost = {
|
|
142
142
|
clientId: DAEMON_TAG, tag: DAEMON_TAG,
|
|
143
|
-
bindDoor: async (settings) =>
|
|
143
|
+
bindDoor: async (settings) => {
|
|
144
|
+
// #4247 — the sign-in doors text Meni's code through notify, handed in here so passkeyDoor imports no notification code.
|
|
145
|
+
(await import("./gateway/signInDoor/passkeyDoor.js")).setOwnerTexter({ reaches: smsReachesOwner, text: textOwner });
|
|
146
|
+
return (await import("./gateway/restDoor.js")).startRestDoor(settings);
|
|
147
|
+
},
|
|
144
148
|
findOtherOwner: async (port) => (await import("./gateway/lanProbe.js")).findOtherBn(port),
|
|
145
149
|
onDoorOwned: (port) => {
|
|
146
150
|
// #4231 — BN holds no agent CLI: the cluster keeps every chat CLI and its background subagents (#4814), so a BN release never waits on one.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bullseye-sign-in-door",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The public sign-in door every Bullseye host's grants come from: passkey, authenticator and texted-code sign-in, OAuth for the MCP connectors and the sign-in pages. Built from signInDoor/ into dist/ by build-sign-in-door.cjs, which the gateway deploy and refresh run.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20.0.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node build-sign-in-door.cjs"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@simplewebauthn/server": "^14.0.3",
|
|
16
|
+
"qrcode": "^1.5.4"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.0.0",
|
|
20
|
+
"@types/qrcode": "^1.5.6",
|
|
21
|
+
"typescript": "^5.4.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* these very pages, so the panel and a browser with every editor closed show the same thing from the same service.
|
|
6
6
|
*/
|
|
7
7
|
import { PACKAGE_HOMEPAGE } from "../gatewaySettings.js";
|
|
8
|
-
import { NOTICE_SCRIPT, PAGE_STYLE } from "./chatPage.js";
|
|
9
|
-
import { ICON_HEAD } from "./iconDoor.js";
|
|
8
|
+
import { NOTICE_SCRIPT, PAGE_STYLE } from "./signInDoor/chatPage.js";
|
|
9
|
+
import { ICON_HEAD } from "./signInDoor/iconDoor.js";
|
|
10
10
|
import { CONNECTION_SOURCE, PICKER_PAGE_SOURCE } from "../shared/webhost/webviewShim.js";
|
|
11
11
|
export const PANEL_PAGES = ["settings", "public-access"];
|
|
12
12
|
const LINKS = {
|
package/dist/gateway/restDoor.js
CHANGED
|
@@ -19,10 +19,10 @@ import { isAbsolute, join, relative } from "path";
|
|
|
19
19
|
import { createServer, request as httpRequest } from "http";
|
|
20
20
|
import { WebSocket, WebSocketServer } from "ws";
|
|
21
21
|
import { CONFIG_DIR, GatewayError } from "../gatewaySettings.js";
|
|
22
|
-
import { CHAT_HEADERS } from "./chatPage.js";
|
|
23
|
-
import { isIconPath, serveIcon } from "./iconDoor.js";
|
|
24
|
-
import { MCP_PATH, accessGranted, challenge, grantClient, handleOAuth, isOAuthPath, publicBase } from "./oauthDoor.js";
|
|
25
|
-
import { bearer, bearerAdmitted, fromThisMachine, handlePasskey, isPasskeyPath, localOnly, refusalOfRequest, sessionExpiresAt, sessionSignIn, tokenProves } from "./passkeyDoor.js";
|
|
22
|
+
import { CHAT_HEADERS } from "./signInDoor/chatPage.js";
|
|
23
|
+
import { isIconPath, serveIcon } from "./signInDoor/iconDoor.js";
|
|
24
|
+
import { MCP_PATH, accessGranted, challenge, grantClient, handleOAuth, isOAuthPath, publicBase } from "./signInDoor/oauthDoor.js";
|
|
25
|
+
import { bearer, bearerAdmitted, fromThisMachine, handlePasskey, isPasskeyPath, localOnly, refusalOfRequest, sessionExpiresAt, sessionSignIn, tokenProves } from "./signInDoor/passkeyDoor.js";
|
|
26
26
|
import { configFile, panelState, reinstallMessenger, saveConfigFile, saveSetting } from "./panel.js";
|
|
27
27
|
import { PANEL_PAGES, panelHtml } from "./panelPage.js";
|
|
28
28
|
import { configureMcpHosts } from "./mcpHosts.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PACKAGE_VERSION } from "
|
|
1
|
+
import { PACKAGE_VERSION } from "./doorSettings.js";
|
|
2
2
|
import { ICON_HEAD } from "./iconDoor.js";
|
|
3
3
|
import { PASSKEY_SCRIPT } from "./passkeyDoor.js";
|
|
4
4
|
import { PROOF_WAYS } from "./passkeyClient.js";
|
|
5
|
-
import { CONNECTION_SOURCE } from "
|
|
5
|
+
import { CONNECTION_SOURCE } from "./shared/webviewShim.js";
|
|
6
6
|
/** The ancestors allowed to frame this page, and nothing else. VS Code's own webview shell shows the one shared
|
|
7
7
|
* interface inside the extension panel (#2726); a scheme source admits any documentation of that scheme and no site.
|
|
8
8
|
* The same page is also framed in a browser (#3081): the Bullseye dashboard's web shell writes the panel's own HTML
|
|
@@ -400,7 +400,7 @@ export function serviceHtml({ name, host }) {
|
|
|
400
400
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
401
401
|
<title>${safe(name)}</title>${ICON_HEAD}<style>${PAGE_STYLE}</style></head><body class="titled">
|
|
402
402
|
<header><h1 id="title">${safe(name)}</h1><span class="grow"></span><button id="refresh" class="keep" hidden>🔄<span class="lbl"> Refresh</span></button><button id="logout" class="keep" hidden>🚪<span class="lbl"> Logout</span></button></header>
|
|
403
|
-
<div id="status" role="status"></div><div id="serving" class="idbar" hidden data-be-tip="The process that answered this page — its process id, when it started and the sign-in build its code was loaded from — and when this page's sign-in expires"><span class="srv">${safe(host)} · pid ${me.pid} · started ${storedStamp(me.startedAt)} · sign-in
|
|
403
|
+
<div id="status" role="status"></div><div id="serving" class="idbar" hidden data-be-tip="The process that answered this page — its process id, when it started and the sign-in build its code was loaded from — and when this page's sign-in expires"><span class="srv">${safe(host)} · pid ${me.pid} · started ${storedStamp(me.startedAt)} · sign-in ${safe(me.build)}</span><small id="expires" hidden></small></div>
|
|
404
404
|
<main id="main"></main>
|
|
405
405
|
<script>${CONNECTION_SOURCE}</script><script>var FACTS = ${facts}, TITLE = FACTS.name;
|
|
406
406
|
${PASSKEY_SCRIPT}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4247 — what every sign-in door shares: where the notify config lives, the gateway's token settings, the refusal
|
|
3
|
+
* type every door answers with and the build the door was loaded from. The gateway and BullseyeNotif both import it,
|
|
4
|
+
* so a refusal thrown by any door is the one GatewayError class each catcher tests against.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync } from "fs";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
/** The build the door's code was loaded from: the package.json one folder above the built module. */
|
|
11
|
+
export const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
|
|
12
|
+
export const CONFIG_DIR = process.env.NOTIFY_MCP_CONFIG_DIR || join(homedir(), ".notify-mcp");
|
|
13
|
+
export const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
14
|
+
export const DEFAULT_GATEWAY_PORT = 7470;
|
|
15
|
+
/** A refused request, answered to its caller with this status and these words by whichever door it reached. */
|
|
16
|
+
export class GatewayError extends Error {
|
|
17
|
+
status;
|
|
18
|
+
facts;
|
|
19
|
+
/** `facts` ride beside the words in the refusal's body, so a caller acts on what was refused without parsing the message. */
|
|
20
|
+
constructor(status, message, facts = {}) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.facts = facts;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The token is mandatory: a door that is open to the home network never starts without one. */
|
|
27
|
+
export function readGatewaySettings() {
|
|
28
|
+
if (!existsSync(CONFIG_PATH))
|
|
29
|
+
return undefined;
|
|
30
|
+
const section = JSON.parse(readFileSync(CONFIG_PATH, "utf8")).agentGateway;
|
|
31
|
+
if (!section || typeof section.token !== "string" || section.token.length === 0)
|
|
32
|
+
return undefined;
|
|
33
|
+
const host = typeof section.host === "string" && section.host.length > 0 ? section.host : undefined;
|
|
34
|
+
const hosts = Array.isArray(section.hosts) && section.hosts.length > 0 ? section.hosts.map(String) : undefined;
|
|
35
|
+
return { token: section.token, port: typeof section.port === "number" ? section.port : DEFAULT_GATEWAY_PORT, ...(host === undefined ? {} : { host }), ...(hosts === undefined ? {} : { hosts }) };
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "crypto";
|
|
2
2
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
|
-
import { CONFIG_DIR, GatewayError } from "
|
|
4
|
+
import { CONFIG_DIR, GatewayError } from "./doorSettings.js";
|
|
5
5
|
import { ICON_HEAD, logoUri } from "./iconDoor.js";
|
|
6
6
|
import { HOST_RE, LOOPBACK_HOSTS, PASSKEY_SCRIPT, approvalStands, digest, doorState, escapeHtml, mint, fromThisMachine, sessionApproval, tokenProves, tokenStands } from "./passkeyDoor.js";
|
|
7
7
|
export const MCP_PATH = "/mcp";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { PASSKEY_SCRIPT, PROOF_WAYS } from "./passkeyClient.js";
|
|
2
2
|
export { PASSKEY_SCRIPT } from "./passkeyClient.js";
|
|
3
|
+
export { GatewayError, readGatewaySettings } from "./doorSettings.js";
|
|
3
4
|
import { createHash, createHmac, randomBytes, randomInt, timingSafeEqual } from "crypto";
|
|
4
5
|
import { existsSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "fs";
|
|
5
6
|
import { hostname, uptime } from "os";
|
|
6
7
|
import { join } from "path";
|
|
7
8
|
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";
|
|
8
9
|
import QRCode from "qrcode";
|
|
9
|
-
import {
|
|
10
|
-
import { CONFIG_DIR, GatewayError, readGatewaySettings } from "../gatewaySettings.js";
|
|
10
|
+
import { CONFIG_DIR, GatewayError, readGatewaySettings } from "./doorSettings.js";
|
|
11
11
|
import { ICON_HEAD } from "./iconDoor.js";
|
|
12
12
|
const PASSKEY_PREFIX = "/passkey/";
|
|
13
13
|
const ENROL_PATH = "/passkey/enrol";
|
|
@@ -54,6 +54,20 @@ export function ownerRegistry() {
|
|
|
54
54
|
return { origins: names.filter((name) => !outside.includes(name)).map((name) => `https://${name}`), rpID, outside };
|
|
55
55
|
}
|
|
56
56
|
const OWNER_RP_NAME = "Bullseye";
|
|
57
|
+
let noTexterSaid = false;
|
|
58
|
+
/** No sender handed in: SMS reaches nobody, said ONCE on stderr so a gateway older than setOwnerTexter shows in its log instead of only as a lost SMS sign-in. */
|
|
59
|
+
const NO_TEXTER = {
|
|
60
|
+
reaches: () => {
|
|
61
|
+
if (!noTexterSaid)
|
|
62
|
+
process.stderr.write("[agent-gateway] this process handed the sign-in door no SMS sender (setOwnerTexter), so no code can be texted and SMS sign-ins do not stand; a gateway older than passkeyDoor's setOwnerTexter must be redeployed\n");
|
|
63
|
+
noTexterSaid = true;
|
|
64
|
+
return false;
|
|
65
|
+
},
|
|
66
|
+
text: async () => { throw new Error("this process gave the sign-in door no SMS sender"); },
|
|
67
|
+
};
|
|
68
|
+
let ownerTexter = NO_TEXTER;
|
|
69
|
+
/** Every door in this process texts through the sender its booting process hands in here. */
|
|
70
|
+
export function setOwnerTexter(texter) { ownerTexter = texter; }
|
|
57
71
|
// GATE: a lock file nobody can read as a lock (half written, damaged) is taken over once it is this old; a readable lock is only ever taken from a holder that is gone.
|
|
58
72
|
const OWNER_LOCK_UNREADABLE_MS = 30_000;
|
|
59
73
|
// GATE: a change to a file the doors share (the owner registry, a door's session store) waits this long for another process's change to finish, then answers 409 and changes nothing.
|
|
@@ -421,7 +435,7 @@ export function createSignInDoor({ storeFile, product, short, home, host: doorHo
|
|
|
421
435
|
if (legacyRetired(store))
|
|
422
436
|
return false;
|
|
423
437
|
if (approval === SMS)
|
|
424
|
-
return locked(store) &&
|
|
438
|
+
return locked(store) && ownerTexter.reaches();
|
|
425
439
|
// NULL-OK: field authenticator is OPTIONAL and therefore it is ok to check for NULL
|
|
426
440
|
if (approval.startsWith(AUTHENTICATOR))
|
|
427
441
|
return store.authenticator !== undefined && `${AUTHENTICATOR}${store.authenticator.id}` === approval;
|
|
@@ -468,7 +482,7 @@ export function createSignInDoor({ storeFile, product, short, home, host: doorHo
|
|
|
468
482
|
const host = String(req.headers["x-forwarded-host"] ?? req.headers.host ?? "").split(",")[0].trim().replace(/:\d+$/, "").toLowerCase();
|
|
469
483
|
const retired = legacyRetired(store);
|
|
470
484
|
const codes = !retired && locked(store);
|
|
471
|
-
return { enrolled: locked(store), local: fromThisMachine(req), passkey: (!retired && store.passkeys.some((passkey) => passkey.rpID === host)) || (host === doorHost && ownerCredentials().length > 0), authenticator: codes && store.authenticator !== undefined, sms: codes &&
|
|
485
|
+
return { enrolled: locked(store), local: fromThisMachine(req), passkey: (!retired && store.passkeys.some((passkey) => passkey.rpID === host)) || (host === doorHost && ownerCredentials().length > 0), authenticator: codes && store.authenticator !== undefined, sms: codes && ownerTexter.reaches(), codesShut: codesShut(store) };
|
|
472
486
|
}
|
|
473
487
|
function ownerEnrolTicket(host, replaces) {
|
|
474
488
|
if (host.toLowerCase() !== doorHost)
|
|
@@ -725,7 +739,7 @@ ${locked(store) ? "" : `<p class="mut">Until an owner passkey is registered, not
|
|
|
725
739
|
/** Texts a fresh 6-digit code to Meni's mobile; it replaces any earlier one, and only one goes out a minute. */
|
|
726
740
|
async function smsSend(from) {
|
|
727
741
|
codesClosed(readStore());
|
|
728
|
-
if (!
|
|
742
|
+
if (!ownerTexter.reaches())
|
|
729
743
|
throw new GatewayError(404, "no SMS channel reaches Meni's mobile");
|
|
730
744
|
codesOpen(readStore());
|
|
731
745
|
const now = Date.now();
|
|
@@ -738,7 +752,7 @@ ${locked(store) ? "" : `<p class="mut">Until an owner passkey is registered, not
|
|
|
738
752
|
textedCode = sent;
|
|
739
753
|
const minutes = SMS_CODE_LIFETIME_MS / 60_000;
|
|
740
754
|
try {
|
|
741
|
-
await
|
|
755
|
+
await ownerTexter.text(`${short} sign-in code: ${code}. It works once, for ${minutes} minutes. If you did not ask for it, someone is at your ${short} sign-in page.`);
|
|
742
756
|
}
|
|
743
757
|
catch (err) {
|
|
744
758
|
if (textedCode === sent)
|
|
@@ -813,7 +827,7 @@ ${locked(store) ? "" : `<p class="mut">Until an owner passkey is registered, not
|
|
|
813
827
|
const enrollments = [...tickets.entries()].filter(([, ticket]) => ticket.exp > now).map(([key, ticket]) => ({ ref: key.slice(0, SESSION_REF_LENGTH), host: ticket.host, exp: ticket.exp }));
|
|
814
828
|
const registry = ownerRegistry();
|
|
815
829
|
const owner = { rpID: registry.rpID, origins: registry.origins, outside: registry.outside, legacyRetired: legacyRetired(store), credentials: readOwners().credentials.map(({ id, device, createdAt }) => ({ id, device, createdAt })) };
|
|
816
|
-
return { locked: locked(store), sms:
|
|
830
|
+
return { locked: locked(store), sms: ownerTexter.reaches(), passkeys: store.passkeys.map(({ id, rpID, device, createdAt }) => ({ id, rpID, device, createdAt })), owner, authenticator, sessions, enrollments };
|
|
817
831
|
}
|
|
818
832
|
/** Revokes one session by its reference, or every session when none is given; the next request carrying it is refused. Returns how many went. */
|
|
819
833
|
function revokeSessions(ref) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const PICKER_SOURCE = String.raw `
|
|
3
|
+
var BASE_CSS = [
|
|
4
|
+
"@media (max-width: 480px) and (pointer: coarse) {",
|
|
5
|
+
" html { -webkit-text-size-adjust: 100%; }",
|
|
6
|
+
" :root { --vscode-font-size: 14px !important; }",
|
|
7
|
+
" body { font-size: 14px; }",
|
|
8
|
+
" *, *::before, *::after { box-sizing: border-box; }",
|
|
9
|
+
" .filter-group, .be-seg { flex-wrap: wrap; max-width: 100%; }",
|
|
10
|
+
" table:not([data-be-locked-head]) { display: block; max-width: 100%; overflow-x: auto; }",
|
|
11
|
+
" body { overflow-wrap: break-word; }",
|
|
12
|
+
" img, video, canvas { max-width: 100%; }",
|
|
13
|
+
" pre { max-width: 100%; overflow-x: auto; }",
|
|
14
|
+
" :where(textarea, input:not([type=checkbox]):not([type=radio]):not([type=range])) { font-size: 16px; }",
|
|
15
|
+
" :where(button:not([class*=be-]), select:not([class*=be-]), [role=button]:not([class*=be-])) { min-height: 40px; }",
|
|
16
|
+
" :where(label:has(> input[type=checkbox]), label:has(> input[type=radio])) { min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }",
|
|
17
|
+
" html { height: auto !important; overflow-x: hidden !important; overflow-y: auto !important; }",
|
|
18
|
+
" body { height: auto !important; overflow: visible !important; }",
|
|
19
|
+
" #bullseye-workspace select { min-height: 40px; }",
|
|
20
|
+
" #bullseye-workspace-slot #bullseye-workspace select { min-height: 32px; max-width: 25vw !important; }",
|
|
21
|
+
"}"
|
|
22
|
+
].join(" ");
|
|
23
|
+
|
|
24
|
+
var MIN_PHONE_FONT = 12;
|
|
25
|
+
var floorTimer = 0;
|
|
26
|
+
|
|
27
|
+
function floorFonts() {
|
|
28
|
+
floorTimer = 0;
|
|
29
|
+
document.body.querySelectorAll("*").forEach(function (el) {
|
|
30
|
+
if (parseFloat(getComputedStyle(el).fontSize) < MIN_PHONE_FONT) {
|
|
31
|
+
el.style.setProperty("font-size", MIN_PHONE_FONT + "px", "important");
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function scrolledByABox(el) {
|
|
37
|
+
for (var box = el.parentElement; box !== document.body; box = box.parentElement) {
|
|
38
|
+
if (/auto|scroll/.test(getComputedStyle(box).overflowY)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function markLockedHeads() {
|
|
46
|
+
document.body.querySelectorAll("table").forEach(function (table) {
|
|
47
|
+
var head = table.querySelector(":scope > thead");
|
|
48
|
+
var cell = head === null ? null : head.querySelector("th, td");
|
|
49
|
+
var locked = head !== null && (getComputedStyle(head).position === "sticky" || (cell !== null && getComputedStyle(cell).position === "sticky")) && scrolledByABox(table);
|
|
50
|
+
table.toggleAttribute("data-be-locked-head", locked);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function phonePass() {
|
|
55
|
+
floorFonts();
|
|
56
|
+
markLockedHeads();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function floorFontsSoon() {
|
|
60
|
+
if (floorTimer === 0) {
|
|
61
|
+
floorTimer = setTimeout(phonePass, 300);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function baseStyles() {
|
|
66
|
+
if (document.getElementById("__bullseye-base") !== null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var style = document.createElement("style");
|
|
70
|
+
style.id = "__bullseye-base";
|
|
71
|
+
style.textContent = BASE_CSS;
|
|
72
|
+
document.head.insertBefore(style, document.head.firstChild);
|
|
73
|
+
if (window.matchMedia("(max-width: 480px) and (pointer: coarse)").matches) {
|
|
74
|
+
var watch = function () {
|
|
75
|
+
new MutationObserver(floorFontsSoon).observe(document.body, { childList: true, subtree: true });
|
|
76
|
+
floorFontsSoon();
|
|
77
|
+
};
|
|
78
|
+
if (document.readyState === "loading") {
|
|
79
|
+
document.addEventListener("DOMContentLoaded", watch);
|
|
80
|
+
} else {
|
|
81
|
+
watch();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function notice(id, text) {
|
|
87
|
+
if (document.getElementById(id) !== null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
var bar = document.createElement("div");
|
|
91
|
+
bar.id = id;
|
|
92
|
+
bar.style.cssText = "position:fixed;left:0;right:0;bottom:0;z-index:2147483647;display:flex;align-items:center;font:12px system-ui,sans-serif;background:#5a1d1d;color:#fff";
|
|
93
|
+
var line = document.createElement("span");
|
|
94
|
+
line.className = "__bullseye-notice-text";
|
|
95
|
+
line.textContent = text;
|
|
96
|
+
line.style.cssText = "flex:1;min-width:0;padding:4px 10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis";
|
|
97
|
+
line.title = text;
|
|
98
|
+
var close = document.createElement("button");
|
|
99
|
+
close.type = "button";
|
|
100
|
+
close.textContent = "✕";
|
|
101
|
+
close.setAttribute("aria-label", "Dismiss");
|
|
102
|
+
close.style.cssText = "flex:none;width:40px;height:40px;border:0;background:none;color:inherit;font:16px system-ui,sans-serif;cursor:pointer";
|
|
103
|
+
close.addEventListener("click", function () {
|
|
104
|
+
bar.style.display = "none";
|
|
105
|
+
});
|
|
106
|
+
bar.appendChild(line);
|
|
107
|
+
bar.appendChild(close);
|
|
108
|
+
document.body.appendChild(bar);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function refused(text) {
|
|
112
|
+
notice("__bullseye-workspace-refused", text);
|
|
113
|
+
var shown = document.getElementById("__bullseye-workspace-refused");
|
|
114
|
+
if (shown !== null) {
|
|
115
|
+
shown.firstChild.textContent = text;
|
|
116
|
+
shown.firstChild.title = text;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var framedPage = new URLSearchParams(window.location.search).get("bullseye-framed") !== null;
|
|
121
|
+
var workspaceRead = 0;
|
|
122
|
+
var barColours = "background:#252526;color:#ccc";
|
|
123
|
+
var workspaceBarStyle = "display:flex;flex-wrap:nowrap;justify-content:flex-end;gap:8px;align-items:center;box-sizing:border-box;min-height:24px;max-width:100%;overflow:hidden;font:12px system-ui,sans-serif;" + barColours + ";border-bottom:1px solid #454545;padding:2px 8px;pointer-events:auto";
|
|
124
|
+
|
|
125
|
+
function workspaceBox() {
|
|
126
|
+
var box = document.createElement("div");
|
|
127
|
+
box.id = "bullseye-workspace";
|
|
128
|
+
box.style.cssText = workspaceBarStyle;
|
|
129
|
+
return box;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function place(box, slot) {
|
|
133
|
+
var old = document.getElementById(box.id);
|
|
134
|
+
if (old !== null && old !== box) old.remove();
|
|
135
|
+
if (slot === null) {
|
|
136
|
+
document.body.insertBefore(box, document.body.firstChild);
|
|
137
|
+
} else {
|
|
138
|
+
box.style.cssText = "display:flex;align-items:center;gap:6px;max-width:100%;font:inherit;pointer-events:auto";
|
|
139
|
+
slot.appendChild(box);
|
|
140
|
+
}
|
|
141
|
+
pickerPlaced();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pickerSlot() {
|
|
145
|
+
return document.getElementById("__bullseye-workspace-frame") === null ? document.getElementById("bullseye-workspace-slot") : null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function choose(text, label, labels, current, onChange, emptyText) {
|
|
149
|
+
var holder = document.createElement("label");
|
|
150
|
+
holder.style.cssText = "display:flex;align-items:center;gap:4px;min-width:0;white-space:nowrap";
|
|
151
|
+
holder.textContent = text;
|
|
152
|
+
var select = document.createElement("select");
|
|
153
|
+
select.setAttribute("aria-label", label);
|
|
154
|
+
select.style.cssText = "font:inherit;" + barColours + ";color-scheme:dark;border:0;min-width:0;max-width:42vw;text-overflow:ellipsis";
|
|
155
|
+
labels.forEach(function (name) {
|
|
156
|
+
var option = document.createElement("option");
|
|
157
|
+
option.style.cssText = name === current ? "background:#094771;color:#fff;font-weight:600" : barColours;
|
|
158
|
+
option.value = name;
|
|
159
|
+
option.textContent = name === "" ? (emptyText || "—") : name;
|
|
160
|
+
option.selected = name === current;
|
|
161
|
+
select.appendChild(option);
|
|
162
|
+
});
|
|
163
|
+
var generation = 0;
|
|
164
|
+
select.addEventListener("change", function () {
|
|
165
|
+
var choice = ++generation;
|
|
166
|
+
var picked = select.value;
|
|
167
|
+
var latest = function () { return choice === generation; };
|
|
168
|
+
onChange(picked, function () {
|
|
169
|
+
if (latest()) select.value = current;
|
|
170
|
+
}, function () {
|
|
171
|
+
if (!latest()) return false;
|
|
172
|
+
current = picked;
|
|
173
|
+
select.value = current;
|
|
174
|
+
Array.prototype.slice.call(select.children).forEach(function (option) {
|
|
175
|
+
if (option.value === "" && current !== "") option.remove();
|
|
176
|
+
});
|
|
177
|
+
return true;
|
|
178
|
+
}, latest);
|
|
179
|
+
});
|
|
180
|
+
holder.appendChild(select);
|
|
181
|
+
return holder;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function workspacesUrl() {
|
|
185
|
+
return "/__bullseye/workspaces?at=" + encodeURIComponent(window.location.search);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function workspacePicker() {
|
|
189
|
+
if (framedPage) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
var read = ++workspaceRead;
|
|
193
|
+
pickerFetch(workspacesUrl(), { cache: "no-store" }).then(function (response) {
|
|
194
|
+
if (read !== workspaceRead) return null;
|
|
195
|
+
return response.ok ? response.json() : response.text().then(function (text) {
|
|
196
|
+
notice("__bullseye-workspace-unread", "⛔ The workspace picker could not be drawn (" + response.status + ") — " + text);
|
|
197
|
+
return null;
|
|
198
|
+
});
|
|
199
|
+
}).then(function (served) {
|
|
200
|
+
if (read !== workspaceRead || served === null || served.machine === true) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (served.listUnreadable !== undefined) {
|
|
204
|
+
notice("__bullseye-workspace-unread", "⛔ Workspace list: " + served.listUnreadable + " — this page offers only its own workspace until the list is fixed on Bullseye Control");
|
|
205
|
+
}
|
|
206
|
+
var labels = Object.keys(served.workspaces).filter(function (label) {
|
|
207
|
+
return served.workspaces[label][page] !== undefined;
|
|
208
|
+
});
|
|
209
|
+
if (served.current === "" && new URLSearchParams(window.location.search).has("project")) {
|
|
210
|
+
notice("__bullseye-workspace-unknown", "⛔ This address names a workspace that is not served here — pick one of: " + labels.join(", "));
|
|
211
|
+
}
|
|
212
|
+
if (labels.length <= 1) {
|
|
213
|
+
var old = document.getElementById("bullseye-workspace");
|
|
214
|
+
if (old !== null) {
|
|
215
|
+
old.remove();
|
|
216
|
+
pickerPlaced();
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
drawBar(served, labels);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function drawBar(served, labels) {
|
|
225
|
+
var box = workspaceBox();
|
|
226
|
+
box.appendChild(choose("📍 ", "Workspace", served.current === "" ? [""].concat(labels) : labels, served.current, function (picked, undo, commit, latest) {
|
|
227
|
+
if (picked === "") {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
pickerSave(served, picked).then(function (answer) {
|
|
231
|
+
if (!latest()) return;
|
|
232
|
+
if (!answer.ok) {
|
|
233
|
+
refused("⛔ That workspace could not be picked (" + answer.status + ") — this page stays where it is");
|
|
234
|
+
undo();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!commit()) return;
|
|
238
|
+
served.current = picked;
|
|
239
|
+
pickerNavigate(served.workspaces[picked][page]);
|
|
240
|
+
}, function () {
|
|
241
|
+
if (!latest()) return;
|
|
242
|
+
refused("⛔ That workspace could not be picked — this page stays where it is");
|
|
243
|
+
undo();
|
|
244
|
+
});
|
|
245
|
+
}, "no workspace named"));
|
|
246
|
+
place(box, pickerSlot());
|
|
247
|
+
}
|
|
248
|
+
`;
|
|
249
|
+
const CONNECTION_SOURCE = String.raw `(function () {
|
|
250
|
+
"use strict";
|
|
251
|
+
if (window.bullseyeConnection !== undefined) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
var BAR = "__bullseye-connection";
|
|
255
|
+
var MARKS = { reconnecting: "🔄 RECONNECTING", live: "✅ LIVE" };
|
|
256
|
+
var COLOURS = { reconnecting: "#7a5200", live: "#1d5a2c" };
|
|
257
|
+
var current = null;
|
|
258
|
+
var ticker = 0;
|
|
259
|
+
var clearer = 0;
|
|
260
|
+
var pending = 0;
|
|
261
|
+
// GATE: a drop that comes back within this shows nothing at all; only a connection still down after it shows the RECONNECTING bar
|
|
262
|
+
var GRACE_MS = 1500;
|
|
263
|
+
|
|
264
|
+
function clock(at) {
|
|
265
|
+
return new Date(at).toLocaleTimeString([], { hour12: false });
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function reading() {
|
|
269
|
+
var now = Date.now();
|
|
270
|
+
var lines = ["What dropped: " + current.what, "Since: " + clock(current.since) + " (" + Math.round((now - current.since) / 1000) + " s ago)"];
|
|
271
|
+
if (current.state === "reconnecting" && current.retryAt !== undefined) {
|
|
272
|
+
lines.push("Next retry: " + (current.retryAt > now ? "in " + Math.ceil((current.retryAt - now) / 1000) + " s" : "now"));
|
|
273
|
+
} else if (current.state === "live") {
|
|
274
|
+
lines.push("Live again after " + Math.round((now - current.since) / 1000) + " s");
|
|
275
|
+
}
|
|
276
|
+
return lines.join("\n");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function placeBar(el) {
|
|
280
|
+
var app = document.querySelector("vaadin-app-layout");
|
|
281
|
+
var nav = app && app.shadowRoot && app.shadowRoot.querySelector("[part=navbar]:not([bottom])");
|
|
282
|
+
if (nav && getComputedStyle(nav).position === "fixed") {
|
|
283
|
+
el.setAttribute("slot", "navbar");
|
|
284
|
+
el.style.position = "static";
|
|
285
|
+
el.style.flex = "0 0 100%";
|
|
286
|
+
if (el.parentNode !== app) app.appendChild(el);
|
|
287
|
+
} else {
|
|
288
|
+
el.removeAttribute("slot");
|
|
289
|
+
el.style.position = window.__bullseyeReconnectInstalled ? "fixed" : "sticky";
|
|
290
|
+
if (el.parentNode !== document.body || document.body.firstChild !== el) document.body.insertBefore(el, document.body.firstChild);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function bar() {
|
|
295
|
+
var found = document.getElementById(BAR);
|
|
296
|
+
if (found !== null) {
|
|
297
|
+
placeBar(found);
|
|
298
|
+
return found;
|
|
299
|
+
}
|
|
300
|
+
found = document.createElement("div");
|
|
301
|
+
found.id = BAR;
|
|
302
|
+
found.setAttribute("role", "status");
|
|
303
|
+
found.setAttribute("aria-live", "polite");
|
|
304
|
+
found.setAttribute("data-be-notice", "own");
|
|
305
|
+
found.style.cssText = "position:sticky;top:0;z-index:1;flex:none;box-sizing:border-box;width:100%;min-height:20px;padding:1px 8px;display:flex;align-items:center;justify-content:center";
|
|
306
|
+
var word = document.createElement("span");
|
|
307
|
+
word.className = "__bullseye-notice-text";
|
|
308
|
+
word.style.cssText = "font:700 12px/18px system-ui,sans-serif;color:#fff;cursor:help";
|
|
309
|
+
found.appendChild(word);
|
|
310
|
+
placeBar(found);
|
|
311
|
+
return found;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function paint() {
|
|
315
|
+
var shown = bar();
|
|
316
|
+
var word = shown.firstChild;
|
|
317
|
+
shown.style.background = COLOURS[current.state];
|
|
318
|
+
var mark = MARKS[current.state];
|
|
319
|
+
if (word.textContent !== mark) {
|
|
320
|
+
word.textContent = mark;
|
|
321
|
+
}
|
|
322
|
+
var tip = reading();
|
|
323
|
+
if (word.getAttribute("data-be-tip") !== tip) {
|
|
324
|
+
word.setAttribute("data-be-tip", tip);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function release() {
|
|
329
|
+
var shown = document.getElementById(BAR);
|
|
330
|
+
if (shown !== null) {
|
|
331
|
+
shown.remove();
|
|
332
|
+
}
|
|
333
|
+
current = null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function show(state, what, extra) {
|
|
337
|
+
window.clearTimeout(clearer);
|
|
338
|
+
var dropped = current !== null && current.state !== "live";
|
|
339
|
+
current = { state: state, what: what || (current && current.what) || "the live connection to this page's service", since: dropped ? current.since : Date.now(), retryAt: extra.retryAt, why: extra.why };
|
|
340
|
+
record("indicator", "shown", null, { state: state });
|
|
341
|
+
paint();
|
|
342
|
+
window.clearInterval(ticker);
|
|
343
|
+
ticker = window.setInterval(paint, 1000);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// GATE: a socket that drops sooner than this after opening counts as a failed attempt, so each retry waits twice as long and LIVE shows only once a socket has stayed up this long
|
|
347
|
+
var SETTLED_MS = 3000;
|
|
348
|
+
// GATE: sign-in HTTP requests use this limit times failed attempts (capped at 30000); a CONNECTING socket has no application deadline.
|
|
349
|
+
var CONNECT_MS = 5000;
|
|
350
|
+
// GATE: the page pings this often while visible, and asks its service at most this long; a socket a tunnel or a suspended phone tab cut sends no close, and one whose ping goes unanswered while its service answers is reopened in place
|
|
351
|
+
var BEAT_MS = 20000;
|
|
352
|
+
// GATE: a late ping starts a daemon health read; after it answers, a fresh ping gets a full beat. Any delivered frame cancels the verdict.
|
|
353
|
+
var PING_ANSWER_MS = 2500;
|
|
354
|
+
var drops = 0;
|
|
355
|
+
var openedAt = 0;
|
|
356
|
+
var watched = [];
|
|
357
|
+
var polled = [];
|
|
358
|
+
var counts = {};
|
|
359
|
+
var style = document.createElement("style");
|
|
360
|
+
style.textContent = "vaadin-connection-indicator{display:none!important}" +
|
|
361
|
+
"body.bullseye-conn-lost:has(> #" + BAR + "){padding-top:20px;box-sizing:border-box;--bullseye-conn-bar-h:20px}" +
|
|
362
|
+
"vaadin-app-layout:has(> #" + BAR + ")::part(navbar){flex-wrap:wrap}";
|
|
363
|
+
document.head.appendChild(style);
|
|
364
|
+
function record(trigger, outcome, socket, extra) {
|
|
365
|
+
var key = trigger + ":" + outcome;
|
|
366
|
+
counts[key] = (counts[key] || 0) + 1;
|
|
367
|
+
var event = Object.assign({ at: Date.now(), trigger: trigger, outcome: outcome,
|
|
368
|
+
readyState: socket === null ? null : socket.readyState }, extra);
|
|
369
|
+
window.dispatchEvent(new CustomEvent("bullseye-connection", { detail: event }));
|
|
370
|
+
if (outcome === "drop" || outcome === "shown" || outcome === "recovered") {
|
|
371
|
+
console.info("[Bullseye connection] " + JSON.stringify(event));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function serviceAnswers(path) {
|
|
376
|
+
return window.fetch(path, { cache: "no-store", signal: AbortSignal.timeout(BEAT_MS) }).then(function (response) {
|
|
377
|
+
if (response.status >= 502) {
|
|
378
|
+
throw new Error("HTTP " + response.status);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function clearCheck(one, check) {
|
|
384
|
+
if (one.checking === check) one.checking = null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function look(trigger) {
|
|
388
|
+
polled.forEach(function (read) { read(); });
|
|
389
|
+
watched.forEach(function (one) {
|
|
390
|
+
var socket = one.socketNow();
|
|
391
|
+
record(trigger, "observed", socket);
|
|
392
|
+
if (socket === null || socket.readyState !== 1 || one.checking !== null) return;
|
|
393
|
+
var check = { socket: socket, heard: one.heard };
|
|
394
|
+
one.checking = check;
|
|
395
|
+
one.ping(socket);
|
|
396
|
+
window.setTimeout(function () {
|
|
397
|
+
if (one.socketNow() !== socket || one.heard !== check.heard) {
|
|
398
|
+
clearCheck(one, check);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
serviceAnswers(one.path).then(function () {
|
|
402
|
+
if (one.socketNow() !== socket || one.heard !== check.heard) {
|
|
403
|
+
clearCheck(one, check);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
// Only a fresh, unanswered ping AFTER the daemon answered can prove a stale transport.
|
|
407
|
+
// Data, a hidden tab, or a suspended browser cancels this verdict. HTTP failure never closes it.
|
|
408
|
+
var asked = Date.now();
|
|
409
|
+
one.ping(socket);
|
|
410
|
+
window.setTimeout(function () {
|
|
411
|
+
clearCheck(one, check);
|
|
412
|
+
if (one.socketNow() !== socket || socket.readyState !== 1) return;
|
|
413
|
+
if (one.heard !== check.heard || document.visibilityState !== "visible" || Date.now() - asked > BEAT_MS * 2) {
|
|
414
|
+
record("ping-timeout", "suppressed", socket, { delivering: one.heard !== check.heard });
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
one.dead(socket, "ping-timeout");
|
|
418
|
+
}, BEAT_MS);
|
|
419
|
+
}, function () {
|
|
420
|
+
clearCheck(one, check);
|
|
421
|
+
record("daemon-unresponsive", "suppressed", socket);
|
|
422
|
+
});
|
|
423
|
+
}, PING_ANSWER_MS);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
window.setInterval(function () {
|
|
428
|
+
if (document.visibilityState === "visible") look("heartbeat");
|
|
429
|
+
}, BEAT_MS);
|
|
430
|
+
document.addEventListener("visibilitychange", function () {
|
|
431
|
+
if (document.visibilityState === "visible") look("visibility");
|
|
432
|
+
});
|
|
433
|
+
window.addEventListener("pageshow", function (event) {
|
|
434
|
+
if (event.persisted) look("pageshow");
|
|
435
|
+
});
|
|
436
|
+
window.addEventListener("online", function () { look("online"); });
|
|
437
|
+
|
|
438
|
+
window.bullseyeConnection = {
|
|
439
|
+
limit: function () {
|
|
440
|
+
return Math.min(CONNECT_MS * (drops + 1), 30000);
|
|
441
|
+
},
|
|
442
|
+
answers: serviceAnswers,
|
|
443
|
+
counts: counts,
|
|
444
|
+
record: record,
|
|
445
|
+
watch: function (socketNow, ping, dead, path) {
|
|
446
|
+
var one = { socketNow: socketNow, ping: ping, dead: dead, path: path, heard: 0, checking: null };
|
|
447
|
+
watched.push(one);
|
|
448
|
+
function heard() {
|
|
449
|
+
one.heard += 1;
|
|
450
|
+
}
|
|
451
|
+
heard.stop = function () {
|
|
452
|
+
watched = watched.filter(function (other) {
|
|
453
|
+
return other !== one;
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
return heard;
|
|
457
|
+
},
|
|
458
|
+
// HTTP-only apps use this adapter; a slow read has no application deadline and never flags a healthy link.
|
|
459
|
+
followHttp: function (spec) {
|
|
460
|
+
var asking = false;
|
|
461
|
+
var down = false;
|
|
462
|
+
function failed(what) {
|
|
463
|
+
if (!down) {
|
|
464
|
+
down = true;
|
|
465
|
+
record("http-error", "drop", null);
|
|
466
|
+
spec.down();
|
|
467
|
+
}
|
|
468
|
+
window.bullseyeConnection.reconnecting(what, spec.every);
|
|
469
|
+
}
|
|
470
|
+
function read() {
|
|
471
|
+
if (asking || document.hidden || !spec.active()) return;
|
|
472
|
+
asking = true;
|
|
473
|
+
Promise.resolve().then(spec.read).then(function (response) {
|
|
474
|
+
spec.response(response);
|
|
475
|
+
if (response.status >= 500) {
|
|
476
|
+
failed(spec.what);
|
|
477
|
+
} else if (down) {
|
|
478
|
+
down = false;
|
|
479
|
+
window.bullseyeConnection.live();
|
|
480
|
+
spec.recovered();
|
|
481
|
+
}
|
|
482
|
+
}, function () {
|
|
483
|
+
failed(spec.what);
|
|
484
|
+
}).finally(function () { asking = false; });
|
|
485
|
+
}
|
|
486
|
+
polled.push(read);
|
|
487
|
+
window.setInterval(read, spec.every);
|
|
488
|
+
return { read: read, failed: failed };
|
|
489
|
+
},
|
|
490
|
+
keep: function (spec) {
|
|
491
|
+
var socket = null;
|
|
492
|
+
var stopped = false;
|
|
493
|
+
var everOpened = false;
|
|
494
|
+
var retry = 0;
|
|
495
|
+
var heard = window.bullseyeConnection.watch(function () {
|
|
496
|
+
return socket;
|
|
497
|
+
}, spec.ping, function (dead, trigger) {
|
|
498
|
+
abandon(dead, window.bullseyeConnection.closed(everOpened), trigger);
|
|
499
|
+
}, spec.path);
|
|
500
|
+
function again(wait) {
|
|
501
|
+
if (stopped) return;
|
|
502
|
+
window.clearTimeout(retry);
|
|
503
|
+
spec.down();
|
|
504
|
+
window.bullseyeConnection.reconnecting(spec.what, wait);
|
|
505
|
+
retry = window.setTimeout(function () {
|
|
506
|
+
if (!stopped) {
|
|
507
|
+
spec.attach(connect, later, everOpened);
|
|
508
|
+
}
|
|
509
|
+
}, wait);
|
|
510
|
+
}
|
|
511
|
+
function later() {
|
|
512
|
+
again(window.bullseyeConnection.failed());
|
|
513
|
+
}
|
|
514
|
+
function abandon(ws, wait, trigger) {
|
|
515
|
+
if (socket !== ws) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
record(trigger, "drop", ws);
|
|
519
|
+
ws.onopen = ws.onmessage = ws.onclose = ws.onerror = null;
|
|
520
|
+
socket = null;
|
|
521
|
+
ws.close();
|
|
522
|
+
again(wait);
|
|
523
|
+
}
|
|
524
|
+
function connect() {
|
|
525
|
+
if (stopped || socket !== null) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
window.clearTimeout(retry);
|
|
529
|
+
var ws = spec.open();
|
|
530
|
+
var reopened = everOpened;
|
|
531
|
+
var opened = false;
|
|
532
|
+
socket = ws;
|
|
533
|
+
ws.onopen = function () {
|
|
534
|
+
record("socket-open", "recovered", ws);
|
|
535
|
+
opened = true;
|
|
536
|
+
everOpened = true;
|
|
537
|
+
heard();
|
|
538
|
+
spec.opened(ws, reopened);
|
|
539
|
+
window.bullseyeConnection.opened(function () {
|
|
540
|
+
return socket === ws && ws.readyState === 1;
|
|
541
|
+
}, window.bullseyeConnection.live);
|
|
542
|
+
};
|
|
543
|
+
ws.onmessage = function (event) {
|
|
544
|
+
if (socket !== ws) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
heard();
|
|
548
|
+
spec.message(ws, event);
|
|
549
|
+
};
|
|
550
|
+
ws.onerror = function () {
|
|
551
|
+
if (socket === ws) {
|
|
552
|
+
record("socket-error", "drop", ws);
|
|
553
|
+
spec.down();
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
ws.onclose = function (event) {
|
|
557
|
+
if (socket !== ws) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
record("socket-close", "drop", ws, { code: event.code, reason: event.reason });
|
|
561
|
+
socket = null;
|
|
562
|
+
if (spec.closed(event)) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
again(opened ? window.bullseyeConnection.closed(reopened) : window.bullseyeConnection.failed());
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
connect: connect,
|
|
570
|
+
later: later,
|
|
571
|
+
socket: function () {
|
|
572
|
+
return socket;
|
|
573
|
+
},
|
|
574
|
+
stop: function () {
|
|
575
|
+
stopped = true;
|
|
576
|
+
heard.stop();
|
|
577
|
+
window.clearTimeout(retry);
|
|
578
|
+
if (socket !== null) {
|
|
579
|
+
var ws = socket;
|
|
580
|
+
socket = null;
|
|
581
|
+
ws.onopen = ws.onmessage = ws.onclose = ws.onerror = null;
|
|
582
|
+
ws.close();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
},
|
|
587
|
+
forget: function () {
|
|
588
|
+
drops = 0;
|
|
589
|
+
},
|
|
590
|
+
failed: function () {
|
|
591
|
+
drops += 1;
|
|
592
|
+
return Math.min(250 * Math.pow(2, drops - 1), 30000);
|
|
593
|
+
},
|
|
594
|
+
opened: function (stillOpen, settle) {
|
|
595
|
+
openedAt = Date.now();
|
|
596
|
+
window.clearTimeout(pending);
|
|
597
|
+
pending = 0;
|
|
598
|
+
if (drops === 0) {
|
|
599
|
+
settle();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
window.setTimeout(function () {
|
|
603
|
+
if (stillOpen()) {
|
|
604
|
+
drops = 0;
|
|
605
|
+
settle();
|
|
606
|
+
}
|
|
607
|
+
}, SETTLED_MS);
|
|
608
|
+
},
|
|
609
|
+
closed: function (reopened) {
|
|
610
|
+
drops = reopened && Date.now() - openedAt < SETTLED_MS ? drops + 1 : 0;
|
|
611
|
+
return Math.min(250 * Math.pow(2, drops), 30000);
|
|
612
|
+
},
|
|
613
|
+
reconnecting: function (what, retryInMs) {
|
|
614
|
+
var retryAt = Date.now() + retryInMs;
|
|
615
|
+
if (current !== null) {
|
|
616
|
+
show("reconnecting", what, { retryAt: retryAt });
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
if (pending !== 0) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
pending = window.setTimeout(function () {
|
|
623
|
+
pending = 0;
|
|
624
|
+
show("reconnecting", what, { retryAt: retryAt });
|
|
625
|
+
}, GRACE_MS);
|
|
626
|
+
},
|
|
627
|
+
signInAgain: function () {
|
|
628
|
+
window.sessionStorage.setItem("bullseye-return-to", window.location.pathname + window.location.search + window.location.hash);
|
|
629
|
+
window.location.assign("/");
|
|
630
|
+
},
|
|
631
|
+
live: function () {
|
|
632
|
+
window.clearTimeout(pending);
|
|
633
|
+
pending = 0;
|
|
634
|
+
if (current === null || current.state === "live") {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
show("live", current.what, {});
|
|
638
|
+
window.clearInterval(ticker);
|
|
639
|
+
clearer = window.setTimeout(release, 300);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
})();`;
|
|
643
|
+
const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
644
|
+
"use strict";
|
|
645
|
+
var script = document.currentScript;
|
|
646
|
+
var page = script.getAttribute("data-page");
|
|
647
|
+
var pickerFetch = window.fetch.bind(window);
|
|
648
|
+
var pickerNavigate = window.location.assign.bind(window.location);
|
|
649
|
+
var pickerPlaced = function () {};
|
|
650
|
+
var pickerSave = function (served, picked) {
|
|
651
|
+
return Promise.resolve({ ok: true });
|
|
652
|
+
};
|
|
653
|
+
var stateKey = "bullseye-webhost:" + page;
|
|
654
|
+
var drawn = script.getAttribute("data-drawn");
|
|
655
|
+
var sender = Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
656
|
+
var numbered = 0;
|
|
657
|
+
var unacked = [];
|
|
658
|
+
var acquired = false;
|
|
659
|
+
var state = readState();
|
|
660
|
+
window.bullseyeWebUi = true;
|
|
661
|
+
|
|
662
|
+
function readState() {
|
|
663
|
+
var raw = window.localStorage.getItem(stateKey);
|
|
664
|
+
return raw === null ? undefined : JSON.parse(raw);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function frameOf(message) {
|
|
668
|
+
numbered += 1;
|
|
669
|
+
var hello = typeof window.bullseyeHello === "function" && JSON.stringify(message) === JSON.stringify(window.bullseyeHello());
|
|
670
|
+
return { id: numbered, hello: hello, text: JSON.stringify({ type: "message", message: message, hello: hello, sender: sender, id: numbered }) };
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function send(message) {
|
|
674
|
+
var frame = frameOf(message);
|
|
675
|
+
unacked.push(frame);
|
|
676
|
+
var socket = kept.socket();
|
|
677
|
+
if (socket !== null && socket.readyState === 1) {
|
|
678
|
+
socket.send(frame.text);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function acked(id) {
|
|
683
|
+
unacked = unacked.filter(function (frame) {
|
|
684
|
+
return frame.id > id;
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function deliver(message) {
|
|
689
|
+
window.dispatchEvent(new MessageEvent("message", { data: message, origin: window.location.origin }));
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
` + PICKER_SOURCE + String.raw `
|
|
693
|
+
var WHAT = "this page's live connection to its service";
|
|
694
|
+
// GATE: one health read is abandoned after this times the square of the tries so far (capped at 8000), then asked again
|
|
695
|
+
var ANSWER_MS = 700;
|
|
696
|
+
var healthTries = 0;
|
|
697
|
+
|
|
698
|
+
function unreached(err, connect, later) {
|
|
699
|
+
if (err.name === "AbortError") {
|
|
700
|
+
awaitHost(connect, later);
|
|
701
|
+
} else if (err instanceof TypeError) {
|
|
702
|
+
window.setTimeout(function () {
|
|
703
|
+
awaitHost(connect, later);
|
|
704
|
+
}, 250);
|
|
705
|
+
} else {
|
|
706
|
+
later();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function reconnectOrReload(health, connect, later) {
|
|
711
|
+
if (health.pages === undefined) {
|
|
712
|
+
later();
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
var served = health.pages[page];
|
|
716
|
+
if (served === undefined || served.live !== true || served.drawn !== drawn || typeof window.bullseyeHello !== "function") {
|
|
717
|
+
window.bullseyeConnection.record("daemon-or-page-replaced", "drop", null);
|
|
718
|
+
window.location.reload();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
connect();
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function awaitHost(connect, later) {
|
|
725
|
+
window.bullseyeConnection.reconnecting(WHAT, 250);
|
|
726
|
+
var asking = new AbortController();
|
|
727
|
+
healthTries += 1;
|
|
728
|
+
var abandon = window.setTimeout(function () {
|
|
729
|
+
asking.abort();
|
|
730
|
+
}, Math.min(ANSWER_MS * healthTries * healthTries, 8000));
|
|
731
|
+
var missed = function (err) {
|
|
732
|
+
unreached(err, connect, later);
|
|
733
|
+
};
|
|
734
|
+
window.fetch("/__bullseye/health", { cache: "no-store", signal: asking.signal }).then(function (response) {
|
|
735
|
+
if (response.ok) {
|
|
736
|
+
response.json().then(function (health) {
|
|
737
|
+
window.clearTimeout(abandon);
|
|
738
|
+
healthTries = 0;
|
|
739
|
+
reconnectOrReload(health, connect, later);
|
|
740
|
+
}, missed);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
window.clearTimeout(abandon);
|
|
744
|
+
healthTries = 0;
|
|
745
|
+
if (response.status === 401) {
|
|
746
|
+
window.bullseyeConnection.signInAgain();
|
|
747
|
+
} else {
|
|
748
|
+
window.setTimeout(function () {
|
|
749
|
+
awaitHost(connect, later);
|
|
750
|
+
}, 250);
|
|
751
|
+
}
|
|
752
|
+
}, missed);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function openUnlessSignedOut(connect, later) {
|
|
756
|
+
window.fetch("/__bullseye/health", { cache: "no-store", signal: AbortSignal.timeout(window.bullseyeConnection.limit()) }).then(function (response) {
|
|
757
|
+
if (response.status === 401) {
|
|
758
|
+
window.bullseyeConnection.signInAgain();
|
|
759
|
+
} else {
|
|
760
|
+
connect();
|
|
761
|
+
}
|
|
762
|
+
}, later);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function handle(text) {
|
|
766
|
+
var frame = JSON.parse(text);
|
|
767
|
+
if (frame.type === "post") {
|
|
768
|
+
deliver(frame.message);
|
|
769
|
+
} else if (frame.type === "ack") {
|
|
770
|
+
acked(frame.id);
|
|
771
|
+
} else if (frame.type === "reload") {
|
|
772
|
+
window.location.reload();
|
|
773
|
+
} else if (frame.type === "failed") {
|
|
774
|
+
notice("__bullseye-page-failed", "");
|
|
775
|
+
document.getElementById("__bullseye-page-failed").textContent = "⚠️ This page could not be read — " + frame.why;
|
|
776
|
+
} else if (frame.type === "recovered") {
|
|
777
|
+
var failedBar = document.getElementById("__bullseye-page-failed");
|
|
778
|
+
if (failedBar !== null) {
|
|
779
|
+
failedBar.remove();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
var kept = window.bullseyeConnection.keep({
|
|
785
|
+
what: WHAT,
|
|
786
|
+
path: "/__bullseye/health",
|
|
787
|
+
open: function () {
|
|
788
|
+
var scheme = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
789
|
+
var mine = new WebSocket(scheme + "//" + window.location.host + "/__bullseye/ws?page=" + encodeURIComponent(page) + "&at=" + encodeURIComponent(window.location.search) + "&drawn=" + encodeURIComponent(drawn));
|
|
790
|
+
mine.binaryType = "blob";
|
|
791
|
+
mine.unpacking = Promise.resolve();
|
|
792
|
+
mine.unpackingCount = 0;
|
|
793
|
+
return mine;
|
|
794
|
+
},
|
|
795
|
+
attach: function (connect, later, everOpened) {
|
|
796
|
+
if (everOpened) {
|
|
797
|
+
awaitHost(connect, later);
|
|
798
|
+
} else {
|
|
799
|
+
openUnlessSignedOut(connect, later);
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
opened: function (mine, reopened) {
|
|
803
|
+
if (typeof DecompressionStream === "function") {
|
|
804
|
+
mine.send(JSON.stringify({ type: "packed" }));
|
|
805
|
+
}
|
|
806
|
+
if (reopened) {
|
|
807
|
+
unacked = unacked.filter(function (frame) {
|
|
808
|
+
return !frame.hello;
|
|
809
|
+
});
|
|
810
|
+
unacked.push(frameOf(window.bullseyeHello()));
|
|
811
|
+
}
|
|
812
|
+
unacked.forEach(function (frame) {
|
|
813
|
+
mine.send(frame.text);
|
|
814
|
+
});
|
|
815
|
+
},
|
|
816
|
+
message: function (mine, event) {
|
|
817
|
+
if (typeof event.data === "string" && mine.unpackingCount === 0) {
|
|
818
|
+
handle(event.data);
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
mine.unpackingCount += 1;
|
|
822
|
+
var text = typeof event.data === "string" ? Promise.resolve(event.data) : new Response(event.data.stream().pipeThrough(new DecompressionStream("gzip"))).text();
|
|
823
|
+
mine.unpacking = mine.unpacking.then(function () {
|
|
824
|
+
return text;
|
|
825
|
+
}).then(function (unpacked) {
|
|
826
|
+
mine.unpackingCount -= 1;
|
|
827
|
+
queueMicrotask(function () {
|
|
828
|
+
handle(unpacked);
|
|
829
|
+
});
|
|
830
|
+
}, function (err) {
|
|
831
|
+
mine.unpackingCount -= 1;
|
|
832
|
+
notice("__bullseye-page-failed", "");
|
|
833
|
+
document.getElementById("__bullseye-page-failed").textContent = "⚠️ A frame from the host could not be unpacked — " + err.message;
|
|
834
|
+
});
|
|
835
|
+
},
|
|
836
|
+
down: function () {},
|
|
837
|
+
closed: function () {
|
|
838
|
+
return false;
|
|
839
|
+
},
|
|
840
|
+
ping: function (alive) {
|
|
841
|
+
alive.send('{"type":"ping"}');
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
window.acquireVsCodeApi = function () {
|
|
846
|
+
if (acquired) {
|
|
847
|
+
throw new Error("An instance of the VS Code API has already been acquired");
|
|
848
|
+
}
|
|
849
|
+
acquired = true;
|
|
850
|
+
return Object.freeze({
|
|
851
|
+
postMessage: send,
|
|
852
|
+
setState: function (next) {
|
|
853
|
+
state = next;
|
|
854
|
+
window.localStorage.setItem(stateKey, JSON.stringify(next));
|
|
855
|
+
return next;
|
|
856
|
+
},
|
|
857
|
+
getState: function () {
|
|
858
|
+
return state;
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
function start() {
|
|
864
|
+
baseStyles();
|
|
865
|
+
kept.connect();
|
|
866
|
+
workspacePicker();
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (document.readyState === "loading") {
|
|
870
|
+
document.addEventListener("DOMContentLoaded", start);
|
|
871
|
+
} else {
|
|
872
|
+
start();
|
|
873
|
+
}
|
|
874
|
+
})();`;
|
|
875
|
+
const PICKER_PAGE_SOURCE = String.raw `(function () {
|
|
876
|
+
"use strict";
|
|
877
|
+
var page = document.currentScript.getAttribute("data-page");
|
|
878
|
+
var pickerFetch = window.fetch.bind(window);
|
|
879
|
+
var pickerNavigate = window.location.assign.bind(window.location);
|
|
880
|
+
var pickerPlaced = function () {};
|
|
881
|
+
var pickerSave = function (served, picked) {
|
|
882
|
+
return Promise.resolve({ ok: true });
|
|
883
|
+
};
|
|
884
|
+
` + PICKER_SOURCE + String.raw `
|
|
885
|
+
baseStyles();
|
|
886
|
+
if (document.readyState === "loading") {
|
|
887
|
+
document.addEventListener("DOMContentLoaded", workspacePicker);
|
|
888
|
+
} else {
|
|
889
|
+
workspacePicker();
|
|
890
|
+
}
|
|
891
|
+
})();`;
|
|
892
|
+
const NATIVE_PICKER_SOURCE = String.raw `(function () {
|
|
893
|
+
"use strict";
|
|
894
|
+
var page = document.currentScript.getAttribute("data-page");
|
|
895
|
+
var api;
|
|
896
|
+
var acquire = window.acquireVsCodeApi;
|
|
897
|
+
var waiting = new Map();
|
|
898
|
+
var next = 0;
|
|
899
|
+
var pickedFrame = "";
|
|
900
|
+
var FRAME_ID = "__bullseye-workspace-frame";
|
|
901
|
+
var HIDE_ID = "__bullseye-cover-hides-page";
|
|
902
|
+
var watched = null;
|
|
903
|
+
var workspaceSize = null;
|
|
904
|
+
var pickerNavigate = function () {
|
|
905
|
+
cover(pickedFrame);
|
|
906
|
+
};
|
|
907
|
+
var pickerPlaced = function () {
|
|
908
|
+
var bar = document.getElementById("bullseye-workspace");
|
|
909
|
+
if (typeof ResizeObserver === "function" && watched !== bar) {
|
|
910
|
+
if (workspaceSize !== null) workspaceSize.disconnect();
|
|
911
|
+
watched = bar;
|
|
912
|
+
workspaceSize = bar === null ? null : new ResizeObserver(fit);
|
|
913
|
+
if (workspaceSize !== null) workspaceSize.observe(bar);
|
|
914
|
+
}
|
|
915
|
+
fit();
|
|
916
|
+
};
|
|
917
|
+
var pickerFetch = function (url, init) {
|
|
918
|
+
var id = ++next;
|
|
919
|
+
var pick = init && init.method === "POST" ? JSON.parse(init.body).label : undefined;
|
|
920
|
+
return new Promise(function (resolve) {
|
|
921
|
+
waiting.set(id, { resolve: resolve, pick: pick });
|
|
922
|
+
api.postMessage({ type: "__bullseyeWorkspace", id: id, pick: pick });
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
function fit() {
|
|
927
|
+
var frame = document.getElementById(FRAME_ID);
|
|
928
|
+
if (frame === null) return;
|
|
929
|
+
var bar = document.getElementById("bullseye-workspace");
|
|
930
|
+
var top = bar === null ? 0 : Math.max(0, Math.floor(bar.getBoundingClientRect().bottom));
|
|
931
|
+
frame.style.cssText = "position:fixed;left:0;right:0;bottom:0;top:" + top + "px;width:100%;height:calc(100% - " + top + "px);border:0;margin:0;z-index:2147483646;background:#1e1e1e";
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function cover(url) {
|
|
935
|
+
var frame = document.getElementById(FRAME_ID);
|
|
936
|
+
var bar = document.getElementById("bullseye-workspace");
|
|
937
|
+
if (url === "") {
|
|
938
|
+
if (frame !== null) {
|
|
939
|
+
frame.remove();
|
|
940
|
+
document.documentElement.style.overflow = "";
|
|
941
|
+
if (bar !== null) place(bar, pickerSlot());
|
|
942
|
+
}
|
|
943
|
+
var hide = document.getElementById(HIDE_ID);
|
|
944
|
+
if (hide !== null) hide.remove();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
var src = url + (url.indexOf("?") < 0 ? "?" : "&") + "bullseye-framed=1";
|
|
948
|
+
if (frame === null) {
|
|
949
|
+
if (bar !== null) {
|
|
950
|
+
bar.style.cssText = workspaceBarStyle;
|
|
951
|
+
place(bar, null);
|
|
952
|
+
}
|
|
953
|
+
frame = document.createElement("iframe");
|
|
954
|
+
frame.id = FRAME_ID;
|
|
955
|
+
frame.setAttribute("title", "The picked workspace, drawn by its service");
|
|
956
|
+
document.body.appendChild(frame);
|
|
957
|
+
}
|
|
958
|
+
if (frame.getAttribute("src") !== src) frame.setAttribute("src", src);
|
|
959
|
+
document.documentElement.style.overflow = "hidden";
|
|
960
|
+
if (document.getElementById(HIDE_ID) === null) {
|
|
961
|
+
var hide = document.createElement("style");
|
|
962
|
+
hide.id = HIDE_ID;
|
|
963
|
+
hide.textContent = "body > :not(#bullseye-workspace):not([id^='__bullseye-']):not(.be-tip):not(script):not(style) { visibility: hidden !important; }";
|
|
964
|
+
document.head.appendChild(hide);
|
|
965
|
+
}
|
|
966
|
+
window.scrollTo(0, 0);
|
|
967
|
+
fit();
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
window.addEventListener("resize", fit);
|
|
971
|
+
var pickerSave = function (served, picked) {
|
|
972
|
+
return pickerFetch("/__bullseye/workspaces", { method: "POST", body: JSON.stringify({ label: picked }) });
|
|
973
|
+
};
|
|
974
|
+
window.addEventListener("message", function (event) {
|
|
975
|
+
var reply = event.data;
|
|
976
|
+
if (reply?.type === "__bullseyeWorkspaceRefresh" && api !== undefined) {
|
|
977
|
+
workspacePicker();
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (reply?.type !== "__bullseyeWorkspace" || !waiting.has(reply.id)) return;
|
|
981
|
+
var asked = waiting.get(reply.id);
|
|
982
|
+
waiting.delete(reply.id);
|
|
983
|
+
if (reply.status === 200 && asked.pick === undefined) cover(reply.body.frame);
|
|
984
|
+
if (reply.status === 200 && asked.pick !== undefined) pickedFrame = reply.body.frame;
|
|
985
|
+
asked.resolve({ ok: reply.status === 200, status: reply.status, json: function () { return Promise.resolve(reply.body); }, text: function () { return Promise.resolve(String(reply.body)); } });
|
|
986
|
+
});
|
|
987
|
+
` + PICKER_SOURCE + String.raw `
|
|
988
|
+
window.acquireVsCodeApi = function () {
|
|
989
|
+
api = acquire();
|
|
990
|
+
baseStyles();
|
|
991
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", workspacePicker);
|
|
992
|
+
else workspacePicker();
|
|
993
|
+
return api;
|
|
994
|
+
};
|
|
995
|
+
})();`;
|
|
996
|
+
module.exports = { CONNECTION_SOURCE, SHIM_SOURCE, PICKER_PAGE_SOURCE, NATIVE_PICKER_SOURCE };
|
package/dist/gatewaySettings.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* #4247 — the leaf every BullseyeNotif door shares with notify:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* #4247 — the leaf every BullseyeNotif door shares with notify: the installed build's version and homepage and the atomic
|
|
3
|
+
* record write. Where the config lives, the gateway's token settings and the refusal type every door answers with belong
|
|
4
|
+
* to the sign-in door (BullseyeVSC scripts/mcp-gateway/signInDoor/doorSettings.ts, copied into src/gateway/signInDoor/ by
|
|
5
|
+
* `esbuild.js --sync-door` before every build) and are re-exported here, so a refusal thrown by
|
|
6
|
+
* the door and one thrown by BN's own doors are the one GatewayError class restDoor catches.
|
|
7
7
|
* notify.ts re-exports every name here, so a caller that still imports them from notify.js reads the same values.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { homedir } from "os";
|
|
11
|
-
import { join } from "path";
|
|
9
|
+
import { readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
12
10
|
import { fileURLToPath } from "url";
|
|
13
11
|
export const MANIFEST_PATH = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
14
12
|
/** The build the extension has installed beside this bundle now; it moves when a window activates a newer extension and mirrors it. */
|
|
@@ -18,20 +16,7 @@ export function installedVersion() {
|
|
|
18
16
|
/** The build this process is running, read once at load. */
|
|
19
17
|
export const PACKAGE_VERSION = installedVersion();
|
|
20
18
|
export const PACKAGE_HOMEPAGE = JSON.parse(readFileSync(MANIFEST_PATH, "utf8")).homepage;
|
|
21
|
-
export
|
|
22
|
-
export const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
23
|
-
export const DEFAULT_GATEWAY_PORT = 7470;
|
|
24
|
-
/** A refused request, answered to its caller with this status and these words by whichever door it reached. */
|
|
25
|
-
export class GatewayError extends Error {
|
|
26
|
-
status;
|
|
27
|
-
facts;
|
|
28
|
-
/** `facts` ride beside the words in the refusal's body, so a caller acts on what was refused without parsing the message. */
|
|
29
|
-
constructor(status, message, facts = {}) {
|
|
30
|
-
super(message);
|
|
31
|
-
this.status = status;
|
|
32
|
-
this.facts = facts;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
19
|
+
export { CONFIG_DIR, CONFIG_PATH, DEFAULT_GATEWAY_PORT, GatewayError, readGatewaySettings } from "./gateway/signInDoor/doorSettings.js";
|
|
35
20
|
/** A rename Windows refuses while a reader holds the destination open for a moment. */
|
|
36
21
|
const RENAME_REFUSED = new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
37
22
|
// GATE: five tries, waiting 10, 20, 40 and 80 ms — 150 ms at the outside — so a write a reader's lock refuses for a moment still lands, and one it refuses for good fails exactly as a single attempt did.
|
|
@@ -55,14 +40,3 @@ export function writeRecordFile(final, text) {
|
|
|
55
40
|
}
|
|
56
41
|
}
|
|
57
42
|
}
|
|
58
|
-
/** The token is mandatory: a door that is open to the home network never starts without one. */
|
|
59
|
-
export function readGatewaySettings() {
|
|
60
|
-
if (!existsSync(CONFIG_PATH))
|
|
61
|
-
return undefined;
|
|
62
|
-
const section = JSON.parse(readFileSync(CONFIG_PATH, "utf8")).agentGateway;
|
|
63
|
-
if (!section || typeof section.token !== "string" || section.token.length === 0)
|
|
64
|
-
return undefined;
|
|
65
|
-
const host = typeof section.host === "string" && section.host.length > 0 ? section.host : undefined;
|
|
66
|
-
const hosts = Array.isArray(section.hosts) && section.hosts.length > 0 ? section.hosts.map(String) : undefined;
|
|
67
|
-
return { token: section.token, port: typeof section.port === "number" ? section.port : DEFAULT_GATEWAY_PORT, ...(host === undefined ? {} : { host }), ...(hosts === undefined ? {} : { hosts }) };
|
|
68
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.495",
|
|
4
4
|
"homepage": "https://www.npmjs.com/package/omni-notify-mcp",
|
|
5
5
|
"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.",
|
|
6
6
|
"main": "dist/daemon.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"sync-shared": "node -e \"require((process.env.BULLSEYE_SHARED||require('os').homedir()+'/Desktop/BullseyeShared')+'/git-bash/gitBash.js').run(process.argv.slice(1))\" sync-shared.sh",
|
|
17
|
-
"prebuild": "npm run sync-shared",
|
|
18
|
-
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node -e \"require('fs').copyFileSync('src/shared/webhost/package.json','dist/shared/webhost/package.json');require('fs').copyFileSync('vscode-extension/mcpHosts.cjs','dist/mcpHosts.cjs');require('fs').copyFileSync('vscode-extension/channelReading.cjs','dist/channelReading.cjs');require('fs').copyFileSync('vscode-extension/gatewayInstall.cjs','dist/gatewayInstall.cjs')\"",
|
|
17
|
+
"prebuild": "npm run sync-shared && node vscode-extension/esbuild.js --sync-door",
|
|
18
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node -e \"require('fs').copyFileSync('src/shared/webhost/package.json','dist/shared/webhost/package.json');require('fs').copyFileSync('src/gateway/signInDoor/package.json','dist/gateway/package.json');require('fs').copyFileSync('src/gateway/signInDoor/shared/package.json','dist/gateway/signInDoor/shared/package.json');require('fs').copyFileSync('vscode-extension/mcpHosts.cjs','dist/mcpHosts.cjs');require('fs').copyFileSync('vscode-extension/channelReading.cjs','dist/channelReading.cjs');require('fs').copyFileSync('vscode-extension/gatewayInstall.cjs','dist/gatewayInstall.cjs')\"",
|
|
19
19
|
"build:extension": "node vscode-extension/esbuild.js",
|
|
20
20
|
"start": "node dist/daemon.js",
|
|
21
21
|
"test": "npm run build && npm run build:extension && node tests/run-tests.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|