@linxin666/dsh-remote-bridge 0.4.8 → 0.4.10

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 (72) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +75 -18
  3. package/README.zh.md +74 -18
  4. package/lib/client.js +783 -260
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +15849 -2913
  7. package/lib/types/client/PairEntry.d.ts +2 -2
  8. package/lib/types/client/PairPanel.d.ts +10 -2
  9. package/lib/types/client/UiPresentRow.d.ts +13 -0
  10. package/lib/types/client/icons.d.ts +5 -13
  11. package/lib/types/client/index.d.ts +4 -0
  12. package/lib/types/client/locales.d.ts +24 -15
  13. package/lib/types/client/semantic.d.ts +9 -5
  14. package/lib/types/client/toolview-slot.d.ts +68 -0
  15. package/lib/types/client/ui-card.d.ts +160 -0
  16. package/lib/types/core/commands.d.ts +59 -0
  17. package/lib/types/core/connection.d.ts +106 -0
  18. package/lib/types/core/devices.d.ts +102 -2
  19. package/lib/types/core/extension.d.ts +13 -0
  20. package/lib/types/core/hub.d.ts +129 -15
  21. package/lib/types/core/liveactivity.d.ts +324 -0
  22. package/lib/types/core/protocol.d.ts +328 -5
  23. package/lib/types/core/push.d.ts +186 -0
  24. package/lib/types/core/questions.d.ts +61 -9
  25. package/lib/types/core/session-meta.d.ts +55 -1
  26. package/lib/types/core/squads.d.ts +130 -0
  27. package/lib/types/core/turn-end-quiet.d.ts +135 -0
  28. package/lib/types/core/ui.d.ts +238 -0
  29. package/lib/types/core/usage-stats.d.ts +160 -0
  30. package/lib/types/core/usage.d.ts +294 -0
  31. package/lib/types/host/apns.d.ts +151 -0
  32. package/lib/types/host/squads-ledger.d.ts +39 -0
  33. package/lib/types/host/squads.d.ts +77 -0
  34. package/lib/types/host/ui-tools.d.ts +80 -0
  35. package/lib/types/host/usage-stats.d.ts +75 -0
  36. package/lib/types/host/watchers.d.ts +95 -0
  37. package/lib/types/index.d.ts +47 -3
  38. package/package.json +15 -14
  39. package/src/client/PairEntry.tsx +58 -31
  40. package/src/client/PairPanel.tsx +181 -97
  41. package/src/client/UiPresentRow.tsx +149 -0
  42. package/src/client/icons.tsx +17 -60
  43. package/src/client/index.ts +11 -0
  44. package/src/client/locales.ts +36 -24
  45. package/src/client/panel.module.css +239 -186
  46. package/src/client/semantic.ts +10 -6
  47. package/src/client/toolview-slot.ts +84 -0
  48. package/src/client/ui-card.ts +368 -0
  49. package/src/client/ui-present.module.css +87 -0
  50. package/src/core/commands.ts +95 -0
  51. package/src/core/connection.ts +811 -12
  52. package/src/core/devices.ts +337 -5
  53. package/src/core/extension.ts +20 -0
  54. package/src/core/hub.ts +518 -43
  55. package/src/core/liveactivity.ts +833 -0
  56. package/src/core/protocol.ts +370 -5
  57. package/src/core/push.ts +385 -0
  58. package/src/core/questions.ts +81 -10
  59. package/src/core/session-meta.ts +73 -1
  60. package/src/core/squads.ts +345 -0
  61. package/src/core/turn-end-quiet.ts +388 -0
  62. package/src/core/ui.ts +398 -0
  63. package/src/core/usage-stats.ts +424 -0
  64. package/src/core/usage.ts +937 -0
  65. package/src/core/wire.ts +8 -0
  66. package/src/host/apns.ts +320 -0
  67. package/src/host/squads-ledger.ts +105 -0
  68. package/src/host/squads.ts +206 -0
  69. package/src/host/ui-tools.ts +233 -0
  70. package/src/host/usage-stats.ts +155 -0
  71. package/src/host/watchers.ts +296 -0
  72. package/src/index.ts +327 -10
@@ -20,18 +20,41 @@ export const METHOD_SESSION_MODELS = 'session.models'
20
20
  export const METHOD_SESSION_SET_MODEL = 'session.setModel'
