@linxin666/dsh-remote-bridge 0.4.12 → 0.4.13

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.
Files changed (59) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +45 -8
  3. package/README.zh.md +45 -8
  4. package/lib/client.js +1 -1
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +18031 -373
  7. package/lib/types/core/connection.d.ts +9 -0
  8. package/lib/types/core/devices.d.ts +27 -6
  9. package/lib/types/core/liveactivity.d.ts +7 -0
  10. package/lib/types/core/model-efforts.d.ts +83 -0
  11. package/lib/types/core/protocol.d.ts +2 -0
  12. package/lib/types/core/push.d.ts +51 -2
  13. package/lib/types/host/firewall.d.ts +74 -0
  14. package/lib/types/host/host-bind-capability.d.ts +90 -0
  15. package/lib/types/host/ingress-gate.d.ts +59 -0
  16. package/lib/types/host/ingress-sync.d.ts +429 -0
  17. package/lib/types/host/lan-bind-plan.d.ts +96 -0
  18. package/lib/types/host/lan-bind.d.ts +106 -0
  19. package/lib/types/host/lan-forward.d.ts +112 -0
  20. package/lib/types/host/lan.d.ts +61 -0
  21. package/lib/types/host/pair-origin.d.ts +34 -19
  22. package/lib/types/host/relay-bridge-connector.d.ts +215 -0
  23. package/lib/types/host/relay-connector.d.ts +152 -0
  24. package/lib/types/host/relay-control.d.ts +124 -0
  25. package/lib/types/host/relay-registry.d.ts +114 -0
  26. package/lib/types/host/relay.d.ts +170 -0
  27. package/lib/types/host/routes.d.ts +24 -1
  28. package/lib/types/host/tunnel-orphan.d.ts +145 -0
  29. package/lib/types/host/tunnel-plan.d.ts +41 -0
  30. package/lib/types/host/tunnel.d.ts +289 -0
  31. package/lib/types/index.d.ts +426 -1
  32. package/package.json +4 -2
  33. package/src/client/panel.module.css +16 -1
  34. package/src/core/connection.ts +206 -11
  35. package/src/core/devices.ts +31 -6
  36. package/src/core/hub.ts +17 -5
  37. package/src/core/liveactivity.ts +16 -2
  38. package/src/core/model-efforts.ts +223 -0
  39. package/src/core/protocol.ts +3 -0
  40. package/src/core/push.ts +70 -4
  41. package/src/host/firewall.ts +230 -0
  42. package/src/host/host-bind-capability.ts +249 -0
  43. package/src/host/ingress-gate.ts +203 -0
  44. package/src/host/ingress-sync.ts +1074 -0
  45. package/src/host/lan-bind-plan.ts +134 -0
  46. package/src/host/lan-bind.ts +250 -0
  47. package/src/host/lan-forward.ts +321 -0
  48. package/src/host/lan.ts +142 -0
  49. package/src/host/pair-origin.ts +44 -38
  50. package/src/host/relay-bridge-connector.ts +783 -0
  51. package/src/host/relay-connector.ts +317 -0
  52. package/src/host/relay-control.ts +224 -0
  53. package/src/host/relay-registry.ts +263 -0
  54. package/src/host/relay.ts +294 -0
  55. package/src/host/routes.ts +47 -3
  56. package/src/host/tunnel-orphan.ts +325 -0
  57. package/src/host/tunnel-plan.ts +58 -0
  58. package/src/host/tunnel.ts +688 -0
  59. package/src/index.ts +1280 -22
@@ -36,6 +36,17 @@
36
36
  * @module @linxin666/dsh-remote-bridge
37
37
  */
38
38
  import type { Context } from '@deepseek-ai/cordis';
