omni-notify-mcp 1.3.440 → 1.3.442

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.
@@ -204,6 +204,7 @@ function agoSpan(at) { var span = el("span", "ago", ago(at) + " ago"); span.data
204
204
  function tickAges() { document.querySelectorAll("[data-ago]").forEach(function (span) { var old = ago(Number(span.dataset.ago)) + " ago"; if (span.textContent !== old) span.textContent = old; }); }
205
205
  function aged(before, at, after) { var words = el("span"); words.append(before, agoSpan(at), after || ""); return words; }
206
206
  function plainWhy(err) { return err instanceof TypeError ? "no connection to BN" : err.message; }
207
+ async function told(response) { if (response.status !== 502 && response.status !== 504 && /json/.test(response.headers.get("content-type") || "")) return response.json(); var gone = Error("BN is not answering (HTTP " + response.status + ")"); gone.status = response.status; throw gone; }
207
208
  function factsTable(rows) {
208
209
  var table = el("table", "facts");
209
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); });
@@ -309,7 +310,7 @@ async function signIn(notice) {
309
310
  token = "";
310
311
  btnLogout.disabled = false;
311
312
  var door;
312
- try { door = await (await fetch("/passkey/state")).json(); }
313
+ try { door = await told(await fetch("/passkey/state")); }
313
314
  catch (e) {
314
315
  if (mine !== view) return;
315
316
  window.bullseyeConnection.reconnecting("this page's connection to BN", RECHECK_MS);
@@ -910,8 +911,8 @@ async function home() {
910
911
  try {
911
912
  var res = await fetch("/screen/open", { method: "POST", headers: { authorization: "Bearer " + token } });
912
913
  if (res.status === 401) { signIn("You are signed out. Sign in again."); return; }
913
- if (!res.ok) throw new Error("The gateway answered " + res.status + ": " + await res.text());
914
- var opened = await res.json();
914
+ if (!res.ok && res.status !== 502 && res.status !== 504) throw new Error("The gateway answered " + res.status + ": " + await res.text());
915
+ var opened = await told(res);
915
916
  liveRead();
916
917
  if (mine === view) {
917
918
  var back = sessionStorage.getItem("bullseye-return-to");
@@ -106,8 +106,8 @@ async function call(method, path, body) {
106
106
  try { r = await fetch(path, { method: method, headers: scoped({ authorization: "Bearer " + token, "content-type": "application/json" }), body: body === undefined ? undefined : JSON.stringify(body) }); }
107
107
  catch (e) { window.bullseyeConnection.reconnecting("this page's connection to the Notify service", location.pathname.indexOf("public-access") >= 0 ? 2000 : REFRESH_MS); throw e; }
108
108
  if (r.status >= 502) window.bullseyeConnection.reconnecting("this page's connection to the Notify service (HTTP " + r.status + ")", location.pathname.indexOf("public-access") >= 0 ? 2000 : REFRESH_MS); else window.bullseyeConnection.live();
109
- var j = await r.json().catch(function () { return {}; });
110
109
  if (r.status === 401) { needSignIn("This sign-in was not accepted. Sign in again."); throw new Error("not signed in"); }
110
+ var j = await told(r);
111
111
  if (!r.ok) { var refused = new Error(j.error || ("HTTP " + r.status)); refused.status = r.status; throw refused; }
112
112
  return j;
113
113
  }
@@ -341,7 +341,8 @@ var STEPS_REFRESH_MS = 2000;
341
341
  function paint(m) {
342
342
  model = m;
343
343
  liveRead();
344
- if (m.banner) bannerLine.set("⚠️ NOTE", m.banner, "warning"); else bannerLine.hide();
344
+ bannerLine.fill = function (detail) { detail.replaceChildren(el("p", "", model.banner.replace(/^⚠️ /, ""))); };
345
+ if (m.banner) bannerLine.set("⚠️ TUNNEL", "another one runs here · tap to read", "warning", m.banner); else bannerLine.hide();
345
346
  m.steps.forEach(function (s, i) {
346
347
  var sec = document.getElementById("s" + i);
347
348
  sec.querySelector(".mark").textContent = s.mark;
@@ -249,7 +249,7 @@ export function signInPage(res, title, body) {
249
249
  <style>:root{--bg:#fff;--fg:#111;--mut:#667;--line:#d8dce2;--go:#0b5fff;--bad:#a40000}@media(prefers-color-scheme:dark){:root{--bg:#14171c;--fg:#e8eaed;--mut:#9aa3b0;--line:#2b313b;--go:#2f6df0;--bad:#ff8a80}}
250
250
  body{font:16px system-ui,sans-serif;max-width:440px;margin:12px auto;padding:0 16px;background:var(--bg);color:var(--fg)}h2{font-size:19px;margin:0 0 8px}h3{font-size:15px;margin:16px 0 4px}input{font:inherit;width:100%;padding:10px;box-sizing:border-box;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg)}
251
251
  button{font:inherit;padding:10px 16px;margin:12px 8px 0 0;border:1px solid var(--go);border-radius:8px;background:var(--go);color:#fff}button.plain{background:none;color:var(--fg);border-color:var(--line)}
252
- .mut{color:var(--mut);font-size:14px}.err{color:var(--bad);font-weight:600}code{word-break:break-all}svg{width:240px;height:240px;background:#fff}li{margin:4px 0}a{color:var(--go)}.home{display:inline-flex;align-items:center;min-height:32px;padding:0 10px;margin:0 0 10px;border:1px solid var(--line);border-radius:8px;color:var(--fg);text-decoration:none;font-size:14px}@media(max-width:480px) and (pointer:coarse){a{display:inline-block;padding:10px 0}a.home{display:inline-flex;padding:0 10px}button{min-height:44px}}</style></head><body><a class="home" href="/">‹ BN sign-in</a>${body}</body></html>`;
252
+ .mut{color:var(--mut);font-size:14px}.err{color:var(--bad);font-weight:600}code{word-break:break-all}svg{width:240px;height:240px;background:#fff}li{margin:4px 0}a{color:var(--go)}.home{display:inline-flex;align-items:center;min-height:32px;padding:0 10px;margin:0 0 10px;border:1px solid var(--line);border-radius:8px;color:var(--fg);text-decoration:none;font-size:14px}@media(max-width:480px) and (pointer:coarse){a{display:inline-block;padding:10px 0}a.home{display:inline-flex;padding:0 10px}button{min-height:44px}}</style></head><body>${body}</body></html>`;
253
253
  res.writeHead(200, { ...PAGE_HEADERS, "content-length": String(Buffer.byteLength(html)) });
254
254
  res.end(html);
255
255
  }
@@ -480,8 +480,9 @@ export function createSignInDoor({ storeFile, product, short, home, host: doorHo
480
480
  tickets.set(digest(ticket), { exp: expiresAt, host: doorHost, ...(replaces === undefined ? {} : { replaces }) });
481
481
  return { url: `https://${doorHost}${ENROL_PATH}#${ticket}`, expiresAt };
482
482
  }
483
+ const wayBack = `<a class="home" href="/">‹ ${short} sign-in</a>`;
483
484
  function enrolPage(res) {
484
- signInPage(res, `${short} passkey`, `<h2>Add a passkey for ${short}</h2>
485
+ signInPage(res, `${short} passkey`, `${wayBack}<h2>Add a passkey for ${short}</h2>
485
486
  <p>Your phone's fingerprint will be what signs you in to ${short} from anywhere. After it is added, it is the only way into ${short} from the internet.</p>
486
487
  <p>${PROOF_WAYS.link}</p>
487
488
  <button id="go">Add passkey</button><p id="out"></p>
@@ -495,15 +496,15 @@ go.onclick=async function(){go.disabled=true;out.className="";out.textContent="W
495
496
  </script>`);
496
497
  }
497
498
  function authenticatorPage(res) {
498
- signInPage(res, `${short} authenticator`, `<h2>Add an authenticator app</h2>
499
+ signInPage(res, `${short} authenticator`, `${wayBack}<h2>Add an authenticator app</h2>
499
500
  <p>Google Authenticator, Microsoft Authenticator and LastPass all work. Its 6-digit code becomes the second way to sign in to ${short}, after the fingerprint. Away from this computer, your fingerprint is asked first.</p>
500
501
  <button id="go">Show the QR code</button><div id="qr"></div>
501
502
  <div id="confirm" hidden><label>Code the app shows<br><input id="code" inputmode="numeric" autocomplete="one-time-code" maxlength="6"></label><button id="ok">Add authenticator</button></div><p id="out"></p>
502
503
  <script>${PASSKEY_SCRIPT}
503
504
  var out=document.getElementById("out"),go=document.getElementById("go"),ok=document.getElementById("ok"),qr=document.getElementById("qr"),confirm=document.getElementById("confirm"),auth={},pending="";
504
- var fail=function(b){return function(e){out.className="err";out.textContent=e.message;b.disabled=false;};};
505
+ var fail=function(b){return function(e){out.className="err";out.textContent=e instanceof TypeError?"No connection to ${short} — press it again once you are back online.":e.message;b.disabled=false;};};
505
506
  go.onclick=function(){go.disabled=true;out.className="";
506
- fetch("/passkey/state"+location.search).then(function(r){return r.json();}).then(function(door){if(door.local)return;out.textContent="Waiting for your fingerprint...";return passkeySignIn().then(function(s){auth={authorization:"Bearer "+s};});})
507
+ fetch("/passkey/state"+location.search).then(function(r){if(r.status===502||r.status===504||!/json/.test(r.headers.get("content-type")||""))throw new Error("${short} is not answering (HTTP "+r.status+")");return r.json();}).then(function(door){if(door.local)return;out.textContent="Waiting for your fingerprint...";return passkeySignIn().then(function(s){auth={authorization:"Bearer "+s};});})
507
508
  .then(function(){return pkPost("/passkey/authenticator/begin"+location.search,{},auth);})
508
509
  .then(function(b){pending=b.pending;qr.innerHTML=b.qr;var k=document.createElement("p");k.className="mut";k.textContent="Or type this key in the app: "+b.key;qr.append(k);confirm.hidden=false;
509
510
  out.textContent="Scan it in the app, then type the 6-digit code it shows.";document.getElementById("code").focus();},fail(go));};
@@ -520,7 +521,7 @@ ok.onclick=function(){ok.disabled=true;pkPost("/passkey/authenticator/confirm"+l
520
521
  const app = store.authenticator === undefined ? `<p class="mut">None — <a href="${authenticatorHref}">add an authenticator app</a>.</p>`
521
522
  : `<ul><li><b>Authenticator app</b> <span class="mut">${escapeHtml(new Date(store.authenticator.createdAt).toLocaleString())}</span>
522
523
  <button class="plain" data-route="authenticator/remove">Remove</button></li></ul><p><a href="${authenticatorHref}">Replace it</a></p>`;
523
- signInPage(res, `${short} passkey setup`, `<h2>${short} passkeys</h2><h3>Enrolled</h3>${listed ? `<ul>${listed}</ul>` : `<p class="mut">No passkey yet.</p>`}<h3>Authenticator app</h3>${app}
524
+ signInPage(res, `${short} passkey setup`, `${wayBack}<h2>${short} passkeys</h2><h3>Enrolled</h3>${listed ? `<ul>${listed}</ul>` : `<p class="mut">No passkey yet.</p>`}<h3>Authenticator app</h3>${app}
524
525
  ${locked(store) ? "" : `<p class="mut">Until an owner passkey is registered, nothing opens ${short} from outside.</p>`}<p id="out" class="err"></p>
525
526
  <script>document.querySelectorAll("button[data-id],button[data-route]").forEach(function(b){b.onclick=async function(){b.disabled=true;
526
527
  var r=await fetch("${PASSKEY_PREFIX}"+(b.dataset.route||"remove")+location.search,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:b.dataset.id})});
@@ -128,7 +128,8 @@ function sizePhone(){
128
128
  document.body.classList.toggle("phone",phone);document.documentElement.style.setProperty("--k",String(phoneScale));
129
129
  if(terminal&&terminal.options.fontSize!==Math.round(15*phoneScale)){terminal.options.fontSize=Math.round(15*phoneScale);refit();}
130
130
  }
131
- var view=0,sent={},listResize=null,terminal,fitAddon,socket=null,reconnect,observer,arrival=null,socketDown=false,lost=function(){},sender=Math.random().toString(36).slice(2)+Date.now().toString(36);
131
+ var view=0,sent={},listResize=null,terminal,fitAddon,socket=null,reconnect,observer,arrival=null,socketDown=false,reopened=null,lost=function(){},sender=Math.random().toString(36).slice(2)+Date.now().toString(36);
132
+ var REOPENED="A new CLI of this conversation — the one before is gone, and its screen was not kept.";
132
133
  var heard=window.bullseyeConnection.watch(function(){return socket;},function(alive){alive.send('{"kind":"ping"}');},function(dead){lost(dead);});
133
134
  sizePhone();window.addEventListener("resize",sizePhone);
134
135
  if(window.visualViewport){var fitKeyboard=function(){document.body.style.height=phone?visualViewport.height+"px":"";};visualViewport.addEventListener("resize",fitKeyboard);fitKeyboard();}
@@ -153,8 +154,8 @@ function tool(id,icon,label,cls,brief){var b=el("button",cls,icon);b.id=id;b.app
153
154
 
154
155
  function show(name,heading){
155
156
  view++;
156
- clearTimeout(reconnect);if(socket!==null){socket.onclose=null;socket.close();socket=null;}
157
- if(name!=="terminal"){socketDown=false;if(!gatewayDown)window.bullseyeConnection.live();if(observer){observer.disconnect();observer=null;}document.getElementById("keybar").hidden=true;if(terminal){terminal.dispose();terminal=null;}main.style.display="";main.style.flexDirection="";}
157
+ clearTimeout(reconnect);if(socket!==null){socket.onopen=socket.onmessage=socket.onerror=socket.onclose=null;socket.close();socket=null;}if(observer){observer.disconnect();observer=null;}if(terminal){terminal.dispose();terminal=null;}
158
+ if(name!=="terminal"){socketDown=false;if(!gatewayDown)window.bullseyeConnection.live();document.getElementById("keybar").hidden=true;main.style.display="";main.style.flexDirection="";tools.replaceChildren();}
158
159
  title.textContent=heading;
159
160
  var inList=name==="list";
160
161
  btnBack.hidden=inList||name==="signin";
@@ -175,7 +176,7 @@ function show(name,heading){
175
176
 
176
177
  function scoped(h){if(scope!==null)h["x-bullseye-project"]=scope;return h}function down(what,method,path){if(method==="GET"&&path==="/v1/conversations")window.bullseyeConnection.reconnecting(what,8000);else if(method==="GET"&&path==="/v1/panel")window.bullseyeConnection.reconnecting(what,5000);else if(method==="GET"&&path.indexOf("/v1/terminals/")===0)window.bullseyeConnection.reconnecting(what,1000);}
177
178
  async function reach(method,path,body,signal){var response;try{response=await fetch(path,{method:method,headers:scoped({authorization:"Bearer "+token,"content-type":"application/json"}),body:body===undefined?undefined:JSON.stringify(body),signal:signal});}catch(e){if(e.name!=="AbortError")down("the connection to the Notify service",method,path);throw e;}if(response.status>=502)down("the connection to the Notify service (HTTP "+response.status+")",method,path);else if(!socketDown)window.bullseyeConnection.live();return response;}
178
- async function api(method,path,body,signal){var response=await reach(method,path,body,signal);var data=await response.json();if(!response.ok){if(response.status===401)signIn("Sign in again to reach your CLI.");var error=Error(data.error||"Request failed");error.status=response.status;throw error;}return data;}
179
+ async function api(method,path,body,signal){var response=await reach(method,path,body,signal);var data=await told(response);if(!response.ok){if(response.status===401)signIn("Sign in again to reach your CLI.");var error=Error(data.error||"Request failed");error.status=response.status;throw error;}return data;}
179
180
  function fail(error){liveNotice(plainWhy(error),"error");}
180
181
  function ordered(id,act,body){if(!socket||socket.readyState!==WebSocket.OPEN)return;socket.send(JSON.stringify(Object.assign({kind:act},body)));}
181
182
  /** The last folder of a path, so a row names its project without printing the whole path. */
@@ -379,7 +380,7 @@ async function cliAttach(id,origin){
379
380
  liveNotice("⏳ Getting "+name+" from the CLI machine…");
380
381
  try{
381
382
  var response=await reach("GET","/v1/terminals/"+id+"/file?path="+encodeURIComponent(path));
382
- if(!response.ok){var refused=await response.json();if(response.status===401)signIn("Sign in again to reach your CLI.");throw Error(refused.error||"the gateway answered "+response.status);}
383
+ if(!response.ok){var refused=await told(response);if(response.status===401)signIn("Sign in again to reach your CLI.");throw Error(refused.error||"the gateway answered "+response.status);}
383
384
  var address=URL.createObjectURL(await response.blob()),link=el("a");link.href=address;link.download=name;document.body.append(link);link.click();link.remove();setTimeout(function(){URL.revokeObjectURL(address);},60000);
384
385
  if(mine===view)liveNotice("Saved "+name+" to this device's downloads.");
385
386
  }catch(error){if(mine===view)liveNotice("Not saved — "+plainWhy(error),"error");}
@@ -396,7 +397,7 @@ async function cliAttach(id,origin){
396
397
  var response=await reach("GET","/v1/terminals/"+id+"/file?path="+encodeURIComponent(path));
397
398
  if(mine!==view||said.parentNode!==sheet)return;
398
399
  if(response.status===401){signIn("Sign in again to reach your CLI.");return;}
399
- if(!response.ok){said.className="err";said.textContent="⚠️ "+((await response.json()).error||"the gateway answered "+response.status);return;}
400
+ if(!response.ok){said.className="err";said.textContent="⚠️ "+((await told(response)).error||"the gateway answered "+response.status);return;}
400
401
  if(!(response.headers.get("content-type")||"").includes("json")){
401
402
  var name=base(path);
402
403
  var address=URL.createObjectURL(await response.blob()),link=el("a");link.href=address;link.download=name;document.body.append(link);link.click();link.remove();setTimeout(function(){URL.revokeObjectURL(address);},60000);
@@ -434,7 +435,7 @@ async function cliAttach(id,origin){
434
435
  },true);
435
436
  var keybar=document.getElementById("keybar"),ctrlHeld=false,ctrlKey=null;
436
437
  function disarm(){ctrlHeld=false;ctrlKey.classList.remove("armed");}
437
- var unacked=[],inputs=0,from=sender+"."+mine;function typed(body){inputs+=1;var sent={id:inputs,frame:JSON.stringify(Object.assign({kind:"input",from:from,id:inputs},body))};unacked.push(sent);if(socket!==null&&socket.readyState===WebSocket.OPEN)socket.send(sent.frame);}
438
+ var unacked=[],inputs=0,from=sender+"."+mine;function typed(body){if(term.options.disableStdin){liveNotice("Not sent — this CLI is no longer connected. Press 🔌 Reattach.","error");return;}inputs+=1;var sent={id:inputs,frame:JSON.stringify(Object.assign({kind:"input",from:from,id:inputs},body))};unacked.push(sent);if(socket!==null&&socket.readyState===WebSocket.OPEN)socket.send(sent.frame);}
438
439
  function sendKey(data){if(ctrlHeld){disarm();data=ctrlBarSeq(data);}typed({data:data});}
439
440
  keybar.replaceChildren();keybar.hidden=false;
440
441
  [NEW_LINE].concat(KEY_BAR.slice(0,7),[{id:"ctrl",label:"Ctrl",title:"Ctrl (sticky)"}],KEY_BAR.slice(7)).forEach(function(key){
@@ -448,6 +449,8 @@ async function cliAttach(id,origin){
448
449
  refit=function(){if(mine!==view||!socket||socket.readyState!==WebSocket.OPEN||host.clientWidth===0||host.clientHeight===0)return;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});};
449
450
  if(observer)observer.disconnect();observer=new ResizeObserver(refit);host.addEventListener("pointerdown",refit);host.addEventListener("touchstart",refit,{passive:true});var wake=function(){if(!document.hidden)refit();},off=observer.disconnect.bind(observer);window.addEventListener("focus",wake);document.addEventListener("visibilitychange",wake);observer.disconnect=function(){window.removeEventListener("focus",wake);document.removeEventListener("visibilitychange",wake);off();};
450
451
  reattach.onclick=function(){cliAttach(id,origin);};
452
+ if(reopened!==null&&reopened.id===id)liveNotice(REOPENED+(reopened.unsent?" What you typed while it was away was not sent.":""),"hint");
453
+ reopened=null;
451
454
  close.onclick=async function(){close.disabled=true;try{await api("DELETE","/v1/terminals/"+id);swap("list");}catch(error){close.disabled=false;fail(error);}};
452
455
  observer.observe(host);
453
456
  var WHAT="the terminal connection to the CLI",reattached=false;
@@ -474,7 +477,7 @@ async function cliAttach(id,origin){
474
477
  if(mine!==view)return;
475
478
  if(error.status===401)return;
476
479
  if(error.status!==404)return later();
477
- api("POST","/v1/terminals",{conversation:id,cols:term.cols,rows:term.rows},AbortSignal.timeout(START_MS)).then(function(started){if(mine!==view)return;if(started.id!==id){swap("term",started.id);return;}connect();},function(failure){
480
+ api("POST","/v1/terminals",{conversation:id,cols:term.cols,rows:term.rows},AbortSignal.timeout(START_MS)).then(function(started){if(mine!==view)return;if(started.id!==id){reopened={id:started.id,unsent:unacked.length>0};swap("term",started.id);return;}liveNotice(REOPENED,"hint");connect();},function(failure){
478
481
  if(mine!==view)return;
479
482
  if(failure.status!==404)return later();
480
483
  swap("term",id);