21
21
  export const METHOD_SESSION_CREATE = 'session.create'
22
22
  export const METHOD_SESSION_FORK = 'session.fork'
23
+ export const METHOD_SESSION_COMMANDS = 'session.commands'
24
+ export const METHOD_SESSION_COMMAND = 'session.command'
25
+ export const METHOD_SESSION_RENAME = 'session.rename'
26
+ export const METHOD_SESSION_PIN = 'session.pin'
27
+ export const METHOD_SESSION_UNPIN = 'session.unpin'
28
+ export const METHOD_SESSION_ARCHIVE = 'session.archive'
29
+ export const METHOD_SESSION_UNARCHIVE = 'session.unarchive'
30
+ export const METHOD_WORKSPACE_LIST = 'workspace.list'
23
31
  export const METHOD_PRESETS_LIST = 'presets.list'
24
32
  export const METHOD_PAIR_BEGIN = 'pair.begin'
25
33
  export const METHOD_PAIR_FINISH = 'pair.finish'
26
34
  export const METHOD_APPROVAL_RESOLVE = 'approval.resolve'
27
35
  export const METHOD_QUESTION_ANSWER = 'question.answer'
36
+ export const METHOD_QUESTION_LIST = 'question.list'
28
37
  export const METHOD_JOBS_LIST = 'jobs.list'
38
+ export const METHOD_SQUADS_STATE = 'squads.state'
39
+ export const METHOD_SQUADS_LIST = 'squads.list'
40
+ export const METHOD_SQUADS_RUNS = 'squads.runs'
41
+ export const METHOD_SQUADS_RUN_MEMBER = 'squads.runMember'
42
+ export const METHOD_SQUADS_RUN_SQUAD = 'squads.runSquad'
43
+ export const METHOD_PUSH_REGISTER = 'push.register'
44
+ export const METHOD_USAGE_SESSION = 'usage.session'
45
+ export const METHOD_USAGE_BALANCE = 'usage.balance'
46
+ export const METHOD_USAGE_STATS = 'usage.stats'
47
+ // 协议 §35 追加的两个方法:一条卡上的动作回来,以及一张全局卡表的对账读。
48
+ export const METHOD_UI_EVENT = 'ui.event'
49
+ export const METHOD_UI_LIST = 'ui.list'
29
50
 
30
51
  /** Server-pushed topics of protocol v1. */
31
52
  export const TOPIC_SESSION_DELTA = 'session.delta'
32
53
  export const TOPIC_APPROVAL_REQUEST = 'approval.request'
33
54
  export const TOPIC_QUESTION_REQUEST = 'question.request'
34
55
  export const TOPIC_JOBS_CHANGED = 'jobs.changed'
56
+ // §35.2 追加的主题:一块整页自包含文档,以及它自己的结算通知。
57
+ export const TOPIC_UI_REQUEST = 'ui.request'
35
58
 
36
59
  /**
37
60
  * Capability a client declares in `hello`'s `cap` array to ask for a trimmed
@@ -83,6 +106,23 @@ export const CAP_SESSION_SNAPSHOT_SINCE = 'session.snapshot.since.v1'
83
106
  */
84
107
  export const CAP_QUESTIONS = 'questions.v1'
85
108
 
109
+ /**
110
+ * Capability a client declares in `hello`'s `cap` array to learn that this
111
+ * bridge can list the user questions it is still holding.
112
+ *
113
+ * An announcement rather than a switch, the same shape as
114
+ * {@link CAP_SESSION_DEEP_HISTORY}: `question.list` is reachable from every
115
+ * client that declared {@link CAP_QUESTIONS}, exactly as `question.answer` is,
116
+ * so a client written before this name existed loses nothing by declaring it
117
+ * and nothing by never calling the method. What the name buys is a way to tell
118
+ * a bridge that serves the method from one that does not: a host built before
119
+ * it answers `unknown-method`, so a client that does not find this name in
120
+ * `hello`'s `capabilities` keeps the retirement rule it had — a card is over
121
+ * when `question.request` says `settled` — instead of reaping cards on an
122
+ * answer it cannot trust.
123
+ */
124
+ export const CAP_QUESTION_LIST = 'questions.list.v1'
125
+
86
126
  /**
87
127
  * Capability a client declares in `hello`'s `cap` array to be handed the
88
128
  * approval questions this bridge is already holding for it.
@@ -145,6 +185,101 @@ export const CAP_JOBS = 'jobs.v1'
145
185
  */