39
+ import { type FirewallSummary } from './host/firewall.ts';
40
+ import { type ConfigSchemaFactory } from './host/host-bind-capability.ts';
41
+ import { type IngressSyncInput } from './host/ingress-sync.ts';
42
+ import { type ForwardPlan, type ForwardStopReason, type LanBindCapability } from './host/lan-bind-plan.ts';
43
+ import { type LegacyBlockCleanup } from './host/lan-bind.ts';
44
+ import { type LanForwardState } from './host/lan-forward.ts';
45
+ import { type RelayClaim, type RelayConnectorMode } from './host/relay-control.ts';
46
+ import { type RelayBridgeStart, type RelayConnectorPairOptions } from './host/relay-connector.ts';
47
+ import { RelayRegistrar, type RelayIdentity, type RelayState } from './host/relay-registry.ts';
48
+ import { type TunnelPhase } from './host/tunnel.ts';
49
+ import { type TunnelPlan } from './host/tunnel-plan.ts';
39
50
  /** Loader row identity of this plugin. */
40
51
  export declare const name = "remote-bridge";
41
52
  /**
@@ -48,6 +59,13 @@ export declare const name = "remote-bridge";
48
59
  export declare const inject: string[];
49
60
  /** Where the paired-device roster lives inside the DSH home. */
50
61
  export declare const ROSTER_PATH = "remote-bridge/devices.json";
62
+ /**
63
+ * Where this host remembers one reasoning level per model.
64
+ *
65
+ * Beside the roster, and for the same reason: it belongs to this bridge rather
66
+ * than to any one session, and it outlives every process (core/model-efforts.ts).
67
+ */
68
+ export declare const EFFORT_PATH = "remote-bridge/model-efforts.json";
51
69
  /** The environment variable that moves the offline claim window (§32.2). */
52
70
  export declare const OFFLINE_CLAIM_TTL_ENV = "DSH_REMOTE_BRIDGE_OFFLINE_CLAIM_TTL_MS";
53
71
  /**
@@ -81,6 +99,413 @@ export declare const TURN_END_QUIET_MAX_ENV = "DSH_REMOTE_BRIDGE_TURN_END_QUIET_
81
99
  * @returns the report point in milliseconds.
82
100
  */
83
101
  export declare function turnEndQuietMaxWait(env?: NodeJS.ProcessEnv): number;
