@linxin666/dsh-remote-bridge 0.4.10 → 0.4.12

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/src/index.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * - `approval/request` is claimed in-process while a paired device is connected,
14
14
  * and delegated (`next()`) in every other case, which the Host normalizes to
15
15
  * the fail-closed `'unavailable'`.
16
- * - `ui.present` is this bridge's own model tool (protocol §35): one whole
16
+ * - `ui_present` is this bridge's own model tool (protocol §35): one whole
17
17
  * self-contained page is announced as `ui.request` to the paired clients that
18
18
  * declared `ui.v1`, and the user's first action inside it comes back as that
19
19
  * tool call's result. `ui.event` settles it, `ui.list` reads the cards still
@@ -59,7 +59,7 @@ import { QuestionClaims } from './core/questions.ts'
59
59
  import { UiCards } from './core/ui.ts'
60
60
  import { WS_PATH } from './core/protocol.ts'
61
61
  import { SessionMeta, type SessionStoreFace, type SessionTitleFace, type WorkspacesFace } from './core/session-meta.ts'
62
- import { sessionQuietProbe, TURN_END_QUIET_MAX_MS, TurnEndQuietGate } from './core/turn-end-quiet.ts'
62
+ import { sessionQuietProbe, TURN_END_QUIET_REPORT_MS, TurnEndQuietGate } from './core/turn-end-quiet.ts'
63
63
  import { SessionPermissions, type ApprovalPolicyFace, type PermissionPresetsFace, type SandboxPolicyFace } from './core/session-permissions.ts'
64
64
  import { selectionOf, modelSelectionOf } from './core/connection.ts'
65
65
  import { UsageService, type CredentialStoreFace, type SessionRosterFace, type SessionRouteFace, type SettingsFace } from './core/usage.ts'
@@ -82,7 +82,7 @@ export const name = 'remote-bridge'
82
82
  * The Host services this plugin cannot run without.
83
83
  *
84
84
  * `tools` is what protocol §35 added: this bridge contributes one model tool of
85
- * its own (`ui.present`), so a host that composes no tool registry is a host where
85
+ * its own (`ui_present`), so a host that composes no tool registry is a host where
86
86
  * the card channel has no caller — the row simply does not mount here.
87
87
  */
88
88
  export const inject = ['typertGateway', 'webServer', 'tools']
@@ -108,25 +108,29 @@ export function offlineClaimTtl(env: NodeJS.ProcessEnv = process.env): number {
108
108
  return Number.isFinite(configured) && configured > 0 ? configured : OFFLINE_QUESTION_CLAIM_TTL_MS
109
109
  }
110
110
 
111
- /** The environment variable that moves how long a finished turn waits for its session to go quiet (§28). */
111
+ /**
112
+ * The environment variable that moves when a still-waiting turn end is reported (§28).
113
+ *
114
+ * The name is the one deployments already set and is kept as it is; what it moves is
115
+ * the point at which the bridge says it is still waiting, because the wait itself has
116
+ * no cap.
117
+ */
112
118
  export const TURN_END_QUIET_MAX_ENV = 'DSH_REMOTE_BRIDGE_TURN_END_QUIET_MAX_MS'
113
119
 
114
120
  /**
115
- * The quiet-wait budget this process runs with.
121
+ * The still-waiting report point this process runs with.
116
122
  *
117
- * The budget is the bridge's own constant and never a host fact, so a deployment
118
- * moves it here. A value that is missing, unreadable or not positive falls back to
119
- * the constant instead of closing the window: a zero budget would announce every
120
- * turn end at its frame, and an operator who wanted that would be turning push
121
- * off. The budget only bounds the wait — a session that does fall quiet inside it
122
- * is announced then, and one that does not is announced at the end with the
123
- * reason it was still busy.
123
+ * It is the bridge's own constant and never a host fact, so a deployment moves it
124
+ * here. A value that is missing, unreadable or not positive falls back to the
125
+ * constant: the point only decides when the log line saying the wait continues is
126
+ * written, and nothing about it can make the bridge announce work that is still
127
+ * running or withhold a turn end whose family is quiet.
124
128
  * @param env - the process environment, injectable for a suite.
125
- * @returns the budget in milliseconds.
129
+ * @returns the report point in milliseconds.
126
130
  */
127
131
  export function turnEndQuietMaxWait(env: NodeJS.ProcessEnv = process.env): number {
128
132
  const configured = Number(env[TURN_END_QUIET_MAX_ENV])
129
- return Number.isFinite(configured) && configured > 0 ? configured : TURN_END_QUIET_MAX_MS
133
+ return Number.isFinite(configured) && configured > 0 ? configured : TURN_END_QUIET_REPORT_MS
130
134
  }
131
135
 
132
136
  /** This machine's IANA time zone, or undefined when the platform has none. */
@@ -431,15 +435,17 @@ function applyImpl(ctx: Context): void {
431
435
  },
432
436
  })
433
437
  // The quiet gate both channels announce a finished turn through: §28's
434
- // notification and §29's card end wait for the host's own answer that nothing is
435
- // left running under that session — its own agent, any descendant, and any job
436
- // the host attributes to either. Inert while no key is configured, because both
437
- // channels are then off and no timer is worth arming.
438
+ // notification and §29's card end wait for the host's own answer that the session's
439
+ // whole family is quiet — the root its parent chain climbs to, every session under
440
+ // that root at any depth, and any job the host attributes to one of them. A family
441
+ // that stays busy is never announced, and a subagent session's own turn end is
442
+ // dropped unless the phone prompted it. Inert while no key is configured, because
443
+ // both channels are then off and no timer is worth arming.
438
444
  const turnEndQuiet = new TurnEndQuietGate({
439
445
  push,
440
446
  liveActivity,
441
447
  probe: sessionQuietProbe({ gateway: ctx.typertGateway, peer: ownerPeer, jobs }),
442
- maxWaitMs: turnEndQuietMaxWait(),
448
+ reportAfterMs: turnEndQuietMaxWait(),
443
449
  log,
444
450
  })
445
451
  // The bridge's own follow streams (§28/§29): a suspended phone has no socket,
@@ -541,7 +547,7 @@ function applyImpl(ctx: Context): void {
541
547
  }
542
548
  }, 'remote-bridge: protocol v1 routes')
543
549
 
544
- // §35 的模型工具:`ui.present` 把 agent 写的整页交给已配对的客户端,并在用户
550
+ // §35 的模型工具:`ui_present` 把 agent 写的整页交给已配对的客户端,并在用户
545
551
  // 动作时把结构化事件作为它自己的返回值交回。注册在 `ctx.effect` 里、返回
546
552
  // disposer,所以插件卸载时工具名随行消失,宿主工具表不会留下一根指向空实现的
547
553
  // 指针;`execute` 把 `exec.signal` 一路传到认领表,回合被取消时那张卡立刻结算。
@@ -549,9 +555,9 @@ function applyImpl(ctx: Context): void {
549
555
  const disposeTool = ctx.tools.register(createUiPresentTool({
550
556
  present: async (card, signal) => await hub.present(card, signal),
551
557
  }))
552
- log('model tool ui.present registered')
558
+ log('model tool ui_present registered')
553
559
  return () => { disposeTool() }
554
- }, 'remote-bridge: ui.present tool')
560
+ }, 'remote-bridge: ui_present tool')
555
561
 
556
562
  // 会话事件是 `usage.session` 唯一的来源:桥不读会话日志、也不回填历史,所以
557
563
  // 这个监听器挂上之前广播的事件不会有读数,宿主没广播过的窗口也不会被编出来。