146
186
  export const CAP_AGENTS = 'agents.v1'
147
187
 
188
+ /**
189
+ * Capability a client declares in `hello`'s `cap` array to read the host's
190
+ * agent squads and to drive them.
191
+ *
192
+ * Declaring it is what makes `squads.state`, `squads.list`, `squads.runs`,
193
+ * `squads.runMember` and `squads.runSquad` part of that client's protocol at
194
+ * all: a client that does not declare it — including every client written before
195
+ * this channel existed — is refused each as an unknown method, exactly as those
196
+ * frames were refused before. No command is called on a connection's behalf
197
+ * either, so a client that never asks sends the host no request.
198
+ *
199
+ * The channel is additive beside {@link CAP_AGENTS} rather than a replacement:
200
+ * a phone that predates the squad model keeps the preset roster and session
201
+ * creation it was written against, and a phone that reads this name reads the
202
+ * squad domain instead of deriving agents from anything else.
203
+ */
204
+ export const CAP_SQUADS = 'squads.v1'
205
+
206
+ /**
207
+ * Capability a client declares in `hello`'s `cap` array to register the APNs
208
+ * token this device wants to be notified on.
209
+ *
210
+ * Declaring it is what makes `push.register` part of that client's protocol at
211
+ * all: a client that does not declare it — including every client written before
212
+ * this channel existed — is refused that frame as an unknown method, and no
213
+ * device row is written on its behalf.
214
+ *
215
+ * The name announces that this bridge can REMEMBER a token, not that it will
216
+ * send anything. Whether a notification ever leaves the process is a deployment
217
+ * fact (is an APNs signing key configured?) that the wire deliberately cannot
218
+ * express: a bridge with no key answers `ok:true` exactly like one with a key,
219
+ * because a client has no second code path to keep for the difference. Every
220
+ * notification this channel produces is an outbound APNs request and nothing
221
+ * else — no topic, no frame and no state is added to `/ios/v1` (see the
222
+ * protocol's §28).
223
+ */
224
+ export const CAP_PUSH = 'push.v1'
225
+
226
+ /**
227
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要读本桥自己的用量读数。
228
+ *
229
+ * 宣告它是 `usage.session` 与 `usage.balance` 进入这个客户端协议的唯一前提:
230
+ * 不宣告的客户端——包括这个通道出现之前写下的每一个客户端——收到的是与从前
231
+ * 逐字一样的 `unknown-method`,本桥也不会替它读一条会话、更不会替它打一次
232
+ * 上游余额端点。
233
+ *
234
+ * 一个能力名带两个方法,因为它们读的是同一件事的两面:一条会话下一次请求由
235
+ * 什么组成(上下文窗口取宿主自己广播的值,组成由本桥按文本长度估算并恒标
236
+ * `estimated: true`),以及某条 provider 路由背后账户的余额(DeepSeek 官方
237
+ * 口径,只在路由确实指向 `api.deepseek.com` 且凭据拿得到时才查官方端点,宿主
238
+ * 侧同一 provider + 凭据 60 秒最多一次上游请求)。
239
+ */
240
+ export const CAP_USAGE = 'usage.v1'
241
+
242
+ /**
243
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要读宿主自己的用量台账聚合。
244
+ *
245
+ * 与 {@link CAP_USAGE} 平级、独立声明:宣告它是 `usage.stats` 进入这个客户端
246
+ * 协议的唯一前提,不宣告的客户端——包括 `usage.v1` 出现之后、这个能力出现之前
247
+ * 写下的每一个客户端——收到的仍是 `unknown-method`,本桥也不会替它去读宿主
248
+ * 上 `dsh-usage` 插件的任何一条路由。
249
+ *
250
+ * 拆成独立能力而不是塞进 `usage.v1`,是因为它读的是另一件事:那两半读的是本
251
+ * 进程自己的事实(一个会话、一条路由的账户),这一半读的是另一个插件挂在这个
252
+ * 宿主上的 HTTP 路由,而那个插件可能根本没装。老客户端忽略这个未知名字即可,
253
+ * 它看到的能力表里多一项、别的什么都没有变。
254
+ */
255
+ export const CAP_USAGE_STATS = 'usage.stats.v1'
256
+
257
+ /**
258
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要渲染整页卡并回答它(协议 §35)。
259
+ *
260
+ * 宣告它是 `ui.request` 与 `ui.event` 进入这个客户端协议的唯一前提:不宣告的
261
+ * 客户端——包括这个通道出现之前写下的每一个客户端——收不到任何一帧整页卡,它的
262
+ * `ui.event` 回 `unknown-method`,其余逐字节不变。它是**公告不是协商**(§13.1、
263
+ * §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,
264
+ * 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。
265
+ *
266
+ * 宿主半区只有真实现了 `ui.present` 这一半的桥才把自己列进
267
+ * {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`
268
+ * 会出现、`ui.event` 会被接受。
269
+ */
270
+ export const CAP_UI = 'ui.v1'
271
+
272
+ /**
273
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要按 §24.3 的四条件对账自己手上的整页卡
274
+ * (协议 §35.4)。
275
+ *
276
+ * 与 {@link CAP_QUESTION_LIST} 同一形状:`ui.list` 本身是只读的、对每条配对连接
277
+ * 都开放,这个名字买到的是「这条连接会不会被答」之外的另一种确定性——一条老桥
278
+ * 回 `unknown-method`,于是没有这个名字的客户端就保留它原有的退休规则(卡片只在
279
+ * `ui.request` 说 `settled` 时结束),而不是按一次它信不过的应答清卡。
280
+ */
281
+ export const CAP_UI_LIST = 'ui.list.v1'
282
+
148
283
  /**
149
284
  * Capability a client declares in `hello`'s `cap` array to be answered with
150
285
  * byte-level increments instead of the whole roster or the whole board.
@@ -218,6 +353,66 @@ export const CAP_SESSION_DEEP_HISTORY = 'session.deep-history.v1'
218
353
  */