102
+ /**
103
+ * 桥的配置面。
104
+ *
105
+ * 字段名与 `dsh-remote-web-ui` 逐字一致,所以现有 profile YAML 可以直接沿用;本包
106
+ * 没有 schema 依赖,缺省值由 {@link resolveBridgeConfig} 补齐,没写的字段一律按
107
+ * 缺省处理(不新增开关)。
108
+ */
109
+ export interface Config {
110
+ /** 是否申领 relay 租约(默认 true)。关掉就只有本机的回环入口可用。 */
111
+ relay?: boolean;
112
+ /** 是否起快速隧道(默认 false):隧道目标永远是入站闸门,不是 webServer。 */
113
+ autoTunnel?: boolean;
114
+ /** 隧道令牌:命名隧道用它跑 cloudflared。 */
115
+ tunnelToken?: string;
116
+ /** 命名隧道的固定公网基址(https://host[:port])。 */
117
+ publicBaseUrl?: string;
118
+ /** 受管 profile;缺省取 $DSH_PROFILE,再缺省 'desktop'。 */
119
+ profile?: string;
120
+ /** 局域网绑定开关;不设即关(老插件同义:只有 true 才开边缘)。 */
121
+ lanBind?: boolean;
122
+ /** 是否把命名隧道的 ingress 服务端口同步到本机(默认 false)。 */
123
+ ingressSync?: boolean;
124
+ /** Cloudflare 账户级 API 令牌(ingress-sync 用,默认 undefined)。 */
125
+ cfApiToken?: string;
126
+ /** Cloudflare 账户 id(默认 undefined)。 */
127
+ cfAccountId?: string;
128
+ /** 命名隧道 id(默认 undefined)。 */
129
+ cfTunnelId?: string;
130
+ }
131
+ /** 配置面补齐缺省值后的样子:每个字段都是调用方可以直接用的值。 */
132
+ export interface ResolvedBridgeConfig {
133
+ relay: boolean;
134
+ autoTunnel: boolean;
135
+ tunnelToken: string | undefined;
136
+ publicBaseUrl: string | undefined;
137
+ profile: string;
138
+ lanBind: boolean | undefined;
139
+ ingressSync: boolean;
140
+ cfApiToken: string | undefined;
141
+ cfAccountId: string | undefined;
142
+ cfTunnelId: string | undefined;
143
+ }
144
+ /**
145
+ * 把行配置补齐成桥要用的完整配置面。
146
+ * @param raw - loader 交给插件的行配置(字段名与老插件一致)。
147
+ * @param env - 进程环境,注入给测试。
148
+ * @returns 每个字段都有确定取值的配置。
149
+ */
150
+ export declare function resolveBridgeConfig(raw: unknown, env?: NodeJS.ProcessEnv): ResolvedBridgeConfig;
151
+ /**
152
+ * 端口没绑上时的重新规划间隔。
153
+ *
154
+ * 一次 recompose 可以让 apply 跑到监听器 bind 之前,所以隧道、租约与局域网边缘都
155
+ * 可能拿到未落定的端口;这个间隔就是老插件 PORT_SETTLE_RETRY_MS 的语义。
156
+ */
157
+ export declare const PORT_SETTLE_RETRY_MS = 1000;
158
+ /** 一次性重试计时器的注入面(测试给假时钟)。 */
159
+ export interface PortSettleTimer {
160
+ setTimeout(fn: () => void, ms: number): unknown;
161
+ clearTimeout(handle: unknown): void;
162
+ }
163
+ /** 端口落定之前的那一个重试计时器。 */
164
+ export interface PortSettleRetry {
165
+ /** 请求一次「端口落定后重来」;已经排着一个就什么都不做,回 false。 */
166
+ request(): boolean;
167
+ /** 端口落定了:丢掉排着的那个,下一次未落定重新计时、重新告警。 */
168
+ reset(): void;
169
+ /** 卸载:丢掉排着的那个,之后的请求不再排。 */
170
+ dispose(): void;
171
+ /** 此刻是否排着一个重试。 */
172
+ readonly pending: boolean;
173
+ }
174
+ /**
175
+ * 建一个端口落定前的一次性重试计划。
176
+ *
177
+ * 全进程只该有一个这样的计划:隧道、租约与 ingress-sync 共用一个,否则每次未落定
178
+ * 都会多排一个计时器,端口落定后一起回放成重复的申领与重复的隧道启动。
179
+ * @param options - 重试动作、间隔、计时器与告警落点。
180
+ * @returns 计划本身。
181
+ */
182
+ export declare function createPortSettleRetry(options: {
183
+ onRetry: () => void;
184
+ retryMs?: number;
185
+ timer?: PortSettleTimer;
186
+ warn?: (message: string) => void;
187
+ }): PortSettleRetry;
188
+ /** 端口落定之后,一次规划需要的全部事实。 */
189
+ export interface BridgeWiringFacts {
190
+ /** 补齐缺省值后的配置面。 */
191
+ readonly config: ResolvedBridgeConfig;
192
+ /** 入站闸门的端口:隧道、租约与局域网边缘都指向它,不是 webServer 的端口。 */
193
+ readonly gatePort: number | undefined;
194
+ /** 宿主/CLI 给出的启动绑定(局域网边缘的 yield 判据)。 */
195
+ readonly startupHost?: string;
196
+ /** 本机可以监听的局域网 IPv4 字面量。 */
197
+ readonly candidates?: readonly string[];
198
+ /** 安装的 webserver schema 是否接受通配绑定(只上报,从不写)。 */
199
+ readonly wildcardSupported?: boolean;
200
+ }
201
+ /** 一次规划的产物:隧道、租约、局域网边缘与 ingress-sync 各自的输入。 */
202
+ export interface BridgeWiringPlan {
203
+ /** 端口还没落定:隧道、租约与转发器都要等它。 */
204
+ readonly awaitPort: boolean;
205
+ /** 隧道计划;快速隧道在端口未落定时是 undefined,绝不计划一个未落定的目标。 */
206
+ readonly tunnel: TunnelPlan | undefined;
207
+ /** 这次是否发起租约申领。它与隧道计划无关:无隧道时也必须申领。 */
208
+ readonly claim: boolean;
209
+ /** 局域网边缘计划:听哪个地址,或者为什么必须关着。 */
210
+ readonly forward: ForwardPlan;
211
+ /** ingress-sync 的输入:端口未落定时是一次零请求等待。 */
212
+ readonly ingress: IngressSyncInput;
213
+ }
214
+ /**
215
+ * 把一份配置与一个闸门端口规划成四件事:隧道、租约、局域网边缘、ingress-sync。
216
+ *
217
+ * 三处「不是 webServer 端口」都在这里落定:快速隧道的目标 URL、租约申领的端口、
218
+ * ingress-sync 要收敛到的服务端口,全部是闸门端口,公网侧因此只看见 /ios/v1。
219
+ * @param facts - 配置、闸门端口与局域网能力。
220
+ * @returns 这次应该做的事。
221
+ */
222
+ export declare function bridgeWiringPlanOf(facts: BridgeWiringFacts): BridgeWiringPlan;
223
+ /** 一次租约申领的触发面。 */
224
+ export interface LeaseClaimer {
225
+ /** 申领一次;同一把端口/目标键重复调用不发请求。 */
226
+ claim(port: number | undefined, target?: string): boolean;
227
+ /** 这个进程已经申领过的那把键。 */
228
+ readonly key: string | undefined;
229
+ /** 卸载:之后的申领请求一概不发。 */
230
+ dispose(): void;
231
+ }
232
+ /**
233
+ * 建一个去重的租约申领器。
234
+ *
235
+ * 申领只有这一个出口:无隧道分支、端口落定重试、隧道换 URL 都走它,键相同就不
236
+ * 重复申领,否则一个设置同步循环就会把租约的 last_seen 刷成噪声。
237
+ * @param options - 申领动作与失败落点。
238
+ * @returns 申领器。
239
+ */
240
+ export declare function createLeaseClaimer(options: {
241
+ start: (input: {
242
+ port: number;
243
+ }) => Promise<unknown>;
244
+ log?: (message: string) => void;
245
+ }): LeaseClaimer;
246
+ /** 一次已接受的租约应该起哪些连接器。 */
247
+ export interface LeaseConnectorWants {
248
+ /** 命名连接器:只在快速隧道计划下起,别在操作员背后再跑一条 cloudflared。 */
249
+ readonly named: boolean;
250
+ /** 桥连接器:租约带 bridge 授权就起,与隧道计划无关。 */
251
+ readonly bridge: boolean;
252
+ }
253
+ /**
254
+ * 计划与租约决定的两件事,一处算清。
255
+ * @param plan - 当前的隧道计划(未落定时 undefined)。
256
+ * @param claim - 控制面接受的租约。
257
+ * @returns 该起哪些连接器。
258
+ */
259
+ export declare function leaseConnectorWants(plan: TunnelPlan | undefined, claim: RelayClaim): LeaseConnectorWants;
260
+ /**
261
+ * 租约连接器的启动器对:命名连接器读隧道计划,桥连接器只读租约。
262
+ *
263
+ * 两个启动器都可注入,所以「计划 × 租约」的整张表可以直接驱动真实的
264
+ * RelayConnectorPair,而不必把插件挂到一个活宿主上。
265
+ * @param options - 计划读取器与两个真实启动器。
266
+ * @returns RelayConnectorPair 要的那几个 seam。
267
+ */
268
+ export declare function leaseConnectorSeams(options: {
269
+ plan: () => TunnelPlan | undefined;
270
+ startNamed: (token: string, hostname: string) => void;
271
+ startBridge: (start: RelayBridgeStart) => void;
272
+ stopNamed?: () => void;
273
+ stopBridge?: () => void;
274
+ log?: (message: string) => void;
275
+ }): RelayConnectorPairOptions;
276
+ /** 一次隧道状态给出的注册事实。 */
277
+ export interface RelayAnnounceFacts {
278
+ /** relay 开关:关掉时不但不注册,还要把 Worker 上那行撤掉。 */
279
+ readonly relay: boolean;
280
+ /** 当前的隧道计划模式。 */
281
+ readonly mode: TunnelPlan['mode'] | undefined;
282
+ /** 隧道 running 时报出的 URL;没 running 就是 undefined。 */
283
+ readonly url: string | undefined;
284
+ }
285
+ /**
286
+ * 这次的隧道状态该把哪个 URL 注册给 Worker,或者什么都不注册。
287
+ *
288
+ * 只有快速隧道需要注册:Worker 靠注册表里那条 URL 把稳定子域名代理到本机。命名
289
+ * 隧道有自己的固定主机名、桥模式有自己的传输,两者都不写这行。
290
+ * @param facts - 隧道计划、它报出的 URL 与 relay 开关。
291
+ * @returns 要注册的 target,或 undefined。
292
+ */
293
+ export declare function relayAnnounceTargetOf(facts: RelayAnnounceFacts): string | undefined;
294
+ /** Worker 上那行「稳定子域名 -> 本机隧道」的注册,只有一个出口。 */
295
+ export interface RelayAnnouncer {
296
+ /** 隧道计划、它报出的 URL 或 relay 开关变了就调一次。 */
297
+ sync(facts: RelayAnnounceFacts): void;
298
+ /** 注册成功的那个 target;undefined 表示 Worker 上还没有指向本机的行。 */
299
+ readonly registered: string | undefined;
300
+ /** 卸载:停掉重试;`unregister` 时连 Worker 上那行一并撤掉。 */
301
+ dispose(unregister?: boolean): void;
302
+ }
303
+ /**
304
+ * 建一个 announcer。
305
+ *
306
+ * 语义对齐老插件的 ensureRelayRegistrar / announceRelay / disposeRelayAnnouncer:
307
+ * 同一 target 只注册一次(隧道崩溃重启会报一个新 URL,那时才重新注册);失败只记
308
+ * 一行、由 registrar 自己退避重试,绝不冒成异常阻断隧道;relay 从开到关时撤掉那
309
+ * 一行,免得稳定子域名指向一个已经关掉的宿主。
310
+ *
311
+ * 注册上去的 URL 就是隧道的目标,而隧道的目标是入站闸门,所以这一行只透出
312
+ * `/ios/v1`:announcer 不会把宿主的路由表暴露给公网。
313
+ * @param options - 身份来源(懒读,只有真要注册时才碰 DSH home)与失败落点。
314
+ * @returns announcer 本身。
315
+ */
316
+ export declare function createRelayAnnouncer(options: {
317
+ identity: () => RelayIdentity | undefined;
318
+ registrar?: (identity: RelayIdentity, onState: (state: RelayState) => void) => RelayRegistrar;
319
+ log?: (message: string) => void;
320
+ }): RelayAnnouncer;
321
+ /** relay 半区的开关:打开时由计划驱动,关掉时撤行并释放租约。 */
322
+ export interface RelayHalfSwitch {
323
+ /** 关掉一次:撤掉 Worker 上那行注册、释放租约、随后 dispose;重复调用是空操作。 */
324
+ off(): void;
325
+ /** 卸载:不撤行也不释放,只停重试(那一行是手机的收藏地址,由服务端 GC 回收)。 */
326
+ dispose(): void;
327
+ }
328
+ /**
329
+ * 建一个 relay 半区的开关。
330
+ *
331
+ * 对齐老插件 `disposeRelayHalf(true)` 的语义:relay 从开到关时先撤注册行、再
332
+ * `pair.release()` 释放租约,最后 dispose;两步失败都只记一行,绝不冒成异常。与
333
+ * 卸载严格分开——卸载只 `dispose()`,既不放租约也不撤行,否则一次重启就会把手机
334
+ * 收藏的稳定地址抹掉。
335
+ * @param parts - announcer、租约半区与失败落点。
336
+ * @returns 开关本身。
337
+ */
338
+ export declare function createRelayHalfSwitch(parts: {
339
+ announcer: RelayAnnouncer;
340
+ /** 租约半区:懒建(端口落定之后才存在),所以按读取时刻取。 */
341
+ pair?: () => {
342
+ release(): Promise<void>;
343
+ dispose(): void;
344
+ } | undefined;
345
+ log?: (message: string) => void;
346
+ }): RelayHalfSwitch;
347
+ /** 一次实时地址判断要的事实。 */
348
+ export interface LivePublicOriginFacts {
349
+ /** 已接受的租约:控制面决定的 mode 与 hostname。 */
350
+ readonly lease: {
351
+ readonly mode: RelayConnectorMode;
352
+ readonly hostname: string;
353
+ } | undefined;
354
+ /** relay 注册成功的那个 target;undefined 表示还没成功。 */
355
+ readonly registered: string | undefined;
356
+ /** 隧道此刻的阶段与 URL。 */
357
+ readonly tunnel: {
358
+ readonly phase: TunnelPhase;
359
+ readonly url?: string;
360
+ } | undefined;
361
+ }
362
+ /**
363
+ * 桥自己此刻的公网入口。
364
+ *
365
+ * 租约的稳定子域名只在它后面确实有人服务时才优先:bridge 与 named 各有自己的传输,
366
+ * quick 却要靠 Worker 把子域名代理到本机注册给它的那条隧道 URL——注册还没成功时那
367
+ * 条子域名指向离线页,二维码必须退回隧道自己报出的地址。判据只看「租约 mode 与注
368
+ * 册状态」这两个已定的事实,不读时钟,所以它不可能是竞态。
369
+ * @param facts - 租约、注册状态与隧道阶段。
370
+ * @returns 公网基址,或 undefined(此刻没有可拨的公网入口)。
371
+ */
372
+ export declare function livePublicOriginOf(facts: LivePublicOriginFacts): string | undefined;
373
+ /**
374
+ * 局域网兜底地址:只从局域网转发器自己报出的监听事实取值。
375
+ *
376
+ * 默认配置(lanBind 关、宿主绑回环)下本机的局域网地址上没有监听者,把那个字面量
377
+ * 写进二维码就是一个拨不通的地址。所以这里没有第二种来源:转发器说它在监听,就报它
378
+ * 绑定到的地址与端口(内核可能把 0 换成真实端口,它回报的那一对才是客户端能拨的);
379
+ * 转发器没在监听、或地址端口还没有落定,就没有兜底地址。也不另取地址列表里的第一个
380
+ * 去猜——猜出来的地址背后没有监听者。
381
+ * @param forward - 局域网转发器此刻的状态快照;undefined 表示这一行还没把转发器挂上。
382
+ * @returns 局域网地址与端口,或 undefined(此刻本机没有局域网监听者)。
383
+ */
384
+ export declare function lanOriginOf(forward: LanForwardState | undefined): {
385
+ address: string;
386
+ port: number;
387
+ } | undefined;
388
+ /**
389
+ * 一次采样:本机能监听哪些局域网地址,安装的 webserver schema 是否接受通配绑定。
390
+ * @param configOf - schema 工厂注入(测试用),缺省读已安装的那个包。
391
+ * @returns 规划局域网边缘要的能力。
392
+ */
393
+ export declare function lanBindCapabilityOf(configOf?: ConfigSchemaFactory): LanBindCapability;
394
+ /**
395
+ * 一个非回环绑定能被哪些 LAN 基址访问到。
396
+ *
397
+ * 通配绑定回答每个接口,所以每个候选各得一个基址(多网卡的机器可以挑手机真能到的
398
+ * 那张网);具体字面量只在它自己那里可达,因此只广告它一个。
399
+ * @param host - 活的绑定,或端口未落定时受管块里钉的地址。
400
+ * @param port - 绑定的端口。
401
+ * @returns 基址表,绑定留在本机时为空。
402
+ */
403
+ export declare function lanBasesOf(host: string | undefined, port: number): {
404
+ address: string;
405
+ base: string;
406
+ }[];
407
+ /** 局域网绑定状态帧要的事实,请求时刻读一次。 */
408
+ export interface LanBindFrameInput {
409
+ /** 受管 profile。 */
410
+ profile: string;
411
+ /** 开关:翻过是 true/false,没翻过是 undefined。 */
412
+ setting: boolean | undefined;
413
+ /** 旧版本受管块还钉着的地址(清理之前)。 */
414
+ blockHost: string | undefined;
415
+ /** 运行中 webServer 的活的绑定(这套设计里是回环)。 */
416
+ bindHost: string | undefined;
417
+ /** 局域网转发器的实时状态。 */
418
+ forward: LanForwardState;
419
+ /** 转发器为什么关着(开关要求它开时)。 */
420
+ forwardReason: ForwardStopReason | undefined;
421
+ /** 这个进程是否删掉了旧版本留下的块。 */
422
+ legacyBlockRemoved: boolean;
423
+ /** 已落定的端口。 */
424
+ port: number | undefined;
425
+ /** 安装的 webserver schema 接受什么(只上报,从不写)。 */
426
+ wildcardSupported: boolean;
427
+ /** 这个进程能监听的本机非回环 IPv4 字面量。 */
428
+ candidates: string[];
429
+ /** CLI 给出的启动绑定事实。 */
430
+ startupHost: string | undefined;
431
+ }
432
+ /**
433
+ * 局域网绑定状态帧,做成一个纯值,好让每个字段都有直接的单元覆盖。
434
+ *
435
+ * `bindHost` 是局域网客户端真正能拨的地址——转发器的监听器,或者操作员把
436
+ * `--host` 指到网络上时的活绑定——因为卡片就是拿它渲染「bind: host:port」的;
437
+ * `localBindHost` 把宿主进程自己的监听器并排留在旁边。
438
+ * @param input - 请求时刻读到的事实。
439
+ * @param firewallOf - 防火墙摘要读取器(测试注入)。
440
+ * @returns 设置卡读的那一帧。
441
+ */
442
+ export declare function lanBindFrameOf(input: LanBindFrameInput, firewallOf?: (port: number, lanOn: boolean) => FirewallSummary): Record<string, unknown>;
443
+ /** 旧版受管块的清理执行器:一个进程只清一次,而且只删不写。 */
444
+ export interface LegacyBlockCleaner {
445
+ /** 排一次清理(重复调用是空操作);清理在 defer 的回调里跑,不在调用方的帧里。 */
446
+ run(): void;
447
+ /** 已经跑出来的结论,供状态帧的 legacyBlockRemoved 读。 */
448
+ readonly cleanup: LegacyBlockCleanup | undefined;
449
+ }
450
+ /**
451
+ * 建一个旧版受管块清理执行器。
452
+ *
453
+ * 写入路径已经不存在了(局域网边缘是运行时转发器),留下的唯一一次文件操作就是
454
+ * 删掉旧版本写进 profile 的那个块。它必须离开调用方的帧:设置保存正握着宿主的
455
+ * 排他 HMR 事务,从那里直接写配置文件会让配置监视器重入同一事务(#1751/#1754)。
456
+ * 这个清理带一次性守卫,所以进程里最多碰一次文件,后面的重复调用是空操作。
457
+ * @param options - profile 读取器、删除动作、推迟动作与失败落点。
458
+ * @returns 清理执行器。
459
+ */
460
+ export declare function createLegacyBlockCleaner(options: {
461
+ profile: () => string;
462
+ remove?: (profile: string) => LegacyBlockCleanup;
463
+ defer?: (fn: () => void) => void;
464
+ log?: (message: string) => void;
465
+ }): LegacyBlockCleaner;
466
+ /** 入站栈的成员:它们互相之间的卸载次序是硬约束。 */
467
+ export interface BridgeIngressStack {
468
+ readonly ingress?: {
469
+ dispose(): void;
470
+ };
471
+ readonly forwarder?: {
472
+ stop(): unknown;
473
+ };
474
+ readonly connectors?: {
475
+ dispose(): void;
476
+ };
477
+ readonly tunnel?: {
478
+ dispose(): void;
479
+ };
480
+ readonly gate?: {
481
+ stop(): void;
482
+ };
483
+ }
484
+ /**
485
+ * 卸载整条入站栈,次序固定。
486
+ *
487
+ * 转发器先走(它持有局域网侧最外层的监听器),然后连接器(它们会把 socket 打回
488
+ * 闸门),再隧道,最后闸门——闸门必须是最后一个关的,否则前面几步会把还活着的
489
+ * 连接钉在一个已经不存在的上游上。一个成员抛错不影响后面几个。
490
+ * @param stack - 当前活着的成员。
491
+ * @param log - 卸载失败的落点。
492
+ * @returns 实际释放过的成员名,按释放次序。
493
+ */
494
+ export declare function disposeBridgeStack(stack: BridgeIngressStack, log?: (message: string) => void): string[];
495
+ /**
496
+ * 用一份已经存在的身份收掉上一次挂载留下的 relay 半区:先撤掉 Worker 上那行注册,
497
+ * 再释放一次租约。
498
+ *
499
+ * 设置是挂载时的快照,用户把 relay 改成 false 会让插件行重新挂载:旧 effect 的卸载按
500
+ * 设计不释放(那行是手机的收藏地址),新 effect 在 relay=false 下又不建租约半区,所以
501
+ * 真实路径上的释放只可能发生在这里。两步都是 best-effort,失败各记一行,绝不冒成异常
502
+ * ——一次挂载不该因为中继控制面不在线就失败。
503
+ * @param parts - 身份与失败落点。
504
+ */
505
+ export declare function retireStaleRelayHalfOf(parts: {
506
+ identity: RelayIdentity;
507
+ log?: (message: string) => void;
508
+ }): Promise<void>;
84
509
  /**
85
510
  * Mount the bridge.
86
511
  *
@@ -92,7 +517,7 @@ export declare function turnEndQuietMaxWait(env?: NodeJS.ProcessEnv): number;
92
517
  * disposes.
93
518
  * @param ctx - the plugin's context, carrying the gateway and web server.
94
519
  */
