@eduwork/dsh-remote-access 0.1.7 → 0.1.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # 变更记录 / Changelog
2
2
 
3
+ ## 0.1.8 — Unreleased
4
+
5
+ - 修复远程设备上机构模型一直加载失败(“Gateway authorization changed; start a new model request”),刷新页面也不恢复,电脑上却正常。中继与机构模型服务同域名时,电脑到中继的连接可能接着用一次模型请求留下的网络连接,那次请求的授权就带进了远程设备的所有请求,重新登录后它失效,模型列表随之失败。电脑到中继的连接现在不再沿用这份授权。只需更新电脑端,中继不用更新。
6
+
7
+ - Fix organization models that kept failing to load on remote devices ("Gateway authorization changed; start a new model request"), even after reloading, while the computer listed them. With the relay on the domain of the organization's model service, the computer's connection to the relay could take over a network connection a model request had left open, and every request from a remote device then carried that request's authorization, which no longer held once the member signed in again. The computer's relay connections no longer carry it over. Only computers need updating; the relay does not.
8
+
9
+ - 修复 iOS / iPadOS 16.4–18 上,远程界面里的菜单和卡片出现在窗口角落,而不在所点的按钮旁边:访问模式、模型选择、会话统计、Token 用量、上下文用量、本轮用量以及各处“更多”菜单都受影响。DSH 用 CSS 锚点定位摆放它们,Safari 从 iOS 26 才支持;远程网页现在会在浏览器不支持时自己把它们放到按钮旁边。只需更新中继,电脑端不用更新。
10
+
11
+ - Fix menus and cards in the remote interface on iOS / iPadOS 16.4–18 that appeared in a corner of the window instead of next to the control that opened them: access mode, model selection, session statistics, token usage, context usage, turn usage and the "more" menus. DSH places them with CSS anchor positioning, which Safari supports only from iOS 26; the remote web page now places them next to their controls when the browser cannot. Only the relay needs updating; computers do not.
12
+
13
+ - 远程设备现在可以使用侧边聊天。此前电脑拒绝远程设备开启和关闭侧边聊天,设备上反复提示“操作失败,请重试。”需要更新电脑端,中继不用更新;提示反复出现和提示文字看不清的问题由侧边聊天插件 `@eduwork/dsh-side-chat` 修复,电脑上的这个插件也要一并更新。
14
+
15
+ - Remote devices can now use side chats. The computer used to refuse to open or close one for a remote device, which then kept showing "Something went wrong. Try again." Computers need updating; the relay does not. The repeated and hard-to-read notice is fixed in the side chat plugin `@eduwork/dsh-side-chat`, which computers need to update as well.
16
+
3
17
  ## 0.1.7 — 2026-11-15
4
18
 
5
19
  - 修复 iOS / iPadOS 16.4–17.3 上远程界面白屏:配对成功、电脑上也显示已连接,但设备上什么都不显示。远程网页现在会补上这些系统缺少的浏览器功能,DSH 界面也能正常加载。低于 16.4 的系统会提示版本过低,不再白屏。只需更新中继,电脑端不用更新。
package/lib/index.js CHANGED
@@ -6203,7 +6203,7 @@ var require_noise = __commonJS({
6203
6203
  });
6204
6204
 
6205
6205
  // src/plugin.ts
6206
- import { AsyncLocalStorage } from "node:async_hooks";
6206
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
6207
6207
  import { createRequire } from "node:module";
6208
6208
  import { hostname as hostname3 } from "node:os";
6209
6209
  import { dirname as dirname3, join as join2 } from "node:path";
@@ -6447,6 +6447,9 @@ function createHostAdapter(dsh, distIndex) {
6447
6447
  };
6448
6448
  }
6449
6449
 
6450
+ // src/relay-link/link.ts
6451
+ import { AsyncLocalStorage } from "node:async_hooks";
6452
+
6450
6453
  // src/protocol/close-codes.ts