219
354
  export const CAP_SESSION_FORK = 'session.fork.v1'
220
355
 
356
+ /**
357
+ * Capability a client declares in `hello`'s `cap` array to list a session's
358
+ * slash commands and skills and to run one of them.
359
+ *
360
+ * Declaring it is what makes `session.commands` and `session.command` part of
361
+ * that client's protocol at all: a client that does not declare it — including
362
+ * every client written before this channel existed — is refused both as unknown
363
+ * methods, exactly as those frames were refused before. Neither method is called
364
+ * on a connection's behalf either, so a client that never asks costs the host no
365
+ * registry read and no skill catalog read.
366
+ *
367
+ * The channel holds no events and no cache: a directory is read live on every
368
+ * call, so a command a plugin registered a moment ago and a skill withdrawn from
369
+ * one Agent preset are both reflected in the answer that follows.
370
+ */
371
+ export const CAP_COMMANDS = 'commands.v1'
372
+
373
+ /**
374
+ * Capability a client declares in `hello`'s `cap` array to read the host's
375
+ * workspaces and its two registry-global session sets.
376
+ *
377
+ * Declaring it is what makes `workspace.list` part of that client's protocol at
378
+ * all: a client that does not declare it — including every client written before
379
+ * this channel existed — is refused that frame as an unknown method, and no
380
+ * registry is read on its behalf. Behind the name the answer is the host's own
381
+ * synchronous projection: one row per registered workspace in registry order,
382
+ * plus the complete archive and pin sets.
383
+ *
384
+ * The method is a read and nothing is cached, so a pin or an archive followed by
385
+ * another list reads the set the write left behind. That pair of calls is the
386
+ * whole refresh story of the session-admin channel: see {@link CAP_SESSION_ADMIN}.
387
+ */
388
+ export const CAP_WORKSPACE = 'workspace.v1'
389
+
390
+ /**
391
+ * Capability a client declares in `hello`'s `cap` array to rename, pin,
392
+ * unpin, archive and unarchive a session.
393
+ *
394
+ * Declaring it is what makes those five methods part of that client's protocol
395
+ * at all: a client that does not declare it — including every client written
396
+ * before this channel existed — is refused each as an unknown method, and no
397
+ * write is asked of the host on its behalf.
398
+ *
399
+ * Every one of the five is forwarded one-to-one to the endpoint that already
400
+ * owns the semantics, so nothing about a title, a pin or an archive is modelled
401
+ * or re-derived here: a rename reaches `session/rename` — the endpoint that
402
+ * restores a cold session before it writes, which is why a client needs no
403
+ * resume path of its own — and the four set mutations reach
404
+ * `workspace/pinSession`, `workspace/unpinSession`, `workspace/archiveSession`
405
+ * and `workspace/unarchiveSession`. A host refusal crosses with its own code
406
+ * and text, `workspace/session-active` included.
407
+ *
408
+ * The channel publishes no event, because the host announces none of these
409
+ * writes as a cordis event a connection could fold into a delta: a rename
410
+ * appends one `session/title` log record and nothing else. A client re-reads
411
+ * after a write instead — the pin set through {@link CAP_WORKSPACE}, the roster
412
+ * through `session.list` — which is why one branch serves both capabilities.
413
+ */
414
+ export const CAP_SESSION_ADMIN = 'session.admin.v1'
415
+
221
416
  /**
222
417
  * Capability a client declares in `hello`'s `cap` array to be sent frames
223
418
  * compressed instead of as plain text.
@@ -264,16 +459,44 @@ export const KNOWN_METHODS: ReadonlySet<string> = new Set([
264
459
  METHOD_PAIR_FINISH,
265
460
  METHOD_APPROVAL_RESOLVE,
266
461
  METHOD_QUESTION_ANSWER,
462
+ METHOD_QUESTION_LIST,
267
463
  METHOD_JOBS_LIST,
268
464
  METHOD_PRESETS_LIST,
269
465
  METHOD_SESSION_CREATE,
270
466
  METHOD_SESSION_FORK,
467
+ METHOD_SESSION_COMMANDS,
468
+ METHOD_SESSION_COMMAND,
469
+ METHOD_SESSION_RENAME,
470
+ METHOD_SESSION_PIN,
471
+ METHOD_SESSION_UNPIN,
472
+ METHOD_SESSION_ARCHIVE,
473
+ METHOD_SESSION_UNARCHIVE,
474
+ METHOD_WORKSPACE_LIST,
475
+ METHOD_SQUADS_STATE,
476
+ METHOD_SQUADS_LIST,
477
+ METHOD_SQUADS_RUNS,
478
+ METHOD_SQUADS_RUN_MEMBER,
479
+ METHOD_SQUADS_RUN_SQUAD,
480
+ METHOD_PUSH_REGISTER,
481
+ METHOD_USAGE_SESSION,
482
+ METHOD_USAGE_BALANCE,
483
+ METHOD_USAGE_STATS,
484
+ METHOD_UI_EVENT,
485
+ METHOD_UI_LIST,
271
486
  ])
272
487
 
273
488
  /** Refusal codes the bridge itself raises (DSH failures cross as their own code). */