95
- declare function applyImpl(ctx: Context): void;
520
+ declare function applyImpl(ctx: Context, config?: unknown): void;
96
521
  /**
97
522
  * The plugin's mount point: {@link applyImpl} behind the family's
98
523
  * single-instance guard. The name is the npm package identity, which every
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-remote-bridge",
3
3
  "description": "DSH remote bridge: the host half serves protocol v1 over one exact /ios/v1 WebSocket route — session roster, history baseline, prompting, live turn increments with tool activity, interrupt, and in-process agent approval — to a device paired by a one-shot bootstrap token and a P-256 challenge-response, with the token endpoint admitted only from this machine; the browser half adds one sidebar-foot panel that shows that same one-shot token as a QR symbol and draws an interactive card inside the tool row without answering it, and adds no wire surface",
4
- "version": "0.4.12",
4
+ "version": "0.4.13",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -52,7 +52,9 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "qrcode.react": "^4.2.0"
55
+ "cloudflared": "^0.7.3",
56
+ "qrcode.react": "^4.2.0",
57
+ "yaml": "^2.8.2"
56
58
  },
57
59
  "peerDependencies": {
58
60
  "@deepseek-ai/dsh": ">=0.2.1-rc.3",
@@ -55,7 +55,9 @@
55
55
  background: transparent;
56
56
  color: var(--dsw-alias-label-secondary);
57
57
  cursor: pointer;
58
- /* Ahead of the update/remote stack in the shared footer-action seat. */
58
+ /* Rail stack: the trigger leads the seat, which is where a centered 36px
59
+ column reads best. The wide seat places it on the trailing edge instead —
60
+ see the wide rule below. */
59
61
  order: -1;
60
62
  transition: background-color var(--ds-transition-duration) ease, color var(--ds-transition-duration) ease;
61
63
  }
@@ -88,6 +90,19 @@
88
90
  outline-offset: var(--pair-focus-offset);
89
91
  }
90
92
 
93
+ /* Wide seat: the shell lays `sidebar.footer.action` out as a left-aligned row, so
94
+ a position in flow alone leaves this trigger at the row's leading edge. Ordering
95
+ it last and handing it the free space in front puts it on the trailing edge,
96
+ beside the seat's other occupants rather than ahead of them. Both halves are
97
+ needed: order alone would only place it next to the previous occupant. The
98
+ margin is scoped to the wide layout because the rail stacks the seat into a
99
+ centered column, where an auto inline margin would pull the icon off that
100
+ column's axis. */
101
+ .trigger[data-wide='wide'] {
102
+ order: 1;
103
+ margin-inline-start: auto;
104
+ }
105
+
91
106
  /* ── Rail seat geometry (official-shell compatibility) ──
92
107
 
93
108
  The shell renders `sidebar.footer.action` as a centered horizontal row, so