6451
6454
  var Close = {
6452
6455
  normal: 1e3,
@@ -6473,6 +6476,12 @@ var Close = {
6473
6476
  };
6474
6477
 
6475
6478
  // src/relay-link/link.ts
6479
+ var HostSocket = class extends WebSocket {
6480
+ #run = AsyncLocalStorage.snapshot();
6481
+ dispatchEvent(event) {
6482
+ return this.#run(() => super.dispatchEvent(event));
6483
+ }
6484
+ };
6476
6485
  var RelayLink = class {
6477
6486
  #options;
6478
6487
  #control;
@@ -6507,7 +6516,7 @@ var RelayLink = class {
6507
6516
  }
6508
6517
  #connect() {
6509
6518
  if (this.#retiring === void 0) this.#options.onState({ state: "connecting" });
6510
- const control = new WebSocket(this.#url(RELAY_PATHS.host));
6519
+ const control = new HostSocket(this.#url(RELAY_PATHS.host));
6511
6520
  this.#control = control;
6512
6521
  let expiresAt;
6513
6522
  control.addEventListener("message", ({ data }) => {
@@ -6573,7 +6582,7 @@ var RelayLink = class {
6573
6582
  this.#renewal = setTimeout(() => this.#renew(), delays[Math.min(this.#failures++, delays.length - 1)]);
6574
6583
  }
6575
6584
  #open(id) {
6576
- const socket = new WebSocket(this.#url(RELAY_PATHS.accept));
6585
+ const socket = new HostSocket(this.#url(RELAY_PATHS.accept));
6577
6586
  socket.addEventListener("open", () => {
6578
6587
  socket.send(JSON.stringify({ t: "accept", id }));
6579
6588
  this.#options.accept(socket);
@@ -7286,7 +7295,10 @@ var ALLOWED_ROUTES = /* @__PURE__ */ new Map([
7286
7295
  ["/api/changes.diff", ["GET"]],
7287
7296
  ["/api/session.export", ["GET", "HEAD"]],
7288
7297
  ["/api/session.markdown", ["GET", "HEAD"]],
7289
- ["/api/artifactPreview/file", ["GET", "HEAD"]]
7298
+ ["/api/artifactPreview/file", ["GET", "HEAD"]],
7299
+ // EduWork's side chat forks an existing session at a message, names the fork
7300
+ // and archives it on close: session/fork and workspace/archiveSession work.
7301
+ ["/api/eduwork/side-chat", ["POST"]]
7290
7302
  ]);
7291
7303
  var ALLOWED_CALLS = /* @__PURE__ */ new Map([
7292
7304
  ["settings/mutate", ({ ns, ops }) => {
@@ -27389,7 +27401,7 @@ var Config = z2.object({
27389
27401
  })
27390
27402
  });
27391
27403
  var STATE2 = () => dshHomePath("plugins", "dsh-remote-access", "state.json");
27392
- var loadContext = AsyncLocalStorage.snapshot();
27404
+ var loadContext = AsyncLocalStorage2.snapshot();
27393
27405
  var _revoke_dec, _decide_dec, _cancelInvite_dec, _createInvite_dec, _signIn_dec, _test_dec, _retry_dec, _status_dec, _a3, _init;
27394
27406
  var RemoteDevices = class extends (_a3 = TypertRemoteService, _status_dec = [Remote], _retry_dec = [Remote], _test_dec = [Remote], _signIn_dec = [Remote], _createInvite_dec = [Remote], _cancelInvite_dec = [Remote], _decide_dec = [Remote], _revoke_dec = [Remote], _a3) {
27395
27407
  constructor(ctx, config2) {
@@ -1 +1,4 @@
1
- "use strict";(()=>{Promise.withResolvers??=()=>{let t,e;return{promise:new Promise((r,o)=>{t=r,e=o}),resolve:t,reject:e}};AbortSignal.any??=t=>{let e=[...t],n=new AbortController,r=e.find(s=>s.aborted);if(r!==void 0)return n.abort(r.reason),n.signal;let o=s=>{for(let d of e)d.removeEventListener("abort",o);n.abort(s.target.reason)};for(let s of e)s.addEventListener("abort",o);return n.signal};URL.canParse??=(t,e)=>{try{return new URL(t,e),!0}catch{return!1}};var i=parent.remoteTunnel,a=new URL(document.baseURI);function u(t){let{name:e,code:n,message:r,details:o}=t,s=e==="TunnelStreamError";return Object.assign(new Error(r??"remote stream failed"),{dshRemoteStreamFailure:s?{kind:"remote",code:n,details:structuredClone(o)}:{kind:"carrier"}})}function c(t){let e=t.target?.closest?.("a[download]");if(t.defaultPrevented||!(e instanceof HTMLAnchorElement))return;let n=new URL(e.href);n.origin!==a.origin||!n.pathname.startsWith(a.pathname)||(t.preventDefault(),m(n,e.download).catch(r=>console.error("remote download failed",r)))}var l=HTMLAnchorElement.prototype.click;async function m(t,e){let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status} for ${t.pathname}`);let r=document.createElement("a");r.href=URL.createObjectURL(await n.blob()),r.download=e||f(n.headers.get("content-disposition")??"")||t.pathname.split("/").at(-1),l.call(r),setTimeout(()=>URL.revokeObjectURL(r.href),6e4)}function f(t){let e=/filename\*=UTF-8''([^;]+)/i.exec(t)?.[1];return e===void 0?/filename="?([^";]+)/i.exec(t)?.[1]:decodeURIComponent(e)}i!==void 0&&(document.documentElement.setAttribute("data-eduwork-remote",""),Object.assign(globalThis,{__DSH_TRANSPORT__:{async fetch(t,e){let n=new URL(t,a),r={method:e.method??"GET",url:`/${n.pathname.slice(a.pathname.length)}${n.search}`,headers:[...new Headers(e.headers)],...e.body!=null&&{body:await new Response(e.body).arrayBuffer()}},o=await i.fetch(r,e.signal);if("error"in o)throw new TypeError(o.error);return new Response(o.body.byteLength===0?null:o.body,{status:o.status,headers:o.headers})},async*openStream(t,e,n,r){try{for await(let o of i.openStream(t,e,n,r))yield structuredClone(o)}catch(o){throw n.aborted?n.reason:u(o)}}}}),addEventListener("click",c,!0),HTMLAnchorElement.prototype.click=function(){this.isConnected||this.addEventListener("click",c,{once:!0}),l.call(this)});})();
1
+ "use strict";(()=>{Promise.withResolvers??=()=>{let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}};AbortSignal.any??=e=>{let t=[...e],o=new AbortController,i=t.find(a=>a.aborted);if(i!==void 0)return o.abort(i.reason),o.signal;let r=a=>{for(let d of t)d.removeEventListener("abort",r);o.abort(a.target.reason)};for(let a of t)a.addEventListener("abort",r);return o.signal};URL.canParse??=(e,t)=>{try{return new URL(e,t),!0}catch{return!1}};var v="--eduwork-anchor-name",A="--eduwork-position-anchor",E=new Map([["anchor-name",v],["position-anchor",A]]),w=12,S=4,y="data-eduwork-anchored",T="--eduwork-anchored-top",L="--eduwork-anchored-left",k="--eduwork-anchored-max-width",C="--eduwork-anchored-max-height",W=`[${y}]{top:var(${T})!important;left:var(${L})!important;right:auto!important;bottom:auto!important}
2
+ [${y}~=narrow]{max-width:var(${k})!important}
3
+ [${y}~=short]{max-height:var(${C})!important}`;function $(e,t){let o=t+1;for(;o<e.length&&e[o]!==e[t];)o+=e[o]==="\\"?2:1;return o}function _(e){let t=[],o=0,i=0;for(let r=0;r<e.length;r++){let a=e[r];a==="\\"?r++:a==='"'||a==="'"?r=$(e,r):a==="("||a==="["?o++:a===")"||a==="]"?o--:a===","&&o===0&&(t.push(e.slice(i,r).trim()),i=r+1)}return t.push(e.slice(i).trim()),t}function q(e){let t=[],o=[],i=[],r=[],a="";for(let d=0;d<e.length;d++){let u=e[d];if(u==="/"&&e[d+1]==="*"){let h=e.indexOf("*/",d+2);d=h<0?e.length:h+1}else if(u==='"'||u==="'"){let h=$(e,d);a+=e.slice(d,h+1),d=h}else if(u==="\\")a+=e.slice(d,d+2),d++;else if(u==="{")r.push(a.trim()),a="";else if(u===";"||u==="}"){let[,h,m]=/^\s*(anchor-name|position-anchor)\s*:([^]*)$/.exec(a)??[];if(h!==void 0&&m!==void 0&&r.length>0){let f=E.get(h);t.push(`${r.join("{")}{${f}:${m.trim()}${"}".repeat(r.length)}`),(f===v?o:i).push(..._(r.at(-1)))}u==="}"&&r.pop(),a=""}else a+=u}return{css:t.join(`
4
+ `),anchors:o,cards:i}}function N(e,t,o){let i=o.height-w-S-e.bottom,r=e.top-S-w,a=t.height<=i,d=a===t.height<=r?i>=r:a,u=Math.max(0,d?i:r),h=Math.min(t.height,u),m=o.width-2*w,f=Math.min(t.width,m),R=e.left+e.right>o.width,b=Math.max(w,Math.min(R?e.right-f:e.left,o.width-w-f));return{top:d?e.bottom+S:e.top-S-h,left:b,...t.width>m&&{maxWidth:m},...t.height>u&&{maxHeight:u}}}function B(){for(let n of E.values())CSS.registerProperty({name:n,syntax:"*",inherits:!1});let e={anchors:new Set([`[style*="${v}"]`]),cards:new Set([`[style*="${A}"]`])},t=CSSStyleDeclaration.prototype,{setProperty:o,getPropertyValue:i,getPropertyPriority:r,removeProperty:a}=t,d=n=>E.get(n)??n;Object.assign(t,{setProperty(n,c,s){o.call(this,d(n),c,s)},getPropertyValue(n){return i.call(this,d(n))},getPropertyPriority(n){return r.call(this,d(n))},removeProperty(n){return a.call(this,d(n))}});for(let[n,c]of E)Object.defineProperty(t,n.replace(/-(\w)/g,(s,l)=>l.toUpperCase()),{configurable:!0,enumerable:!0,get(){return i.call(this,c)},set(s){o.call(this,c,s??"")}});let u=new WeakSet,h=n=>{let c=document.createElement("style");return u.add(c),c.textContent=n,c},m=(n,c)=>{let s=q(c);for(let l of s.anchors)CSS.supports(`selector(${l})`)&&e.anchors.add(l);for(let l of s.cards)CSS.supports(`selector(${l})`)&&e.cards.add(l);s.css!==""&&(n.after(h(s.css)),x())},f=n=>{u.has(n)||(n instanceof HTMLStyleElement?(u.add(n),m(n,n.textContent??"")):n instanceof HTMLLinkElement&&n.relList.contains("stylesheet")&&n.href!==""&&(u.add(n),fetch(n.href).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.text()}).then(c=>m(n,c),c=>console.error("anchor positioning fallback cannot read",n.href,c))))},R,b=new Set,j=n=>{n.removeAttribute(y);for(let c of[T,L,k,C])n.style.removeProperty(c);b.delete(n)},O=(n,c)=>{R??=document.head.appendChild(h(W)),b.add(n);let{style:s}=n;n.setAttribute(y,""),s.setProperty(T,"0px"),s.setProperty(L,"0px");let l=n.getBoundingClientRect(),g=document.documentElement,p=N(c.getBoundingClientRect(),l,{width:g.clientWidth,height:g.clientHeight});s.setProperty(T,`${p.top-l.top}px`),s.setProperty(L,`${p.left-l.left}px`),p.maxWidth!==void 0&&s.setProperty(k,`${p.maxWidth}px`),p.maxHeight!==void 0&&s.setProperty(C,`${p.maxHeight}px`),n.setAttribute(y,`${p.maxWidth===void 0?"":"narrow"} ${p.maxHeight===void 0?"":"short"}`.trim())},M=0,x=()=>{M||=requestAnimationFrame(I)},I=()=>{M=0;let n=new Map;for(let s of document.querySelectorAll([...e.anchors].join()))if(s.getClientRects().length!==0)for(let l of getComputedStyle(s).getPropertyValue(v).split(","))l.trim()!==""&&n.set(l.trim(),s);let c=new Map;for(let s of document.querySelectorAll([...e.cards].join())){let l=getComputedStyle(s),g=n.get(l.getPropertyValue(A).trim());g===void 0||s.contains(g)||s.getClientRects().length===0||l.visibility==="hidden"||l.position!=="fixed"&&l.position!=="absolute"||c.set(s,g)}for(let s of b)c.has(s)||j(s);for(let[s,l]of c)O(s,l);c.size>0&&x()};new MutationObserver(n=>{for(let c of n)for(let s of c.addedNodes)if(s instanceof Element){f(s);for(let l of s.querySelectorAll("style, link"))f(l)}x()}).observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]});for(let n of document.querySelectorAll("style, link"))f(n)}typeof CSS<"u"&&!CSS.supports("anchor-name","--a")&&typeof CSS.registerProperty=="function"&&B();var H=parent.remoteTunnel,P=new URL(document.baseURI);function F(e){let{name:t,code:o,message:i,details:r}=e,a=t==="TunnelStreamError";return Object.assign(new Error(i??"remote stream failed"),{dshRemoteStreamFailure:a?{kind:"remote",code:o,details:structuredClone(r)}:{kind:"carrier"}})}function U(e){let t=e.target?.closest?.("a[download]");if(e.defaultPrevented||!(t instanceof HTMLAnchorElement))return;let o=new URL(t.href);o.origin!==P.origin||!o.pathname.startsWith(P.pathname)||(e.preventDefault(),G(o,t.download).catch(i=>console.error("remote download failed",i)))}var D=HTMLAnchorElement.prototype.click;async function G(e,t){let o=await fetch(e);if(!o.ok)throw new Error(`HTTP ${o.status} for ${e.pathname}`);let i=document.createElement("a");i.href=URL.createObjectURL(await o.blob()),i.download=t||V(o.headers.get("content-disposition")??"")||e.pathname.split("/").at(-1),D.call(i),setTimeout(()=>URL.revokeObjectURL(i.href),6e4)}function V(e){let t=/filename\*=UTF-8''([^;]+)/i.exec(e)?.[1];return t===void 0?/filename="?([^";]+)/i.exec(e)?.[1]:decodeURIComponent(t)}H!==void 0&&(document.documentElement.setAttribute("data-eduwork-remote",""),Object.assign(globalThis,{__DSH_TRANSPORT__:{async fetch(e,t){let o=new URL(e,P),i={method:t.method??"GET",url:`/${o.pathname.slice(P.pathname.length)}${o.search}`,headers:[...new Headers(t.headers)],...t.body!=null&&{body:await new Response(t.body).arrayBuffer()}},r=await H.fetch(i,t.signal);if("error"in r)throw new TypeError(r.error);return new Response(r.body.byteLength===0?null:r.body,{status:r.status,headers:r.headers})},async*openStream(e,t,o,i){try{for await(let r of H.openStream(e,t,o,i))yield structuredClone(r)}catch(r){throw o.aborted?o.reason:F(r)}}}}),addEventListener("click",U,!0),HTMLAnchorElement.prototype.click=function(){this.isConnected||this.addEventListener("click",U,{once:!0}),D.call(this)});})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduwork/dsh-remote-access",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "End-to-end encrypted remote access to a DSH host through a self-hosted relay",
5
5
  "type": "module",
6
6
  "license": "MulanPSL-2.0 AND MIT",