274
489
  export const CODE_UNPAIRED = 'unpaired'
275
490
  export const CODE_UNKNOWN_METHOD = 'unknown-method'
276
491
  export const CODE_INVALID_ARGS = 'invalid-args'
492
+ /**
493
+ * `usage.session` 点名的会话在这个宿主上不存在:宿主自己的会话名册里没有它,
494
+ * 活会话存储里没有它,本进程也从未观察过它的任何事件。它与「会话存在但两项
495
+ * 读数都取不到」是两个答案,后者回的是空对象——一条刚刚开始、还什么都没广播
496
+ * 的会话,以及一条在桥重载前就存在的会话,都在那个状态里:存在而没读数,不是
497
+ * 不存在。
498
+ */
499
+ export const CODE_UNKNOWN_SESSION = 'unknown-session'
277
500
  export const CODE_PROTO_UNSUPPORTED = 'proto-unsupported'
278
501
  export const CODE_TOKEN_INVALID = 'token-invalid'
279
502
  export const CODE_NONCE_INVALID = 'nonce-invalid'
@@ -285,6 +508,30 @@ export const CODE_APPROVAL_UNKNOWN = 'approval-unknown'
285
508
  * failures crossing this method keep their own codes instead.
286
509
  */
287
510
  export const CODE_QUESTION_UNKNOWN = 'question-unknown'
