omni-notify-mcp 1.3.424 → 1.3.426
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/channelReading.cjs +18 -0
- package/dist/gateway/chatPage.js +248 -85
- package/dist/gateway/extensionModule.js +20 -0
- package/dist/gateway/gatewayInstall.js +83 -0
- package/dist/gateway/mcpDoor.js +19 -4
- package/dist/gateway/mcpHosts.js +19 -0
- package/dist/gateway/panel.js +98 -13
- package/dist/gateway/panelPage.js +353 -222
- package/dist/gateway/passkeyDoor.js +2 -2
- package/dist/gateway/restDoor.js +34 -5
- package/dist/gateway/terminalDoor.js +76 -0
- package/dist/gateway/terminalPage.js +112 -43
- package/dist/gatewayInstall.cjs +59 -0
- package/dist/mcpHosts.cjs +452 -0
- package/dist/notify.js +1 -0
- package/dist/shared/agentSession.js +393 -47
- package/dist/shared/conversation/claudeProvider.js +2 -1
- package/dist/shared/webhost/bullseyeWebHost.js +50 -30
- package/dist/shared/webhost/homeRelative.js +19 -0
- package/dist/shared/webhost/webviewShim.js +6 -6
- package/package.json +3 -2
- package/scripts/shared/ownerGuard.cs +0 -665
- package/scripts/shared/ownerGuard.ps1 +0 -31
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const CHANNEL_KEYS = ["desktop", "telegram", "slack", "sms", "ntfy", "discord", "teams"];
|
|
4
|
+
|
|
5
|
+
function channelsOn(cfg) {
|
|
6
|
+
// NULL-OK: field cfg[key] is OPTIONAL and therefore it is ok to check for NULL
|
|
7
|
+
return CHANNEL_KEYS.filter((key) => cfg[key]?.enabled === true);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function masterMuted(cfg) {
|
|
11
|
+
return cfg.muteAll === true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function firstRunNote(absent) {
|
|
15
|
+
return absent ? " (the file does not exist yet — open the panel and switch a channel on)" : "";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { CHANNEL_KEYS, channelsOn, masterMuted, firstRunNote };
|
package/dist/gateway/chatPage.js
CHANGED
|
@@ -41,22 +41,45 @@ export function servingIdentity() {
|
|
|
41
41
|
export function servingLine() {
|
|
42
42
|
const me = servingIdentity();
|
|
43
43
|
const line = `BN ${me.build} · pid ${me.pid} · started ${storedStamp(me.startedAt)}`;
|
|
44
|
-
return `<div id="serving" class="idbar" data-be-tip="The process that answered this page — the build its own code was loaded from, its process id, and when that process started — and when this page's sign-in expires"><span class="srv">${line}</span><small id="expires" hidden></small></div>`;
|
|
44
|
+
return `<div id="serving" class="idbar" hidden data-be-tip="The process that answered this page — the build its own code was loaded from, its process id, and when that process started — and when this page's sign-in expires"><span class="srv">${line}</span><small id="expires" hidden></small></div>`;
|
|
45
45
|
}
|
|
46
46
|
/** The look every page of the door shares (#2873): BN's page and each service page the public gateway serves. */
|
|
47
|
-
export const PAGE_STYLE = `:root{--bg:#fff;--fg:#111;--mut:#
|
|
48
|
-
@media(prefers-color-scheme:dark){:root{--bg:#14171c;--fg:#e8eaed;--mut:#9aa3b0;--line:#
|
|
49
|
-
*{box-sizing:border-box}html,body{height:100%;margin:0}body{height:100dvh;font:
|
|
50
|
-
header{display:flex;
|
|
51
|
-
header h1{font-size:14px;margin:0;flex:1 1 0;min-width:
|
|
52
|
-
header button{flex:none;padding:
|
|
47
|
+
export const PAGE_STYLE = `:root{--bg:#fff;--fg:#111;--mut:#5d6675;--line:#d0d6de;--me:#0b5fff;--agent:#eef1f5;--bad:#a40000;--ok:#1a7f37;--warn:#8a5a00;--warnbg:#fff4d6;--badbg:#fde8e6}
|
|
48
|
+
@media(prefers-color-scheme:dark){:root{--bg:#14171c;--fg:#e8eaed;--mut:#9aa3b0;--line:#2f3642;--agent:#222831;--me:#2f6df0;--bad:#ff8a80;--ok:#7ee2a8;--warn:#e3b341;--warnbg:#2c2410;--badbg:#301715}}
|
|
49
|
+
*{box-sizing:border-box}html,body{height:100%;margin:0}body{height:100dvh;font:15px/1.35 system-ui,sans-serif;background:var(--bg);color:var(--fg);display:flex;flex-direction:column}
|
|
50
|
+
header{flex:none;display:flex;align-items:center;gap:4px;height:32px;padding:0 6px;background:var(--agent);box-shadow:0 1px 0 var(--line);position:relative;z-index:1}
|
|
51
|
+
header h1{font-size:14px;margin:0 4px;flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
52
|
+
header button,header a.tab{flex:none;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;min-width:40px;padding:0 9px;font-size:13px;line-height:1;white-space:nowrap;text-decoration:none;color:var(--fg);border:solid transparent;border-width:3px 0;border-radius:10px;background:var(--bg) padding-box;box-shadow:inset 0 0 0 1px var(--line)}
|
|
53
|
+
header .here{background:var(--me) padding-box;box-shadow:none;color:#fff;font-weight:600}
|
|
54
|
+
header button.go{box-shadow:none}
|
|
55
|
+
header .tools{display:flex;align-items:center;gap:4px;flex:none}
|
|
53
56
|
button{font:inherit;padding:8px 12px;border:1px solid var(--line);border-radius:8px;background:var(--agent);color:var(--fg)}
|
|
54
57
|
button.go{background:var(--me);border-color:var(--me);color:#fff}button:disabled{opacity:.5}
|
|
58
|
+
header button.go{background:var(--me) padding-box}
|
|
55
59
|
main{flex:1;min-height:0;overflow-y:auto;padding:10px 12px}
|
|
56
60
|
input,textarea{font:inherit;width:100%;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg)}
|
|
57
61
|
label{display:block;margin:10px 0 4px;color:var(--mut);font-size:14px}
|
|
62
|
+
.nline{flex:none;display:flex;flex-wrap:wrap;align-items:stretch;box-shadow:inset 0 -1px 0 var(--line);font-size:12px;line-height:16px}
|
|
63
|
+
.nline.gone{display:none}
|
|
64
|
+
.nsay{flex:1 1 0;min-width:0;min-height:24px;display:flex;flex-wrap:wrap;align-items:center;gap:0 6px;padding:4px 8px;border:0;border-radius:0;background:none;color:inherit;font:inherit;text-align:left}
|
|
65
|
+
.nword{flex:none;font-weight:700;letter-spacing:.02em;white-space:nowrap}
|
|
66
|
+
.ntext{flex:1 1 0;min-width:0;color:var(--mut);white-space:normal;overflow-wrap:anywhere}
|
|
67
|
+
.nx{flex:none;width:40px;min-height:24px;padding:0;border:0;border-radius:0;background:none;color:var(--mut);font-size:14px;line-height:1}
|
|
68
|
+
.ndetail{flex:1 1 100%;min-width:0;padding:6px 8px 8px;border-top:1px solid var(--line);background:var(--bg);font-size:13px;line-height:18px}
|
|
69
|
+
.ndetail p{margin:4px 0}.ndetail button{margin:4px 0}
|
|
70
|
+
.nline[data-severity=good] .nword{color:var(--ok)}.nline[data-severity=warning] .nword{color:var(--warn)}.nline[data-severity=error] .nword{color:var(--bad)}
|
|
71
|
+
.nline[data-severity=warning]{background:var(--warnbg)}.nline[data-severity=error]{background:var(--badbg)}
|
|
72
|
+
.facts{border-collapse:collapse;width:100%;margin:2px 0 6px}
|
|
73
|
+
.facts th,.facts td{border:1px solid var(--line);padding:3px 6px;text-align:left;vertical-align:top;font-weight:400;overflow-wrap:anywhere}
|
|
74
|
+
.facts th{color:var(--mut);white-space:nowrap;width:1%}
|
|
75
|
+
.facts thead th{font-weight:600;background:var(--agent);width:auto}
|
|
76
|
+
.facts .idrow{overflow:visible}.facts .conv-id{flex:1 1 0;white-space:normal;overflow:visible;overflow-wrap:anywhere}
|
|
77
|
+
#__bullseye-connection{position:static!important;order:-1;flex:none;min-height:24px}
|
|
78
|
+
#__bullseye-connection button{width:40px!important;height:auto!important;min-height:0!important;align-self:stretch}
|
|
79
|
+
header{order:-2}
|
|
58
80
|
.convscroll{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
|
|
59
81
|
.conv{border-collapse:separate;border-spacing:0;font-size:14px;table-layout:fixed}
|
|
82
|
+
.conv.stale tbody{opacity:.55}
|
|
60
83
|
.conv th,.conv td{border-bottom:1px solid var(--line);border-right:1px solid var(--line);padding:6px 8px;text-align:left;vertical-align:middle;overflow:hidden}
|
|
61
84
|
.conv th:last-child,.conv td:last-child{border-right:0}
|
|
62
85
|
.conv thead th{color:var(--mut);font-size:12px;font-weight:600;letter-spacing:.03em;background:var(--agent);position:relative}
|
|
@@ -70,8 +93,10 @@ label{display:block;margin:10px 0 4px;color:var(--mut);font-size:14px}
|
|
|
70
93
|
.conv tbody tr:focus-visible{outline:2px solid var(--me);outline-offset:-2px}
|
|
71
94
|
.conv tbody tr.sel{background:rgba(11,95,255,.12)}
|
|
72
95
|
.conv td{white-space:nowrap;text-overflow:ellipsis}
|
|
73
|
-
.conv td.statecell{white-space:normal;overflow-wrap:normal}
|
|
96
|
+
.conv td.statecell{white-space:normal;overflow-wrap:normal;font-weight:600}
|
|
97
|
+
.conv td.statecell[data-state=closed]{color:var(--mut);font-weight:400}
|
|
74
98
|
.conv td.timecell{font-size:12px;font-variant-numeric:tabular-nums}
|
|
99
|
+
.conv td.timecell .age{color:var(--mut)}.conv td.timecell .age::before{content:" · "}
|
|
75
100
|
.conv td.checkcell,.conv th.checkcell{text-align:center;padding:4px 6px}
|
|
76
101
|
.conv input[type=checkbox]{width:15px;height:15px;margin:0;cursor:pointer;vertical-align:middle}
|
|
77
102
|
.conv td.actions{white-space:normal}
|
|
@@ -79,14 +104,13 @@ label{display:block;margin:10px 0 4px;color:var(--mut);font-size:14px}
|
|
|
79
104
|
.idrow{display:flex;align-items:center;gap:6px;min-width:0;overflow:hidden}
|
|
80
105
|
.actrow{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-width:0}
|
|
81
106
|
.acts{display:flex;gap:4px;flex-wrap:wrap;margin:0}.acts button{padding:6px 8px;font-size:14px}
|
|
82
|
-
.listbar{display:flex;flex-wrap:wrap;align-items:center;gap:
|
|
83
|
-
.listbar .count{font-size:13px;color:var(--mut);min-width:0;white-space:
|
|
107
|
+
.listbar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:0 0 8px}
|
|
108
|
+
.listbar .count{font-size:13px;color:var(--mut);min-width:0;white-space:nowrap}
|
|
84
109
|
.listbar .spacer{flex:1 1 auto;min-width:0}
|
|
85
|
-
.listbar button{padding:
|
|
86
|
-
.
|
|
87
|
-
.listbar .notice.err{color:var(--bad)}
|
|
110
|
+
.listbar button{padding:5px 10px;font-size:13px}
|
|
111
|
+
.listnote{margin:0 0 8px;border:1px solid var(--line);border-radius:8px;overflow:hidden}
|
|
88
112
|
.listbar .pick{max-width:none}
|
|
89
|
-
.phonesort{display:none}
|
|
113
|
+
.phonesort,.listbar .all{display:none}
|
|
90
114
|
.bad{color:var(--bad)}
|
|
91
115
|
.rowmeta{color:var(--mut);font-size:13px;white-space:normal;margin:1px 0}
|
|
92
116
|
.idline{display:flex;align-items:center;gap:6px;min-width:0;margin:2px 0}
|
|
@@ -97,9 +121,8 @@ label{display:block;margin:10px 0 4px;color:var(--mut);font-size:14px}
|
|
|
97
121
|
.timeline{display:flex;flex-wrap:wrap;gap:4px 12px;color:var(--mut);font-size:12px;white-space:normal;margin:1px 0}
|
|
98
122
|
.timeline .t{font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
99
123
|
.convmeta{border:1px solid var(--line);border-radius:10px;padding:6px 10px;margin:0 0 10px}
|
|
100
|
-
.idbar{
|
|
101
|
-
.idbar
|
|
102
|
-
.idbar #expires{flex:none}
|
|
124
|
+
.idbar{color:var(--mut);font-size:12px;line-height:16px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
125
|
+
.idbar #expires{display:block}
|
|
103
126
|
.body{white-space:pre-wrap;overflow-wrap:anywhere;max-width:100%}
|
|
104
127
|
.body p{margin:0 0 6px}.body p:last-child{margin-bottom:0}
|
|
105
128
|
.body h1,.body h2,.body h3,.body h4,.body h5,.body h6{margin:10px 0 4px;line-height:1.25}
|
|
@@ -129,43 +152,140 @@ label{display:block;margin:10px 0 4px;color:var(--mut);font-size:14px}
|
|
|
129
152
|
.pick input{flex:1 1 auto;min-width:0;max-width:240px;padding:6px}
|
|
130
153
|
.pick small{flex:1 1 100%;color:var(--bad);font-size:12px;overflow-wrap:anywhere}
|
|
131
154
|
@media(max-width:480px) and (pointer:coarse){
|
|
132
|
-
header{
|
|
133
|
-
header
|
|
134
|
-
header h1{
|
|
135
|
-
header
|
|
155
|
+
header{padding:0 4px}
|
|
156
|
+
header h1{position:absolute;width:1px;height:1px;margin:0;overflow:hidden;clip-path:inset(50%)}
|
|
157
|
+
body.titled header h1{position:static;width:auto;height:auto;margin:0 4px;clip-path:none}
|
|
158
|
+
header .lbl{display:none}header .here .lbl,header .keep .lbl{display:inline}
|
|
159
|
+
header .grow{flex:1 1 0;min-width:0}
|
|
160
|
+
header button{min-height:0}
|
|
161
|
+
.nline{font-size:13px;line-height:18px}
|
|
162
|
+
.nsay,.nx{min-height:32px}
|
|
163
|
+
main{padding:8px}
|
|
136
164
|
button,select{min-height:40px}
|
|
137
165
|
input,select,textarea{font-size:16px}
|
|
138
166
|
input:not([type=checkbox]):not([type=radio]),select{min-height:40px}
|
|
139
|
-
.acts button,.
|
|
140
|
-
.copyid{min-height:40px;display:inline-flex;align-items:center;padding:0
|
|
167
|
+
.acts button,.tm .tmbar button{min-height:40px;font-size:14px}
|
|
168
|
+
.copyid{min-height:32px;min-width:40px;display:inline-flex;align-items:center;justify-content:center;padding:0 8px}
|
|
141
169
|
.system a{display:inline-block;min-height:40px;line-height:40px}
|
|
142
|
-
.
|
|
170
|
+
.listbar{flex-wrap:nowrap;gap:4px;height:32px;margin:0 0 8px}
|
|
171
|
+
.listbar button,.listbar select{flex:none;height:32px;min-height:32px;min-width:40px;padding:0 9px;font-size:13px;border-radius:8px}
|
|
172
|
+
.listbar .count,.listbar .clear{display:none}.listbar .all{display:inline-block}
|
|
173
|
+
.listbar .lbl{display:none}
|
|
174
|
+
.phonesort{display:flex;flex:0 1 auto;min-width:0;gap:4px;align-items:center}
|
|
175
|
+
.phonesort select{flex:0 1 auto;min-width:0;max-width:120px;border:1px solid var(--line);background:var(--agent);color:var(--fg)}
|
|
176
|
+
.conv,.conv tbody{display:block}
|
|
143
177
|
.conv{width:100%!important;table-layout:auto}
|
|
144
|
-
.conv colgroup{display:none}
|
|
145
|
-
.conv
|
|
146
|
-
.
|
|
147
|
-
.
|
|
148
|
-
.conv
|
|
149
|
-
.conv
|
|
150
|
-
.conv
|
|
151
|
-
.conv td
|
|
152
|
-
.conv td
|
|
178
|
+
.conv colgroup,.conv thead{display:none}
|
|
179
|
+
.conv tbody tr{display:grid;grid-template-columns:40px minmax(0,1fr) minmax(0,1fr);border:1px solid var(--line);border-radius:10px;margin:0 0 8px;overflow:hidden;background:var(--bg);-webkit-tap-highlight-color:transparent}
|
|
180
|
+
.conv tbody tr.sel{background:var(--agent);border-color:var(--me);box-shadow:inset 3px 0 0 var(--me)}
|
|
181
|
+
.conv td,.conv td:last-child{display:flex;gap:6px;align-items:baseline;min-width:0;border:0;border-bottom:1px solid var(--line);border-left:1px solid var(--line);padding:5px 8px;font-size:14px;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere}
|
|
182
|
+
.conv td[data-label]::before{content:attr(data-label);flex:none;min-width:38px;color:var(--mut);font-size:11px;letter-spacing:.04em;text-transform:uppercase}
|
|
183
|
+
.conv td.checkcell{grid-row:1/span 5;border-left:0;padding:0;align-items:stretch;background:var(--agent)}
|
|
184
|
+
.conv td.checkcell input{appearance:none;-webkit-appearance:none;width:40px;height:auto;min-height:44px;margin:0;border:0;border-radius:0;background:linear-gradient(var(--bg),var(--bg)) center/18px 18px no-repeat,linear-gradient(var(--mut),var(--mut)) center/22px 22px no-repeat}
|
|
185
|
+
.conv td.checkcell input:checked{background:linear-gradient(#fff,#fff) center/8px 8px no-repeat,linear-gradient(var(--me),var(--me)) center/22px 22px no-repeat}
|
|
186
|
+
.conv td.timecell{flex-wrap:wrap;gap:0 6px}.conv td.timecell .day,.conv td.timecell .ms,.conv td.timecell .age::before{display:none}
|
|
187
|
+
.conv td.timecell .age{order:1;color:var(--fg);white-space:nowrap}.conv td.timecell .at{order:2;color:var(--mut);font-size:12px;white-space:nowrap}
|
|
188
|
+
.conv td.k-process{grid-column:2/-1;order:4}.conv td.k-id{grid-column:2/-1;order:5;align-items:center}
|
|
189
|
+
.conv td.k-id .idrow{flex:1 1 0;overflow:visible}
|
|
190
|
+
.conv .conv-id{flex:1 1 0;white-space:normal;overflow:visible;overflow-wrap:anywhere}
|
|
191
|
+
.conv td.actions,.conv td.actions:last-child{grid-column:1/-1;order:6;display:block;border-left:0;border-bottom:0;padding:6px 8px}
|
|
153
192
|
.conv td.actions::before{display:none}
|
|
154
|
-
.
|
|
155
|
-
.conv td.checkcell{display:block;padding:4px 0}
|
|
156
|
-
.conv input[type=checkbox]{width:40px;height:40px}
|
|
157
|
-
.conv td.empty{display:block;text-align:center}
|
|
158
|
-
#notification-status{display:flex!important;flex-wrap:wrap;align-items:center;gap:0 8px;margin:4px 8px!important;padding:2px 8px!important}
|
|
159
|
-
#notification-status>p{flex:1 1 0;min-width:0;margin:2px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
160
|
-
#notification-status details{flex:none}#notification-status details[open]{flex:1 1 100%}#notification-status summary{display:flex;align-items:center;min-height:40px}
|
|
193
|
+
.actrow{gap:6px}.acts{display:contents}.acts .bad{order:3;margin-left:auto}
|
|
161
194
|
.pick,.pick select,.pick input{max-width:100%}
|
|
162
|
-
.pick{flex:1 1
|
|
195
|
+
.actrow .pick{order:2;flex:1 1 80px}
|
|
196
|
+
.conv td.empty,.conv td.empty:last-child{grid-column:1/-1;display:block;border:0;text-align:center;padding:16px 8px}
|
|
197
|
+
.setup{flex-direction:column;flex-wrap:nowrap}
|
|
198
|
+
.setup button.go{min-height:44px}
|
|
163
199
|
}
|
|
164
200
|
[hidden]{display:none!important}`;
|
|
201
|
+
export const NOTICE_SCRIPT = String.raw `
|
|
202
|
+
function ago(at) { var s = Math.max(0, Math.round((Date.now() - at) / 1000)); return s < 60 ? s + "s" : s < 3600 ? Math.floor(s / 60) + "m" : s < 86400 ? Math.floor(s / 3600) + "h" : Math.floor(s / 86400) + "d"; }
|
|
203
|
+
function clockOf(at) { return new Date(at).toLocaleTimeString([], { hour12: false }); }
|
|
204
|
+
function agoSpan(at) { var span = el("span", "ago", ago(at) + " ago"); span.dataset.ago = String(at); return span; }
|
|
205
|
+
function tickAges() { document.querySelectorAll("[data-ago]").forEach(function (span) { var old = ago(Number(span.dataset.ago)) + " ago"; if (span.textContent !== old) span.textContent = old; }); }
|
|
206
|
+
function aged(before, at, after) { var words = el("span"); words.append(before, agoSpan(at), after || ""); return words; }
|
|
207
|
+
function plainWhy(err) { return err instanceof TypeError ? "no connection to BN" : err.message; }
|
|
208
|
+
function factsTable(rows) {
|
|
209
|
+
var table = el("table", "facts");
|
|
210
|
+
rows.forEach(function (row) { var tr = el("tr"), value = el("td"); if (row[1] instanceof Node) value.append(row[1]); else value.textContent = row[1]; tr.append(el("th", "", row[0]), value); table.append(tr); });
|
|
211
|
+
return table;
|
|
212
|
+
}
|
|
213
|
+
function noticeLine(host) {
|
|
214
|
+
var say = el("button", "nsay"), word = el("b", "nword"), text = el("span", "ntext"), x = el("button", "nx", "✕"), detail = el("div", "ndetail");
|
|
215
|
+
say.type = "button"; x.type = "button"; x.setAttribute("aria-label", "Dismiss"); detail.hidden = true;
|
|
216
|
+
say.append(word, text); host.classList.add("nline"); host.append(say, x, detail);
|
|
217
|
+
var line = { host: host, detail: detail, fill: null, dismissed: null }, key = "", shut = null, drawn = "";
|
|
218
|
+
line.set = function (mark, words, severity, facts) {
|
|
219
|
+
if (word.textContent !== mark) word.textContent = mark;
|
|
220
|
+
if (text.textContent !== words) text.textContent = words;
|
|
221
|
+
if (host.dataset.severity !== (severity || "")) host.dataset.severity = severity || "";
|
|
222
|
+
if (mark !== key) { key = mark; if (shut !== mark) { shut = null; host.classList.remove("gone"); } }
|
|
223
|
+
var now = mark + "|" + (facts || "");
|
|
224
|
+
if (!detail.hidden && line.fill !== null && now !== drawn) line.fill(detail);
|
|
225
|
+
drawn = now;
|
|
226
|
+
};
|
|
227
|
+
line.hide = function () { key = ""; shut = null; detail.hidden = true; host.classList.add("gone"); };
|
|
228
|
+
say.onclick = function () { if (line.fill === null) return; detail.hidden = !detail.hidden; say.setAttribute("aria-expanded", String(!detail.hidden)); if (!detail.hidden) line.fill(detail); };
|
|
229
|
+
x.onclick = function () { if (!detail.hidden) { detail.hidden = true; say.setAttribute("aria-expanded", "false"); return; } if (line.dismissed !== null && line.dismissed()) return; shut = key; host.classList.add("gone"); };
|
|
230
|
+
return line;
|
|
231
|
+
}
|
|
232
|
+
var liveLine = null, liveLast = null, live = { on: false };
|
|
233
|
+
function liveWatch(view) { live = view === null ? { on: false } : { on: true, verb: view.verb || "read", period: view.period || 0, says: view.says || null, facts: view.facts || null, at: 0, failedAt: 0, why: "", ended: "", notice: null }; livePaint(); }
|
|
234
|
+
function liveRead() { if (!live.on) return; live.at = Date.now(); live.failedAt = 0; live.why = ""; if (liveLast !== null) liveLast.dataset.ago = String(live.at); livePaint(); }
|
|
235
|
+
function liveFailed(why) { if (!live.on) return; if (!live.failedAt) live.failedAt = Date.now(); live.why = why; if (live.notice && live.notice.severity !== "error") live.notice = null; livePaint(); }
|
|
236
|
+
function liveEnded(why) { if (!live.on) return; live.ended = why; livePaint(); }
|
|
237
|
+
// GATE: how long a notice that reports something done stays on the status line before it gives the line back; a failure stays until it is closed.
|
|
238
|
+
var NOTICE_MS = 8000, noticeTimer = 0;
|
|
239
|
+
function liveNotice(text, severity) {
|
|
240
|
+
if (!live.on) return;
|
|
241
|
+
clearTimeout(noticeTimer);
|
|
242
|
+
var notice = text ? { text: text, severity: severity || "" } : null;
|
|
243
|
+
live.notice = notice;
|
|
244
|
+
if (notice !== null && notice.severity === "") noticeTimer = setTimeout(function () { if (live.notice === notice) { live.notice = null; livePaint(); } }, NOTICE_MS);
|
|
245
|
+
livePaint();
|
|
246
|
+
}
|
|
247
|
+
function liveStatus() {
|
|
248
|
+
if (live.ended) return { mark: "⏹ ENDED", severity: "", words: live.ended };
|
|
249
|
+
var late = live.period > 0 && live.at > 0 && Date.now() - live.at > 2 * live.period + 2000;
|
|
250
|
+
if (live.failedAt || late) return { mark: "⚠️ STALE", severity: "warning", words: (live.at ? live.verb + " " + ago(live.at) + " ago" : "nothing read yet") + (live.why ? " · " + live.why : "") };
|
|
251
|
+
if (!live.at) return { mark: "⏳ LOADING", severity: "", words: "" };
|
|
252
|
+
return { mark: "✅ LIVE", severity: "good", words: live.verb + " " + ago(live.at) + " ago" };
|
|
253
|
+
}
|
|
254
|
+
function livePaint() {
|
|
255
|
+
if (liveLine === null) return;
|
|
256
|
+
if (!live.on) { liveLine.hide(); return; }
|
|
257
|
+
var status = liveStatus(), said = live.says ? live.says() : "";
|
|
258
|
+
var words = live.notice ? live.notice.text : (said ? said + " · " : "") + status.words;
|
|
259
|
+
liveLine.set(status.mark, words, live.notice && live.notice.severity === "error" ? "error" : status.severity, (live.notice ? live.notice.text : "") + "|" + live.why + "|" + (live.at ? 1 : 0) + "|" + (live.failedAt ? 1 : 0));
|
|
260
|
+
}
|
|
261
|
+
function liveDetail(detail) {
|
|
262
|
+
var status = liveStatus(), rows = [["Status", status.mark]];
|
|
263
|
+
if (live.notice) rows.push(["Notice", live.notice.text]);
|
|
264
|
+
liveLast = live.at ? agoSpan(live.at) : null;
|
|
265
|
+
if (liveLast !== null) rows.push(["Last " + live.verb, liveLast]);
|
|
266
|
+
if (live.period) rows.push(["Refreshes", "every " + Math.round(live.period / 1000) + " s, and when you come back to this page"]);
|
|
267
|
+
if (live.failedAt) rows.push(["Failing since", aged(clockOf(live.failedAt) + " (", live.failedAt, ") — " + live.why)]);
|
|
268
|
+
if (live.facts) rows = rows.concat(live.facts());
|
|
269
|
+
var kept = document.getElementById("serving");
|
|
270
|
+
detail.replaceChildren(factsTable(rows));
|
|
271
|
+
if (kept !== null) detail.append(kept);
|
|
272
|
+
}
|
|
273
|
+
function liveStart(host) {
|
|
274
|
+
liveLine = noticeLine(host);
|
|
275
|
+
liveLine.fill = liveDetail;
|
|
276
|
+
liveLine.dismissed = function () { if (!live.notice) return false; live.notice = null; livePaint(); return true; };
|
|
277
|
+
var kept = document.getElementById("serving");
|
|
278
|
+
if (kept !== null) { kept.hidden = false; liveLine.detail.append(kept); }
|
|
279
|
+
setInterval(function () { livePaint(); tickAges(); }, 1000);
|
|
280
|
+
livePaint();
|
|
281
|
+
}
|
|
282
|
+
`;
|
|
165
283
|
/** The sign-in half every page of the door shares (#2873): the kept session and its expiry, Logout, the sign-in screen and the
|
|
166
284
|
* check of a kept session on load. The page around it defines `main`, `el(tag, cls, text)`, `show(name, heading)` and
|
|
167
285
|
* `home()`, the screen a signed-in visitor lands on, and loads PASSKEY_SCRIPT before it. */
|
|
168
286
|
export const SIGN_IN_SCRIPT = `var KEY = "bn-chat-token";
|
|
287
|
+
// GATE: how long the page waits before asking the gateway again about its sign-in after a failed check.
|
|
288
|
+
var RECHECK_MS = 3000;
|
|
169
289
|
var token = "";
|
|
170
290
|
var expiresAt = 0, expiryTimer;
|
|
171
291
|
var btnLogout = document.getElementById("logout"), expiryNotice = document.getElementById("expires");
|
|
@@ -191,7 +311,14 @@ async function signIn(notice) {
|
|
|
191
311
|
btnLogout.disabled = false;
|
|
192
312
|
var door;
|
|
193
313
|
try { door = await (await fetch("/passkey/state")).json(); }
|
|
194
|
-
catch (e) {
|
|
314
|
+
catch (e) {
|
|
315
|
+
if (mine !== view) return;
|
|
316
|
+
window.bullseyeConnection.reconnecting("this page's connection to BN", RECHECK_MS);
|
|
317
|
+
main.append(el("div", "system", "⏳ Could not reach BN to ask how to sign in (" + plainWhy(e) + ") — asking again…"));
|
|
318
|
+
setTimeout(function () { if (mine === view) signIn(notice); }, RECHECK_MS);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
window.bullseyeConnection.live();
|
|
195
322
|
if (mine !== view) return;
|
|
196
323
|
var message = el("div", "err", notice || "");
|
|
197
324
|
if (door.enrolled && !door.local) {
|
|
@@ -215,8 +342,6 @@ async function signIn(notice) {
|
|
|
215
342
|
main.append(message);
|
|
216
343
|
}
|
|
217
344
|
|
|
218
|
-
// GATE: how long the page waits before asking the gateway again about its sign-in after a failed check.
|
|
219
|
-
var RECHECK_MS = 3000;
|
|
220
345
|
var gatewayDown = false;
|
|
221
346
|
async function resumeSignIn() {
|
|
222
347
|
var response = await fetch("/passkey/session", {headers:{authorization:"Bearer " + token}});
|
|
@@ -224,14 +349,15 @@ async function resumeSignIn() {
|
|
|
224
349
|
if (response.status === 401) { signIn("Your sign-in expired or was revoked. Sign in again."); return; }
|
|
225
350
|
if (!response.ok) throw new Error("the gateway answered " + response.status);
|
|
226
351
|
var session = await response.json();
|
|
352
|
+
window.bullseyeConnection.live();
|
|
227
353
|
keep(token, session.expiresIn === null ? 0 : Date.now() + session.expiresIn * 1000);
|
|
228
354
|
home();
|
|
229
355
|
}
|
|
230
356
|
function recheckSignIn(err) {
|
|
231
357
|
show("signin", "Sign in");
|
|
232
358
|
gatewayDown = true;
|
|
233
|
-
window.bullseyeConnection.reconnecting("
|
|
234
|
-
main.append(el("div", "system", "Could not reach
|
|
359
|
+
window.bullseyeConnection.reconnecting("this page's connection to BN", RECHECK_MS);
|
|
360
|
+
main.append(el("div", "system", "⏳ Could not reach BN (" + plainWhy(err) + ") — your sign-in is kept; checking again…"));
|
|
235
361
|
setTimeout(startSignIn, RECHECK_MS);
|
|
236
362
|
}
|
|
237
363
|
function startSignIn() { if (token) resumeSignIn().catch(recheckSignIn); else signIn(""); }`;
|
|
@@ -345,23 +471,23 @@ async function listView() {
|
|
|
345
471
|
var folders = [];
|
|
346
472
|
var foldersNote = "";
|
|
347
473
|
try { folders = (await api("GET", "/v1/projects")).projects.filter(function (p) { return p.board; }).map(function (p) { return { name: p.name, path: p.path }; }); }
|
|
348
|
-
catch (err) { if (err.message === "signed out") return; foldersNote = "The project folders could not be read — " + err
|
|
474
|
+
catch (err) { if (err.message === "signed out") return; foldersNote = "The project folders could not be read — " + plainWhy(err) + "."; }
|
|
349
475
|
if (mine !== view) return;
|
|
350
476
|
var act = async function (button, method, path) {
|
|
351
477
|
button.disabled = true;
|
|
352
478
|
try { await api(method, path); await paint(); }
|
|
353
|
-
catch (err) { if (err.message !== "signed out") { button.disabled = false;
|
|
479
|
+
catch (err) { if (err.message !== "signed out") { button.disabled = false; liveNotice("Not done — " + plainWhy(err), "error"); } }
|
|
354
480
|
};
|
|
355
481
|
var cols = [
|
|
356
482
|
{ key: "", check: true, name: "", min: 34, weight: 0 },
|
|
357
483
|
{ key: "project", name: "Project", min: 104, weight: 1.3 },
|
|
358
484
|
{ key: "state", name: "State", min: 96, weight: 1.1, state: true },
|
|
359
485
|
{ key: "origin", name: "From", min: 72, weight: 0.7 },
|
|
360
|
-
{ key: "provider", name: "Provider", min: 88, weight: 0.9 },
|
|
361
|
-
{ key: "id", name: "Conversation ID", min: 190, weight: 1.5 },
|
|
362
|
-
{ key: "process", name: "Process ID", min: 96, weight: 0.8 },
|
|
363
|
-
{ key: "opened", name: "Opened", min:
|
|
364
|
-
{ key: "updated", name: "Updated", min:
|
|
486
|
+
{ key: "provider", name: "Provider", short: "CLI", min: 88, weight: 0.9 },
|
|
487
|
+
{ key: "id", name: "Conversation ID", short: "ID", min: 190, weight: 1.5 },
|
|
488
|
+
{ key: "process", name: "Process ID", short: "PID", min: 96, weight: 0.8 },
|
|
489
|
+
{ key: "opened", name: "Opened", min: 200, weight: 1, time: true },
|
|
490
|
+
{ key: "updated", name: "Updated", min: 200, weight: 1, time: true },
|
|
365
491
|
{ key: "actions", name: "Actions", min: 216, weight: 0, plain: true }
|
|
366
492
|
];
|
|
367
493
|
var keyOf = function (col) { return col.key || "_check"; };
|
|
@@ -404,7 +530,7 @@ async function listView() {
|
|
|
404
530
|
return "";
|
|
405
531
|
};
|
|
406
532
|
|
|
407
|
-
var scroll = null, table = null, headRow = null, body = null, countEl = null, noticeEl = null, selectAll = null, emptyRow = null, sortPick = null, sortDirBtn = null;
|
|
533
|
+
var scroll = null, table = null, headRow = null, body = null, countEl = null, noticeEl = null, selectAll = null, emptyRow = null, sortPick = null, sortDirBtn = null, allBtn = null, said = null;
|
|
408
534
|
/** Whether this row's stop slot has anything to act on — the ONE rule both the row's button and the batch button use, so a row the batch would not act on is never offered as one it would. */
|
|
409
535
|
var stoppable = function (c) {
|
|
410
536
|
return c.state !== "closed";
|
|
@@ -489,8 +615,16 @@ async function listView() {
|
|
|
489
615
|
return;
|
|
490
616
|
}
|
|
491
617
|
var cls = col.state ? "statecell" : col.time ? "timecell" : col.plain ? "actions" : "";
|
|
492
|
-
var cell = el("td", cls);
|
|
493
|
-
cell.dataset.label = col.name;
|
|
618
|
+
var cell = el("td", (cls + " k-" + col.key).trim());
|
|
619
|
+
cell.dataset.label = col.short || col.name;
|
|
620
|
+
if (col.time) {
|
|
621
|
+
var day = el("span", "day"), clock = el("span", "clock"), ms = el("span", "ms"), age = el("span", "age");
|
|
622
|
+
var at = el("span", "at"); at.append(day, clock, ms);
|
|
623
|
+
cell.append(at, age);
|
|
624
|
+
tr.append(cell);
|
|
625
|
+
node.cells.push({ td: cell, day: day, clock: clock, ms: ms, age: age, col: col });
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
494
628
|
if (col.key === "id") {
|
|
495
629
|
var idrow = el("div", "idrow");
|
|
496
630
|
var code = el("code", "conv-id");
|
|
@@ -504,7 +638,7 @@ async function listView() {
|
|
|
504
638
|
// ONE action row for every session (#3614, #3916): Open, Stop, Delete, then the project slot.
|
|
505
639
|
var actrow = el("div", "actrow");
|
|
506
640
|
var acts = el("div", "acts");
|
|
507
|
-
var open = el("button", "", "📂 Open");
|
|
641
|
+
var open = el("button", "go", "📂 Open");
|
|
508
642
|
open.onclick = function (e) { e.stopPropagation(); go("term", node.c.id); };
|
|
509
643
|
acts.append(open);
|
|
510
644
|
// A conversation is STOPPED — its CLI ends, it runs no further turn and a later message resumes the same session.
|
|
@@ -515,7 +649,7 @@ async function listView() {
|
|
|
515
649
|
};
|
|
516
650
|
acts.append(halt);
|
|
517
651
|
node.halt = halt;
|
|
518
|
-
var drop = el("button", "bad", "Delete");
|
|
652
|
+
var drop = el("button", "bad", "🗑 Delete");
|
|
519
653
|
drop.onclick = function (e) { e.stopPropagation(); act(drop, "POST", "/v1/conversations/" + node.c.id + "/delete"); };
|
|
520
654
|
acts.append(drop);
|
|
521
655
|
actrow.append(acts);
|
|
@@ -552,6 +686,15 @@ async function listView() {
|
|
|
552
686
|
return;
|
|
553
687
|
}
|
|
554
688
|
if (col.key === "id") { if (cell.code.textContent !== c.id) cell.code.textContent = c.id; cell.code.title = c.id; return; }
|
|
689
|
+
if (col.time) {
|
|
690
|
+
var stamp = textOf(c, col), cut = /^([^ ]+ )([0-9:]{8})(.*)$/.exec(stamp);
|
|
691
|
+
if (cell.td.dataset.stamp !== stamp) { cell.td.dataset.stamp = stamp; cell.day.textContent = cut[1]; cell.clock.textContent = cut[2]; cell.ms.textContent = cut[3]; }
|
|
692
|
+
cell.age.dataset.ago = String(value(c, col.key));
|
|
693
|
+
var old = ago(value(c, col.key)) + " ago";
|
|
694
|
+
if (cell.age.textContent !== old) cell.age.textContent = old;
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
if (col.state) cell.td.dataset.state = c.state;
|
|
555
698
|
var text = textOf(c, col);
|
|
556
699
|
if (cell.td.textContent !== text) cell.td.textContent = text;
|
|
557
700
|
var tip = titleOf(c, col);
|
|
@@ -572,7 +715,7 @@ async function listView() {
|
|
|
572
715
|
if (shown.length === 0) {
|
|
573
716
|
if (emptyRow === null) {
|
|
574
717
|
emptyRow = el("tr");
|
|
575
|
-
var cell = el("td", "empty", "No conversations yet.
|
|
718
|
+
var cell = el("td", "empty", "No conversations yet. + New Agent starts one.");
|
|
576
719
|
cell.colSpan = cols.length;
|
|
577
720
|
emptyRow.append(cell);
|
|
578
721
|
}
|
|
@@ -586,10 +729,11 @@ async function listView() {
|
|
|
586
729
|
var mark = th.querySelector(".sortmark");
|
|
587
730
|
if (mark !== null) mark.textContent = sort.key !== col.key ? "↕" : sort.dir > 0 ? "▲" : sort.dir < 0 ? "▼" : "↕";
|
|
588
731
|
});
|
|
589
|
-
if (sortPick !== null) { sortPick.value = sort.key; sortDirBtn.
|
|
732
|
+
if (sortPick !== null) { sortPick.value = sort.key; sortDirBtn.replaceChildren(sort.dir === 1 ? "▲" : "▼", el("span", "lbl", sort.dir === 1 ? " Ascending" : " Descending")); sortDirBtn.setAttribute("aria-label", "Sort direction: " + (sort.dir === 1 ? "ascending" : "descending")); }
|
|
590
733
|
var n = 0;
|
|
591
734
|
shown.forEach(function (c) { if (picked[c.id]) n++; });
|
|
592
|
-
countEl.textContent = n === 0 ? "
|
|
735
|
+
countEl.textContent = n === 0 ? "" : n + " selected";
|
|
736
|
+
if (allBtn !== null) { allBtn.textContent = (n > 0 && n === shown.length ? "☑" : n > 0 ? "◪" : "☐") + " All"; allBtn.disabled = shown.length === 0; allBtn.setAttribute("aria-pressed", String(n > 0)); allBtn.setAttribute("aria-label", n > 0 ? "Clear the selection of " + n : "Select all conversations"); }
|
|
593
737
|
if (selectAll !== null) { selectAll.checked = shown.length > 0 && n === shown.length; selectAll.indeterminate = n > 0 && n < shown.length; }
|
|
594
738
|
[buttons.delete, buttons.clear].forEach(function (b) { if (b) b.disabled = n === 0; });
|
|
595
739
|
// Stop is offered only when at least one picked row has something to stop (#3614): a conversation already stopped has none.
|
|
@@ -618,8 +762,7 @@ async function listView() {
|
|
|
618
762
|
// a failure for refusing, which is what a 404 for an already-ended CLI would look like (#3614).
|
|
619
763
|
var acts = which === "stop" ? chosen.filter(stoppable) : chosen;
|
|
620
764
|
var untouched = chosen.filter(function (c) { return !acts.includes(c); });
|
|
621
|
-
|
|
622
|
-
noticeEl.textContent = (which === "delete" ? "Deleting " : which === "stop" ? "Stopping " : "Working on ") + acts.length + (acts.length === 1 ? " conversation…" : " conversations…");
|
|
765
|
+
said.set("⏳ WORKING", (which === "delete" ? "Deleting " : which === "stop" ? "Stopping " : "Working on ") + acts.length + (acts.length === 1 ? " conversation…" : " conversations…"), "");
|
|
623
766
|
var done = 0, failed = [];
|
|
624
767
|
for (var i = 0; i < acts.length; i++) {
|
|
625
768
|
markRowFailed(acts[i].id, null);
|
|
@@ -627,21 +770,22 @@ async function listView() {
|
|
|
627
770
|
catch (err) { if (err.message === "signed out") return; failed.push({ id: acts[i].id, why: err.message }); }
|
|
628
771
|
}
|
|
629
772
|
picked = {}; anchor = null;
|
|
630
|
-
await paint();
|
|
773
|
+
try { await paint(); }
|
|
774
|
+
catch (err) { if (err.message === "signed out") return; fail(err); }
|
|
631
775
|
failed.forEach(function (f) { markRowFailed(f.id, f.why); });
|
|
632
776
|
untouched.forEach(function (c) { markRowFailed(c.id, "Nothing to stop here — this conversation is already stopped."); });
|
|
633
|
-
|
|
634
|
-
+ (untouched.length ? " — " + untouched.length +
|
|
635
|
-
+ (failed.length ? " — " + failed.length + (failed.length === 1 ? " was" : " were") + " not " + word + ", with the reason on " + (failed.length === 1 ? "its row" : "their rows") : "");
|
|
636
|
-
noticeEl.className = failed.length ? "notice err" : "notice";
|
|
777
|
+
said.set(failed.length ? "⚠️ PARTIAL" : "✅ DONE", done + " of " + chosen.length + " " + word
|
|
778
|
+
+ (untouched.length ? " — " + untouched.length + " had nothing to stop" : "")
|
|
779
|
+
+ (failed.length ? " — " + failed.length + (failed.length === 1 ? " was" : " were") + " not " + word + ", with the reason on " + (failed.length === 1 ? "its row" : "their rows") : ""), failed.length ? "error" : "good");
|
|
637
780
|
};
|
|
638
781
|
|
|
639
782
|
var build = function () {
|
|
640
783
|
main.replaceChildren();
|
|
641
784
|
dom = {};
|
|
642
785
|
var bar = el("div", "listbar");
|
|
643
|
-
|
|
644
|
-
|
|
786
|
+
allBtn = el("button", "all", "☐ All");
|
|
787
|
+
allBtn.onclick = function () { var any = shown.some(function (c) { return picked[c.id]; }); picked = {}; if (!any) shown.forEach(function (c) { picked[c.id] = true; }); anchor = null; render(); };
|
|
788
|
+
bar.append(allBtn);
|
|
645
789
|
var phoneSort = el("div", "phonesort");
|
|
646
790
|
sortPick = el("select"); sortPick.setAttribute("aria-label", "Sort conversations by");
|
|
647
791
|
cols.forEach(function (col) { if (!col.key || col.plain) return; var o = el("option", "", col.name); o.value = col.key; sortPick.append(o); });
|
|
@@ -649,7 +793,6 @@ async function listView() {
|
|
|
649
793
|
sortDirBtn = el("button", "", "");
|
|
650
794
|
sortDirBtn.onclick = function () { sort = { key: sort.key, dir: sort.dir === 1 ? -1 : 1 }; render(); };
|
|
651
795
|
phoneSort.append(sortPick, sortDirBtn);
|
|
652
|
-
bar.append(phoneSort);
|
|
653
796
|
var mkButton = function (label, cls, key) {
|
|
654
797
|
var b = el("button", cls, label);
|
|
655
798
|
b.disabled = true;
|
|
@@ -658,15 +801,16 @@ async function listView() {
|
|
|
658
801
|
bar.append(b);
|
|
659
802
|
return b;
|
|
660
803
|
};
|
|
661
|
-
mkButton("Stop", "", "stop");
|
|
662
|
-
mkButton("Delete", "bad", "delete");
|
|
663
|
-
buttons.clear = el("button", "", "Clear");
|
|
804
|
+
mkButton("⏹ Stop", "", "stop");
|
|
805
|
+
mkButton("🗑 Delete", "bad", "delete");
|
|
806
|
+
buttons.clear = el("button", "clear", "✕ Clear");
|
|
664
807
|
buttons.clear.disabled = true;
|
|
665
808
|
buttons.clear.onclick = function () { picked = {}; anchor = null; render(); };
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
809
|
+
countEl = el("span", "count", "");
|
|
810
|
+
bar.append(buttons.clear, countEl, el("span", "spacer"), phoneSort);
|
|
811
|
+
noticeEl = el("div", "notice listnote");
|
|
812
|
+
said = noticeLine(noticeEl); said.hide();
|
|
813
|
+
main.append(bar, noticeEl);
|
|
670
814
|
|
|
671
815
|
scroll = el("div", "convscroll");
|
|
672
816
|
table = el("table", "conv");
|
|
@@ -709,18 +853,33 @@ async function listView() {
|
|
|
709
853
|
layout();
|
|
710
854
|
};
|
|
711
855
|
|
|
856
|
+
var reads = 0;
|
|
712
857
|
var paint = function () {
|
|
858
|
+
var turn = ++reads;
|
|
713
859
|
return api("GET", "/v1/conversations").then(function (data) {
|
|
714
|
-
if (mine !== view) return;
|
|
860
|
+
if (mine !== view || turn !== reads) return;
|
|
715
861
|
rows = data.conversations.slice();
|
|
716
862
|
if (table === null) build();
|
|
863
|
+
table.classList.remove("stale");
|
|
864
|
+
liveRead();
|
|
717
865
|
render();
|
|
718
866
|
});
|
|
719
867
|
};
|
|
720
|
-
|
|
868
|
+
// GATE: how often the list is read again; a read that fails keeps the rows on screen, marked STALE with their age.
|
|
869
|
+
var LIST_REFRESH_MS = 8000;
|
|
870
|
+
liveWatch({ period: LIST_REFRESH_MS, says: function () { return table === null ? "" : rows.length + (rows.length === 1 ? " conversation" : " conversations"); } });
|
|
871
|
+
var again = function () { clearTimeout(timer); timer = setTimeout(run, LIST_REFRESH_MS); };
|
|
872
|
+
var back = function () { if (mine === view && document.visibilityState === "visible") { clearTimeout(timer); run(); } };
|
|
873
|
+
document.addEventListener("visibilitychange", back);
|
|
874
|
+
var leaving = setInterval(function () { if (mine !== view) { clearInterval(leaving); document.removeEventListener("visibilitychange", back); } }, 1000);
|
|
721
875
|
var picking = function () { var at = document.activeElement; return at !== null && at.closest && at.closest(".pick") !== null; };
|
|
722
876
|
var run = function () { if (mine !== view) return; if (picking()) { again(); return; } paint().then(again, function (err) { fail(err); again(); }); };
|
|
723
|
-
var fail = function (err) {
|
|
877
|
+
var fail = function (err) {
|
|
878
|
+
if (mine !== view || err.message === "signed out") return;
|
|
879
|
+
liveFailed(plainWhy(err));
|
|
880
|
+
if (table !== null) table.classList.add("stale");
|
|
881
|
+
else main.replaceChildren(el("p", "system", "⏳ The conversations have not been read yet (" + plainWhy(err) + ") — asking again…"));
|
|
882
|
+
};
|
|
724
883
|
if (listResize !== null) window.removeEventListener("resize", listResize);
|
|
725
884
|
listResize = function () { if (mine === view) layout(); };
|
|
726
885
|
window.addEventListener("resize", listResize);
|
|
@@ -741,6 +900,7 @@ function show(name, heading) {
|
|
|
741
900
|
btnLogout.hidden = name === "signin";
|
|
742
901
|
expiryNotice.hidden = name === "signin";
|
|
743
902
|
main.replaceChildren();
|
|
903
|
+
liveWatch(name === "signin" ? null : {});
|
|
744
904
|
return view;
|
|
745
905
|
}
|
|
746
906
|
async function home() {
|
|
@@ -753,12 +913,13 @@ async function home() {
|
|
|
753
913
|
if (res.status === 401) { signIn("You are signed out. Sign in again."); return; }
|
|
754
914
|
if (!res.ok) throw new Error("The gateway answered " + res.status + ": " + await res.text());
|
|
755
915
|
var opened = await res.json();
|
|
916
|
+
liveRead();
|
|
756
917
|
if (mine === view) {
|
|
757
918
|
var back = sessionStorage.getItem("bullseye-return-to");
|
|
758
919
|
sessionStorage.removeItem("bullseye-return-to");
|
|
759
920
|
location.replace(back !== null && back.charAt(0) === "/" && back.charAt(1) !== "/" && back.charAt(1) !== "\\" ? back : opened.page);
|
|
760
921
|
}
|
|
761
|
-
} catch (err) { if (!(err instanceof Error)) throw err; if (mine === view) said.replaceWith(el("div", "err", err.
|
|
922
|
+
} catch (err) { if (!(err instanceof Error)) throw err; if (mine === view) { liveFailed(plainWhy(err)); said.replaceWith(el("div", "err", "⚠️ " + TITLE + " did not open — " + plainWhy(err) + ". 🔄 Refresh asks again.")); } }
|
|
762
923
|
}
|
|
763
924
|
`;
|
|
764
925
|
/** The page each service host of the public gateway serves (#2873): BN's look and BN's sign-in, then the page the
|
|
@@ -768,14 +929,16 @@ export function serviceHtml({ name, host }) {
|
|
|
768
929
|
const safe = (text) => text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
769
930
|
const facts = JSON.stringify({ name }).replace(/</g, "\\u003c");
|
|
770
931
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
771
|
-
<title>${safe(name)}</title>${ICON_HEAD}<style>${PAGE_STYLE}</style></head><body>
|
|
772
|
-
<header><h1 id="title">${safe(name)}</h1><button id="refresh" hidden
|
|
773
|
-
<div id="serving" class="idbar" 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 BN ${safe(me.build)}</span><small id="expires" hidden></small></div>
|
|
932
|
+
<title>${safe(name)}</title>${ICON_HEAD}<style>${PAGE_STYLE}</style></head><body class="titled">
|
|
933
|
+
<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>
|
|
934
|
+
<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 BN ${safe(me.build)}</span><small id="expires" hidden></small></div>
|
|
774
935
|
<main id="main"></main>
|
|
775
936
|
<script>${CONNECTION_SOURCE}</script><script>var FACTS = ${facts}, TITLE = FACTS.name;
|
|
776
937
|
${PASSKEY_SCRIPT}
|
|
777
938
|
${SIGN_IN_SCRIPT}
|
|
778
939
|
${SERVICE_SCRIPT}
|
|
940
|
+
${NOTICE_SCRIPT}
|
|
941
|
+
liveStart(document.getElementById("status"));
|
|
779
942
|
startSignIn();
|
|
780
943
|
</script></body></html>`;
|
|
781
944
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const loaded = new Map();
|
|
7
|
+
export function extensionModulePath(name) {
|
|
8
|
+
const found = [join(HERE, name), join(HERE, "..", name)].find((candidate) => existsSync(candidate));
|
|
9
|
+
if (found === undefined)
|
|
10
|
+
throw new Error(`${name} is not beside this build (${HERE}) — the build copies it from vscode-extension/${name}`);
|
|
11
|
+
return found;
|
|
12
|
+
}
|
|
13
|
+
export function extensionModule(name) {
|
|
14
|
+
const known = loaded.get(name);
|
|
15
|
+
if (known !== undefined)
|
|
16
|
+
return known;
|
|
17
|
+
const module = createRequire(import.meta.url)(extensionModulePath(name));
|
|
18
|
+
loaded.set(name, module);
|
|
19
|
+
return module;
|
|
20
|
+
}
|