511
+ /**
512
+ * The bridge could not read the questions it is holding, so it cannot say which
513
+ * ones are still live. The answer is deliberately not an empty list: a client
514
+ * retires every card a COMPLETE list does not carry, and a read that failed is
515
+ * not a complete one — it is a bridge that cannot answer this question today.
516
+ */
517
+ export const CODE_QUESTION_LIST_UNAVAILABLE = 'question-list-unavailable'
518
+ /**
519
+ * 本桥不认领这个 `callId`:它从没呈现过这张卡,或者这张卡已被别处结算(宽限窗口
520
+ * 到期、回合被取消、桥卸载)。客户端码表保持开放:除本码之外的未知码不得被读成
521
+ * 「卡已消失」(§11.3 同一句)。
522
+ */
523
+ export const CODE_UI_UNKNOWN = 'ui-unknown'
524
+ /**
525
+ * 这张卡已经被用户自己的第一条动作结算过(§35.3)。它与 {@link CODE_UI_UNKNOWN}
526
+ * 是两个答案:重复的一次点击是「已经做完了」,不是「这张卡不存在」。
527
+ */
528
+ export const CODE_UI_SETTLED = 'ui-settled'
529
+ /**
530
+ * 本桥读不出自己持有的卡,所以它说不了哪些还活着。答案故意不是一张空表:客户端
531
+ * 只会按 COMPLETE 的列表退休卡片,一次失败的读不是一张完整的空表,而是这台桥今天
532
+ * 答不了这一问(与 {@link CODE_QUESTION_LIST_UNAVAILABLE} 同一句)。
533
+ */
534
+ export const CODE_UI_LIST_UNAVAILABLE = 'ui-list-unavailable'
288
535
  /**
289
536
  * The named session is a delegated child whose durable parent is not a session
290
537
  * this connection may read. The bridge follows an addressable child and refuses
@@ -298,6 +545,32 @@ export const CODE_SNAPSHOT_UNAVAILABLE = 'snapshot-unavailable'
298
545
  * what a particular host mounts — and only a call that needs the registry fails.
299
546
  */
300
547
  export const CODE_JOBS_UNAVAILABLE = 'jobs-unavailable'
548
+ /**
549
+ * This host serves no endpoint behind the command channel: no `commands/list`,
550
+ * no `commands/execute` or no `skills/list`, which the gateway itself reports
551
+ * as an endpoint nothing exports. The capability stays advertised — it is a fact
552
+ * about this bridge, not about what a particular host mounts — and only a call
553
+ * that needs those endpoints fails.
554
+ */
555
+ export const CODE_COMMANDS_UNAVAILABLE = 'commands-unavailable'
556
+ /**
557
+ * This host serves no squad domain this bridge can reach: no answer to the
558
+ * plugin's state route over loopback, no readable ledger beside it, or a body
559
+ * this build cannot read as one squad domain. The capability stays advertised —
560
+ * it is a fact about this bridge, not about what a particular host mounts — and
561
+ * only a call that needs the domain fails. A refusal the `dsh-agents` plugin
562
+ * itself raised crosses with the plugin's own code instead (`team-not-found`,
563
+ * `member-not-found`, `preset-unknown`, `workspace-required` and their
564
+ * neighbours).
565
+ */
566
+ export const CODE_SQUADS_UNAVAILABLE = 'squads-unavailable'
567
+ /**
568
+ * The definitions are readable but the two run commands cannot be served: this
569
+ * host answered no run route over loopback, and the read-only ledger fallback
570
+ * cannot launch anything. Failing closed is the point — a client is told the
571
+ * capability is not served here rather than shown a run that never started.
572
+ */
573
+ export const CODE_SQUADS_RUN_UNAVAILABLE = 'squads-run-unavailable'
301
574
  export const CODE_SNAPSHOT_TOO_LARGE = 'snapshot-too-large'
302
575
  export const CODE_INTERNAL = 'internal'
303
576
 
@@ -306,6 +579,75 @@ export const PROTO = 1
306
579
  /**
307
580
  * Minor version this package speaks.
308
581
  *
582
+ * 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}
583
+ * 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与
584
+ * {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui.present`。客户端
585
+ * 因此从线路上读到两项新能力名、一种新主题与两种新应答体,所以 minor 抬一格;
586
+ * `proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状。工具结果是**新增**的:
587
+ * 老会话、老 prompt、老回合都不受影响,工具名进入宿主工具表之后只有新回合才可能
588
+ * 被调用。
589
+ * 20 when the usage stats channel shipped: behind {@link CAP_USAGE_STATS} a
590
+ * client may call {@link METHOD_USAGE_STATS} and read the host's own usage
591
+ * ledger — today, this month and one row per local day — and behind the same
592
+ * {@link CAP_USAGE} this bridge now also answers `usage.session` with a
593
+ * `modelContextWindow` when the model catalog of the session's route declares
594
+ * one, so a client reads one new reply body and one new optional key off the
595
+ * wire and has to read the name before it asks. The stats half is independent
596
+ * of {@link CAP_USAGE} on purpose: it reads another plugin's HTTP routes, which
597
+ * a host may not mount at all, so a client written before this name existed
598
+ * keeps the two readings it had and the bridge reads no route on its behalf.
599
+ * No frame, no topic, no existing method and no existing key changes shape.
600
+ * 19 when the usage channel shipped: behind {@link CAP_USAGE} a client may call
601
+ * {@link METHOD_USAGE_SESSION} and read one session's context window and its
602
+ * request's estimated composition, and {@link METHOD_USAGE_BALANCE} and read the
603
+ * account behind one provider route, so it reads two new reply bodies off the
604
+ * wire and has to read the name before it asks — a bridge below this one answers
605
+ * `unknown-method` for both. No frame, no topic and no existing method changes
606
+ * shape.
607
+ * 18 when one card learned to lay out several sessions (§30 of
608
+ * `docs/protocol-v1.md` in the iphone_remote_use_dsh repository): `content-state`
609
+ * gains the optional `rows` key, so a phone reads up to three sessions off one
610
+ * lock-screen card instead of having to hold one card per session. It is a pure
611
+ * addition — no new method, no new capability name, no existing key or topic
612
+ * changes shape — so the minor counts the key alone, and a client that reads 18
613
+ * knows the order of the rows it is handed is the bridge's rather than one it
614
+ * has to derive.
615
+ * 17 when the live-activity channel shipped (§29.2): this bridge now sends the
616
+ * lock-screen card a suspended app cannot update itself, addressed to the
617
+ * per-card APNs tokens {@link METHOD_PUSH_REGISTER} already carries and projected
618
+ * per session rather than per bridge. It is a pure addition — no new method, no
619
+ * new capability name, and no existing frame, field or topic changes shape — so
620
+ * the minor counts it alone: a client that wants a card has to read 17 before it
621
+ * registers one, because a bridge below this one has no sending path at all and
622
+ * would answer `ok:true` to a registration it can never use.
623
+ * 16 when the push channel shipped: behind {@link CAP_PUSH} a client may call
624
+ * {@link METHOD_PUSH_REGISTER} and have the device table remember an APNs token,
625
+ * so a phone learns a turn ended — or that a question is waiting — while its
626
+ * socket is not open. No frame, no topic and no existing method changes shape;
627
+ * the minor is raised because a new reply body and a new announcement appear on
628
+ * the wire, and because a client has to read the name before it registers.
629
+ * 15 when the squads channel shipped: behind {@link CAP_SQUADS} a client may
630
+ * call {@link METHOD_SQUADS_STATE}, {@link METHOD_SQUADS_LIST},
631
+ * {@link METHOD_SQUADS_RUNS}, {@link METHOD_SQUADS_RUN_MEMBER} and
632
+ * {@link METHOD_SQUADS_RUN_SQUAD}, so it reads five new reply bodies off the wire
633
+ * and drives the squad domain instead of deriving its agents from anything else.
634
+ * 14 when the session-admin channel shipped: behind {@link CAP_WORKSPACE} a
635
+ * client may call {@link METHOD_WORKSPACE_LIST} and read the host's workspaces
636
+ * with both registry-global session sets, and behind {@link CAP_SESSION_ADMIN}
637
+ * it may call {@link METHOD_SESSION_RENAME}, {@link METHOD_SESSION_PIN},
638
+ * {@link METHOD_SESSION_UNPIN}, {@link METHOD_SESSION_ARCHIVE} and
639
+ * {@link METHOD_SESSION_UNARCHIVE}, so a phone long-presses a roster row for the
640
+ * same five actions the desktop offers it.
641
+ * 13 when the question list shipped: behind {@link CAP_QUESTION_LIST} a client
642
+ * may call {@link METHOD_QUESTION_LIST} and be answered the questions this
643
+ * bridge is still holding, so it reads a new reply body off the wire and the
644
+ * number rises with it. It is what lets a phone stop trusting a card it holds:
645
+ * the one retirement signal before it was `question.request` with
646
+ * `state: "settled"`, which a phone that was disconnected when the last client
647
+ * left never receives.
648
+ * 12 when the command channel shipped: behind {@link CAP_COMMANDS} a client may
649
+ * call {@link METHOD_SESSION_COMMANDS} and {@link METHOD_SESSION_COMMAND}, so it
650
+ * reads a new reply body off the wire and the number rises with it.
309
651
  * 11 when the fork channel shipped: behind {@link CAP_SESSION_FORK} a client may
310
652
  * call {@link METHOD_SESSION_FORK} and receive the host's own fork answer, so a
311
653
  * phone branches a session that inherits the context of the one it forked. This
@@ -348,19 +690,33 @@ export const PROTO = 1
348
690
  * declares the capability that plugin requires. No addition changed the major
349
691
  * version, a frozen field, or an existing method or topic name.
350
692
  */
351
- export const MINOR = 11
693
+ export const MINOR = 21
352
694
 
353
695
  /**
354
- * The capabilities this bridge itself serves, as `hello` advertises them.
696
+ * The capabilities this bridge itself serves, and the opening half of what
697
+ * `hello` advertises.
698
+ *
699
+ * A capability a mounted plugin adds is not listed here — the bridge is not its
700
+ * author and names none of them — but `hello` advertises it all the same: the
701
+ * answer is this list plus every capability the extension registry currently
702
+ * requires a client to declare (`RemoteBridgeRegistry.capabilities`), computed
703
+ * on each greeting so a plugin mounted after this bridge was built is visible
704
+ * to the next phone. A name both halves carry is listed once, and this list
705
+ * keeps its order at the front, so a bridge with no extension mounted answers
706
+ * byte for byte the list it always did. Extension names never move
707
+ * {@link MINOR}: that number describes this protocol, and a plugin's own names
708
+ * are the plugin's.
355
709
  *
356
- * A capability a mounted plugin adds is not listed here: the bridge cannot know
357
- * what it is not the author of. A client learns such a capability from the
358
- * plugin's own documentation, exactly as it did before this list existed.
710
+ * A capability whose whole switch is a declaration — no method, no answer, no
711
+ * field behind it, such as {@link CAP_APPROVALS} — stays out of this list for
712
+ * the reason it always did: advertising it would claim a handshake change
713
+ * without one.
359
714
  */
360
715
  export const SERVED_CAPABILITIES: readonly string[] = [
361
716
  CAP_SESSION_SNAPSHOT_TRIM,
362
717
  CAP_SESSION_SNAPSHOT_PAGE,
363
718
  CAP_QUESTIONS,
719
+ CAP_QUESTION_LIST,
364
720
  CAP_SUBAGENT_THREAD,
365
721
  CAP_JOBS,
366
722
  CAP_AGENTS,
@@ -371,6 +727,15 @@ export const SERVED_CAPABILITIES: readonly string[] = [
371
727
  CAP_ROSTER_COMPACT,
372
728
  CAP_SESSION_SNAPSHOT_SINCE,
373
729
  CAP_SESSION_FORK,
730
+ CAP_COMMANDS,
731
+ CAP_WORKSPACE,
732
+ CAP_SESSION_ADMIN,
733
+ CAP_SQUADS,
734
+ CAP_PUSH,
735
+ CAP_USAGE,
736
+ CAP_USAGE_STATS,
737
+ CAP_UI,
738
+ CAP_UI_LIST,
374
739
  ]
375
740
  /** `server` field of the hello response. */
376
741
  export const SERVER_ID = 'dsh-remote-bridge'