@linxin666/dsh-remote-bridge 0.4.7 → 0.4.9

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 (78) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +93 -26
  3. package/README.zh.md +91 -26
  4. package/icon.svg +3 -0
  5. package/lib/client.js +274 -253
  6. package/lib/client.js.map +1 -1
  7. package/lib/index.js +8891 -2433
  8. package/lib/types/client/PairEntry.d.ts +2 -2
  9. package/lib/types/client/PairPanel.d.ts +10 -2
  10. package/lib/types/client/icons.d.ts +5 -13
  11. package/lib/types/client/locales.d.ts +10 -14
  12. package/lib/types/client/semantic.d.ts +9 -5
  13. package/lib/types/core/approvals.d.ts +24 -0
  14. package/lib/types/core/commands.d.ts +59 -0
  15. package/lib/types/core/connection.d.ts +124 -5
  16. package/lib/types/core/delta.d.ts +101 -0
  17. package/lib/types/core/devices.d.ts +98 -2
  18. package/lib/types/core/dsh-frames.d.ts +155 -4
  19. package/lib/types/core/envelope.d.ts +34 -0
  20. package/lib/types/core/extension.d.ts +144 -0
  21. package/lib/types/core/hub.d.ts +96 -20
  22. package/lib/types/core/jobs.d.ts +204 -0
  23. package/lib/types/core/liveactivity.d.ts +324 -0
  24. package/lib/types/core/protocol.d.ts +491 -2
  25. package/lib/types/core/push.d.ts +178 -0
  26. package/lib/types/core/questions.d.ts +109 -9
  27. package/lib/types/core/session-meta.d.ts +55 -1
  28. package/lib/types/core/squads.d.ts +130 -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/core/wire.d.ts +1 -1
  32. package/lib/types/core/ws-frames.d.ts +11 -0
  33. package/lib/types/host/apns.d.ts +151 -0
  34. package/lib/types/host/squads-ledger.d.ts +39 -0
  35. package/lib/types/host/squads.d.ts +77 -0
  36. package/lib/types/host/usage-stats.d.ts +75 -0
  37. package/lib/types/host/watchers.d.ts +88 -0
  38. package/lib/types/host/websocket.d.ts +8 -1
  39. package/lib/types/index.d.ts +34 -3
  40. package/lib/types/mount-once.d.ts +55 -0
  41. package/locale/en.json +6 -0
  42. package/locale/ru.json +6 -0
  43. package/locale/zh.json +6 -0
  44. package/package.json +20 -14
  45. package/src/client/PairEntry.tsx +58 -31
  46. package/src/client/PairPanel.tsx +181 -97
  47. package/src/client/icons.tsx +17 -60
  48. package/src/client/locales.ts +15 -23
  49. package/src/client/panel.module.css +239 -186
  50. package/src/client/semantic.ts +10 -6
  51. package/src/core/approvals.ts +32 -1
  52. package/src/core/commands.ts +95 -0
  53. package/src/core/connection.ts +1483 -31
  54. package/src/core/delta.ts +204 -0
  55. package/src/core/devices.ts +221 -3
  56. package/src/core/dsh-frames.ts +365 -8
  57. package/src/core/envelope.ts +46 -0
  58. package/src/core/extension.ts +197 -0
  59. package/src/core/hub.ts +441 -49
  60. package/src/core/jobs.ts +372 -0
  61. package/src/core/liveactivity.ts +833 -0
  62. package/src/core/protocol.ts +556 -2
  63. package/src/core/push.ts +354 -0
  64. package/src/core/questions.ts +264 -17
  65. package/src/core/session-meta.ts +73 -1
  66. package/src/core/squads.ts +345 -0
  67. package/src/core/usage-stats.ts +424 -0
  68. package/src/core/usage.ts +937 -0
  69. package/src/core/wire.ts +13 -1
  70. package/src/core/ws-frames.ts +14 -0
  71. package/src/host/apns.ts +320 -0
  72. package/src/host/squads-ledger.ts +105 -0
  73. package/src/host/squads.ts +206 -0
  74. package/src/host/usage-stats.ts +155 -0
  75. package/src/host/watchers.ts +272 -0
  76. package/src/host/websocket.ts +37 -3
  77. package/src/index.ts +310 -9
  78. package/src/mount-once.ts +142 -0
@@ -9,6 +9,7 @@ export declare const METHOD_SESSION_LIST = "session.list";
9
9
  export declare const METHOD_SESSION_TITLES = "session.titles";
10
10
  export declare const METHOD_SESSION_SNAPSHOT = "session.snapshot";
11
11
  export declare const METHOD_SESSION_HISTORY = "session.history";
12
+ export declare const METHOD_SESSION_HISTORY_DEEP = "session.history.deep";
12
13
  export declare const METHOD_SESSION_PROMPT = "session.prompt";
13
14
  export declare const METHOD_SESSION_INTERRUPT = "session.interrupt";
14
15
  export declare const METHOD_SESSION_ATTACHMENT = "session.attachment";
@@ -16,14 +17,37 @@ export declare const METHOD_SESSION_PERMISSIONS = "session.permissions";
16
17
  export declare const METHOD_SESSION_SET_PERMISSION = "session.setPermission";
17
18
  export declare const METHOD_SESSION_MODELS = "session.models";
18
19
  export declare const METHOD_SESSION_SET_MODEL = "session.setModel";
20
+ export declare const METHOD_SESSION_CREATE = "session.create";
21
+ export declare const METHOD_SESSION_FORK = "session.fork";
22
+ export declare const METHOD_SESSION_COMMANDS = "session.commands";
23
+ export declare const METHOD_SESSION_COMMAND = "session.command";
24
+ export declare const METHOD_SESSION_RENAME = "session.rename";
25
+ export declare const METHOD_SESSION_PIN = "session.pin";
26
+ export declare const METHOD_SESSION_UNPIN = "session.unpin";
27
+ export declare const METHOD_SESSION_ARCHIVE = "session.archive";
28
+ export declare const METHOD_SESSION_UNARCHIVE = "session.unarchive";
29
+ export declare const METHOD_WORKSPACE_LIST = "workspace.list";
30
+ export declare const METHOD_PRESETS_LIST = "presets.list";
19
31
  export declare const METHOD_PAIR_BEGIN = "pair.begin";
20
32
  export declare const METHOD_PAIR_FINISH = "pair.finish";
21
33
  export declare const METHOD_APPROVAL_RESOLVE = "approval.resolve";
22
34
  export declare const METHOD_QUESTION_ANSWER = "question.answer";
35
+ export declare const METHOD_QUESTION_LIST = "question.list";
36
+ export declare const METHOD_JOBS_LIST = "jobs.list";
37
+ export declare const METHOD_SQUADS_STATE = "squads.state";
38
+ export declare const METHOD_SQUADS_LIST = "squads.list";
39
+ export declare const METHOD_SQUADS_RUNS = "squads.runs";
40
+ export declare const METHOD_SQUADS_RUN_MEMBER = "squads.runMember";
41
+ export declare const METHOD_SQUADS_RUN_SQUAD = "squads.runSquad";
42
+ export declare const METHOD_PUSH_REGISTER = "push.register";
43
+ export declare const METHOD_USAGE_SESSION = "usage.session";
44
+ export declare const METHOD_USAGE_BALANCE = "usage.balance";
45
+ export declare const METHOD_USAGE_STATS = "usage.stats";
23
46
  /** Server-pushed topics of protocol v1. */
24
47
  export declare const TOPIC_SESSION_DELTA = "session.delta";
25
48
  export declare const TOPIC_APPROVAL_REQUEST = "approval.request";
26
49
  export declare const TOPIC_QUESTION_REQUEST = "question.request";
50
+ export declare const TOPIC_JOBS_CHANGED = "jobs.changed";
27
51
  /**
28
52
  * Capability a client declares in `hello`'s `cap` array to ask for a trimmed
29
53
  * `session.snapshot` baseline. A client that does not declare it — including
@@ -40,6 +64,25 @@ export declare const CAP_SESSION_SNAPSHOT_TRIM = "session.snapshot.trim.v1";
40
64
  * snapshot protocol v1 always served.
41
65
  */
42
66
  export declare const CAP_SESSION_SNAPSHOT_PAGE = "session.snapshot.page.v1";
67
+ /**
68
+ * Capability a client declares in `hello`'s `cap` array to have
69
+ * `session.snapshot` answer a reconnect with only what it missed.
70
+ *
71
+ * The declaration and the request's `sinceSeq` are what it takes together: a
72
+ * snapshot that carries no `sinceSeq` is answered, byte for byte, the body
73
+ * protocol v1 always served, whether or not the client declared this. Behind
74
+ * both, the client names the durable `lastSeq` of a snapshot it already holds
75
+ * and the answer is either that same reply in an incremental form —
76
+ * `{turns, lastSeq, mode:"since", reset:false}` carrying only the entries above
77
+ * that watermark — or a full baseline with `mode:"full"` and `reset:true`,
78
+ * which is the one answer that tells a client to throw its copy away. The
79
+ * estimate is only served when the bridge can PROVE nothing was lost: the
80
+ * current follow window's oldest entry must sit at or below `sinceSeq + 1`, so a
81
+ * window that has already scrolled past the watermark answers the baseline
82
+ * instead of a delta with a hole in it. It exists because a reconnect on the
83
+ * phone re-paid 0.86-1.06 s of baseline five times in one measured run.
84
+ */
85
+ export declare const CAP_SESSION_SNAPSHOT_SINCE = "session.snapshot.since.v1";
43
86
  /**
44
87
  * Capability a client declares in `hello`'s `cap` array to be shown the
45
88
  * host's pending user questions and to answer them with `question.answer`.
@@ -51,6 +94,285 @@ export declare const CAP_SESSION_SNAPSHOT_PAGE = "session.snapshot.page.v1";
51
94
  * exactly as that frame was refused before.
52
95
  */
53
96
  export declare const CAP_QUESTIONS = "questions.v1";
97
+ /**
98
+ * Capability a client declares in `hello`'s `cap` array to learn that this
99
+ * bridge can list the user questions it is still holding.
100
+ *
101
+ * An announcement rather than a switch, the same shape as
102
+ * {@link CAP_SESSION_DEEP_HISTORY}: `question.list` is reachable from every
103
+ * client that declared {@link CAP_QUESTIONS}, exactly as `question.answer` is,
104
+ * so a client written before this name existed loses nothing by declaring it
105
+ * and nothing by never calling the method. What the name buys is a way to tell
106
+ * a bridge that serves the method from one that does not: a host built before
107
+ * it answers `unknown-method`, so a client that does not find this name in
108
+ * `hello`'s `capabilities` keeps the retirement rule it had — a card is over
109
+ * when `question.request` says `settled` — instead of reaping cards on an
110
+ * answer it cannot trust.
111
+ */
112
+ export declare const CAP_QUESTION_LIST = "questions.list.v1";
113
+ /**
114
+ * Capability a client declares in `hello`'s `cap` array to be handed the
115
+ * approval questions this bridge is already holding for it.
116
+ *
117
+ * Unlike every channel capability beside it, this one gates a second delivery
118
+ * rather than the channel: `approval.request` still reaches every paired
119
+ * connection the moment a tool asks, exactly as it did before this name
120
+ * existed, because gating the first broadcast would take approvals away from
121
+ * every client written before the capability. What the declaration buys is the
122
+ * replay — after a reconnect, or on a session screen opened late, the client is
123
+ * handed the questions that are still waiting instead of a card it never saw.
124
+ * Only a live claim is replayed: a question that was answered, that the bridge
125
+ * timed out, or that was withdrawn with the last phone is gone from the claim
126
+ * registry before the replay reads it.
127
+ *
128
+ * It is deliberately absent from {@link SERVED_CAPABILITIES}: that list is what
129
+ * `hello` advertises as served, advertising a capability is a minor-version
130
+ * addition (see {@link MINOR}), and this channel changes nothing a client can
131
+ * observe in the handshake — no answer, no field and no method behind it. The
132
+ * declaration is the whole switch, and the name reaches a client through this
133
+ * bridge's own protocol documentation.
134
+ */
135
+ export declare const CAP_APPROVALS = "approvals.v1";
136
+ /**
137
+ * Capability a client declares in `hello`'s `cap` array to be told where a
138
+ * message came from and that an agent spawned a child session.
139
+ *
140
+ * Declaring it is what makes the `subagent` delta part of that client's
141
+ * protocol: a client that does not declare it — including every client written
142
+ * before this channel existed — receives no such event, exactly as that frame
143
+ * was dropped before. The `actor` of a `user-message` is not gated: it is an
144
+ * additive field a client that does not read it ignores.
145
+ */
146
+ export declare const CAP_SUBAGENT_THREAD = "subagent.thread.v1";
147
+ /**
148
+ * Capability a client declares in `hello`'s `cap` array to see the host's
149
+ * background jobs and to be told when the set changes.
150
+ *
151
+ * Declaring it is what makes `jobs.list` reachable, and `jobs.list` is the only
152
+ * thing that opens a roster: a connection that declares this capability but
153
+ * never asks for a scope receives no `jobs.changed` at all. A client that does
154
+ * not declare it — including every client written before this channel existed —
155
+ * receives no such event, and its `jobs.list` is refused as an unknown method,
156
+ * exactly as that frame was refused before.
157
+ */
158
+ export declare const CAP_JOBS = "jobs.v1";
159
+ /**
160
+ * Capability a client declares in `hello`'s `cap` array to read the host's
161
+ * Agent presets and to instantiate one as a session.
162
+ *
163
+ * Declaring it is what makes `presets.list` and `session.create` part of that
164
+ * client's protocol at all: a client that does not declare it — including every
165
+ * client written before this channel existed — is refused both as unknown
166
+ * methods, exactly as those frames were refused before. Neither method is
167
+ * called on a connection's behalf either, so a client that never asks sends the
168
+ * host no request.
169
+ */
170
+ export declare const CAP_AGENTS = "agents.v1";
171
+ /**
172
+ * Capability a client declares in `hello`'s `cap` array to read the host's
173
+ * agent squads and to drive them.
174
+ *
175
+ * Declaring it is what makes `squads.state`, `squads.list`, `squads.runs`,
176
+ * `squads.runMember` and `squads.runSquad` part of that client's protocol at
177
+ * all: a client that does not declare it — including every client written before
178
+ * this channel existed — is refused each as an unknown method, exactly as those
179
+ * frames were refused before. No command is called on a connection's behalf
180
+ * either, so a client that never asks sends the host no request.
181
+ *
182
+ * The channel is additive beside {@link CAP_AGENTS} rather than a replacement:
183
+ * a phone that predates the squad model keeps the preset roster and session
184
+ * creation it was written against, and a phone that reads this name reads the
185
+ * squad domain instead of deriving agents from anything else.
186
+ */
187
+ export declare const CAP_SQUADS = "squads.v1";
188
+ /**
189
+ * Capability a client declares in `hello`'s `cap` array to register the APNs
190
+ * token this device wants to be notified on.
191
+ *
192
+ * Declaring it is what makes `push.register` part of that client's protocol at
193
+ * all: a client that does not declare it — including every client written before
194
+ * this channel existed — is refused that frame as an unknown method, and no
195
+ * device row is written on its behalf.
196
+ *
197
+ * The name announces that this bridge can REMEMBER a token, not that it will
198
+ * send anything. Whether a notification ever leaves the process is a deployment
199
+ * fact (is an APNs signing key configured?) that the wire deliberately cannot
200
+ * express: a bridge with no key answers `ok:true` exactly like one with a key,
201
+ * because a client has no second code path to keep for the difference. Every
202
+ * notification this channel produces is an outbound APNs request and nothing
203
+ * else — no topic, no frame and no state is added to `/ios/v1` (see the
204
+ * protocol's §28).
205
+ */
206
+ export declare const CAP_PUSH = "push.v1";
207
+ /**
208
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要读本桥自己的用量读数。
209
+ *
210
+ * 宣告它是 `usage.session` 与 `usage.balance` 进入这个客户端协议的唯一前提:
211
+ * 不宣告的客户端——包括这个通道出现之前写下的每一个客户端——收到的是与从前
212
+ * 逐字一样的 `unknown-method`,本桥也不会替它读一条会话、更不会替它打一次
213
+ * 上游余额端点。
214
+ *
215
+ * 一个能力名带两个方法,因为它们读的是同一件事的两面:一条会话下一次请求由
216
+ * 什么组成(上下文窗口取宿主自己广播的值,组成由本桥按文本长度估算并恒标
217
+ * `estimated: true`),以及某条 provider 路由背后账户的余额(DeepSeek 官方
218
+ * 口径,只在路由确实指向 `api.deepseek.com` 且凭据拿得到时才查官方端点,宿主
219
+ * 侧同一 provider + 凭据 60 秒最多一次上游请求)。
220
+ */
221
+ export declare const CAP_USAGE = "usage.v1";
222
+ /**
223
+ * 客户端在 `hello` 的 `cap` 数组里宣告它要读宿主自己的用量台账聚合。
224
+ *
225
+ * 与 {@link CAP_USAGE} 平级、独立声明:宣告它是 `usage.stats` 进入这个客户端
226
+ * 协议的唯一前提,不宣告的客户端——包括 `usage.v1` 出现之后、这个能力出现之前
227
+ * 写下的每一个客户端——收到的仍是 `unknown-method`,本桥也不会替它去读宿主
228
+ * 上 `dsh-usage` 插件的任何一条路由。
229
+ *
230
+ * 拆成独立能力而不是塞进 `usage.v1`,是因为它读的是另一件事:那两半读的是本
231
+ * 进程自己的事实(一个会话、一条路由的账户),这一半读的是另一个插件挂在这个
232
+ * 宿主上的 HTTP 路由,而那个插件可能根本没装。老客户端忽略这个未知名字即可,
233
+ * 它看到的能力表里多一项、别的什么都没有变。
234
+ */
235
+ export declare const CAP_USAGE_STATS = "usage.stats.v1";
236
+ /**
237
+ * Capability a client declares in `hello`'s `cap` array to be answered with
238
+ * byte-level increments instead of the whole roster or the whole board.
239
+ *
240
+ * Behind it, `session.list` and `board.snapshot` (the latter through the board
241
+ * plugin, §15) accept an opaque `since` token and answer either the whole set
242
+ * (`mode:"reset"`) or only what changed since the set that token names. A
243
+ * client that does not declare it — including every client written before this
244
+ * channel existed — is answered today's body plus the ignorable `mode` and
245
+ * `token` keys, with `mode` always `"reset"`.
246
+ */
247
+ export declare const CAP_DELTA = "delta.v1";
248
+ /**
249
+ * Capability a client declares in `hello`'s `cap` array to be told that an
250
+ * archived session is not in the roster at all.
251
+ *
252
+ * Unlike every capability beside it this one negotiates nothing: the bridge
253
+ * never transfers an archived session, whether or not a client declares it, so
254
+ * an older client simply receives the shorter roster it would have hidden
255
+ * anyway. The name is an announcement of that fact, so a client can stop
256
+ * filtering for itself: behind it, no `session.list` row is a session the
257
+ * host's archive set names, a row that does survive still carries
258
+ * `archived: false` under the same schema, and a live child of an archived
259
+ * parent still crosses with its `parentSessionId` — the parent id, not the
260
+ * parent row.
261
+ */
262
+ export declare const CAP_ROSTER_OMITS_ARCHIVED = "session.list.omit-archived.v1";
263
+ /**
264
+ * Capability a client declares in `hello`'s `cap` array to be answered a
265
+ * compact roster it can page.
266
+ *
267
+ * The declaration alone changes nothing: a listing that carries none of the
268
+ * compact parameters (`cwd`, `maxRows`, `after`) is answered exactly the body
269
+ * protocol v1 always served, so a client can opt into the name before it
270
+ * relies on any of it. Behind the parameters, a row drops its absolute `cwd`
271
+ * unless the request asks for it, drops its `updatedAt` when this connection
272
+ * already sent that id the same value, and a `maxRows`/`after` pair cuts the
273
+ * roster into pages ordered most recent first. The roster is the most repeated
274
+ * large reply on the link, so this is what lets a reconnect pay for the newest
275
+ * screenful plus a cursor instead of the whole list again.
276
+ */
277
+ export declare const CAP_ROSTER_COMPACT = "session.list.compact.v1";
278
+ /**
279
+ * Capability a client declares in `hello`'s `cap` array to be told that this
280
+ * bridge can page a session's durable history down to its oldest entry.
281
+ *
282
+ * The capability is an announcement and nothing more. `session.history.deep` is
283
+ * open to every paired connection, exactly as `session.history` is, because it
284
+ * is a pure read of the session store that costs no other client anything;
285
+ * declaring the capability is how a client learns the method exists, and a
286
+ * client that does not declare it loses only that knowledge.
287
+ */
288
+ export declare const CAP_SESSION_DEEP_HISTORY = "session.deep-history.v1";
289
+ /**
290
+ * Capability a client declares in `hello`'s `cap` array to fork a session.
291
+ *
292
+ * Declaring it is what makes `session.fork` part of that client's protocol at
293
+ * all: a client that does not declare it — including every client written
294
+ * before this channel existed — is refused `unknown-method`, and no fork is
295
+ * asked of the host on its behalf. Behind the name the bridge forwards one
296
+ * `SessionForkRequest` to the host's `session/fork` and hands back the host's
297
+ * own `SessionForkValue`, so what a fork point means stays the host's: an
298
+ * `atSeq` is the source event seq the fork includes, an omitted one is the
299
+ * newest finished turn, and a cut the host opens itself is closed by the host's
300
+ * own synthetic finishing event. Nothing about a fork is modelled or
301
+ * re-derived here.
302
+ */
303
+ export declare const CAP_SESSION_FORK = "session.fork.v1";
304
+ /**
305
+ * Capability a client declares in `hello`'s `cap` array to list a session's
306
+ * slash commands and skills and to run one of them.
307
+ *
308
+ * Declaring it is what makes `session.commands` and `session.command` part of
309
+ * that client's protocol at all: a client that does not declare it — including
310
+ * every client written before this channel existed — is refused both as unknown
311
+ * methods, exactly as those frames were refused before. Neither method is called
312
+ * on a connection's behalf either, so a client that never asks costs the host no
313
+ * registry read and no skill catalog read.
314
+ *
315
+ * The channel holds no events and no cache: a directory is read live on every
316
+ * call, so a command a plugin registered a moment ago and a skill withdrawn from
317
+ * one Agent preset are both reflected in the answer that follows.
318
+ */
319
+ export declare const CAP_COMMANDS = "commands.v1";
320
+ /**
321
+ * Capability a client declares in `hello`'s `cap` array to read the host's
322
+ * workspaces and its two registry-global session sets.
323
+ *
324
+ * Declaring it is what makes `workspace.list` part of that client's protocol at
325
+ * all: a client that does not declare it — including every client written before
326
+ * this channel existed — is refused that frame as an unknown method, and no
327
+ * registry is read on its behalf. Behind the name the answer is the host's own
328
+ * synchronous projection: one row per registered workspace in registry order,
329
+ * plus the complete archive and pin sets.
330
+ *
331
+ * The method is a read and nothing is cached, so a pin or an archive followed by
332
+ * another list reads the set the write left behind. That pair of calls is the
333
+ * whole refresh story of the session-admin channel: see {@link CAP_SESSION_ADMIN}.
334
+ */
335
+ export declare const CAP_WORKSPACE = "workspace.v1";
336
+ /**
337
+ * Capability a client declares in `hello`'s `cap` array to rename, pin,
338
+ * unpin, archive and unarchive a session.
339
+ *
340
+ * Declaring it is what makes those five methods part of that client's protocol
341
+ * at all: a client that does not declare it — including every client written
342
+ * before this channel existed — is refused each as an unknown method, and no
343
+ * write is asked of the host on its behalf.
344
+ *
345
+ * Every one of the five is forwarded one-to-one to the endpoint that already
346
+ * owns the semantics, so nothing about a title, a pin or an archive is modelled
347
+ * or re-derived here: a rename reaches `session/rename` — the endpoint that
348
+ * restores a cold session before it writes, which is why a client needs no
349
+ * resume path of its own — and the four set mutations reach
350
+ * `workspace/pinSession`, `workspace/unpinSession`, `workspace/archiveSession`
351
+ * and `workspace/unarchiveSession`. A host refusal crosses with its own code
352
+ * and text, `workspace/session-active` included.
353
+ *
354
+ * The channel publishes no event, because the host announces none of these
355
+ * writes as a cordis event a connection could fold into a delta: a rename
356
+ * appends one `session/title` log record and nothing else. A client re-reads
357
+ * after a write instead — the pin set through {@link CAP_WORKSPACE}, the roster
358
+ * through `session.list` — which is why one branch serves both capabilities.
359
+ */
360
+ export declare const CAP_SESSION_ADMIN = "session.admin.v1";
361
+ /**
362
+ * Capability a client declares in `hello`'s `cap` array to be sent frames
363
+ * compressed instead of as plain text.
364
+ *
365
+ * Declaring it is what allows the host to compress at all: a frame whose JSON
366
+ * text is at least 1024 UTF-8 bytes crosses as one WebSocket binary frame
367
+ * carrying raw DEFLATE (RFC 1951) of exactly that text, and a frame that does
368
+ * not get smaller still crosses as the text frame it always was. A client that
369
+ * does not declare it — including every client written before this capability
370
+ * existed — receives byte for byte the text frames protocol v1 always wrote.
371
+ *
372
+ * The direction is one way: a client still sends text frames only, and the
373
+ * 10 MiB frame cap stays measured on the text, before inflation.
374
+ */
375
+ export declare const CAP_FRAME_DEFLATE = "frame.deflate.v1";
54
376
  /**
55
377
  * Methods an unpaired connection may still call: the handshake itself and the
56
378
  * two pairing steps. Everything else answers `unpaired` — a caller can pair
@@ -63,6 +385,14 @@ export declare const KNOWN_METHODS: ReadonlySet<string>;
63
385
  export declare const CODE_UNPAIRED = "unpaired";
64
386
  export declare const CODE_UNKNOWN_METHOD = "unknown-method";
65
387
  export declare const CODE_INVALID_ARGS = "invalid-args";
388
+ /**
389
+ * `usage.session` 点名的会话在这个宿主上不存在:宿主自己的会话名册里没有它,
390
+ * 活会话存储里没有它,本进程也从未观察过它的任何事件。它与「会话存在但两项
391
+ * 读数都取不到」是两个答案,后者回的是空对象——一条刚刚开始、还什么都没广播
392
+ * 的会话,以及一条在桥重载前就存在的会话,都在那个状态里:存在而没读数,不是
393
+ * 不存在。
394
+ */
395
+ export declare const CODE_UNKNOWN_SESSION = "unknown-session";
66
396
  export declare const CODE_PROTO_UNSUPPORTED = "proto-unsupported";
67
397
  export declare const CODE_TOKEN_INVALID = "token-invalid";
68
398
  export declare const CODE_NONCE_INVALID = "nonce-invalid";
@@ -74,13 +404,172 @@ export declare const CODE_APPROVAL_UNKNOWN = "approval-unknown";
74
404
  * failures crossing this method keep their own codes instead.
75
405
  */
76
406
  export declare const CODE_QUESTION_UNKNOWN = "question-unknown";
407
+ /**
408
+ * The bridge could not read the questions it is holding, so it cannot say which
409
+ * ones are still live. The answer is deliberately not an empty list: a client
410
+ * retires every card a COMPLETE list does not carry, and a read that failed is
411
+ * not a complete one — it is a bridge that cannot answer this question today.
412
+ */
413
+ export declare const CODE_QUESTION_LIST_UNAVAILABLE = "question-list-unavailable";
414
+ /**
415
+ * The named session is a delegated child whose durable parent is not a session
416
+ * this connection may read. The bridge follows an addressable child and refuses
417
+ * an unaddressable one, rather than reading it blind.
418
+ */
419
+ export declare const CODE_SESSION_NOT_FOLLOWABLE = "session-not-followable";
77
420
  export declare const CODE_SNAPSHOT_UNAVAILABLE = "snapshot-unavailable";
421
+ /**
422
+ * This host composes no job registry, so it has no background jobs to publish.
423
+ * The capability stays advertised — it is a fact about this bridge, not about
424
+ * what a particular host mounts — and only a call that needs the registry fails.
425
+ */
426
+ export declare const CODE_JOBS_UNAVAILABLE = "jobs-unavailable";
427
+ /**
428
+ * This host serves no endpoint behind the command channel: no `commands/list`,
429
+ * no `commands/execute` or no `skills/list`, which the gateway itself reports
430
+ * as an endpoint nothing exports. The capability stays advertised — it is a fact
431
+ * about this bridge, not about what a particular host mounts — and only a call
432
+ * that needs those endpoints fails.
433
+ */
434
+ export declare const CODE_COMMANDS_UNAVAILABLE = "commands-unavailable";
435
+ /**
436
+ * This host serves no squad domain this bridge can reach: no answer to the
437
+ * plugin's state route over loopback, no readable ledger beside it, or a body
438
+ * this build cannot read as one squad domain. The capability stays advertised —
439
+ * it is a fact about this bridge, not about what a particular host mounts — and
440
+ * only a call that needs the domain fails. A refusal the `dsh-agents` plugin
441
+ * itself raised crosses with the plugin's own code instead (`team-not-found`,
442
+ * `member-not-found`, `preset-unknown`, `workspace-required` and their
443
+ * neighbours).
444
+ */
445
+ export declare const CODE_SQUADS_UNAVAILABLE = "squads-unavailable";
446
+ /**
447
+ * The definitions are readable but the two run commands cannot be served: this
448
+ * host answered no run route over loopback, and the read-only ledger fallback
449
+ * cannot launch anything. Failing closed is the point — a client is told the
450
+ * capability is not served here rather than shown a run that never started.
451
+ */
452
+ export declare const CODE_SQUADS_RUN_UNAVAILABLE = "squads-run-unavailable";
78
453
  export declare const CODE_SNAPSHOT_TOO_LARGE = "snapshot-too-large";
79
454
  export declare const CODE_INTERNAL = "internal";
80
455
  /** Protocol version this package speaks. */
81
456
  export declare const PROTO = 1;
82
- /** Minor version this package speaks. */
83
- export declare const MINOR = 0;
457
+ /**
458
+ * Minor version this package speaks.
459
+ *
460
+ * 20 when the usage stats channel shipped: behind {@link CAP_USAGE_STATS} a
461
+ * client may call {@link METHOD_USAGE_STATS} and read the host's own usage
462
+ * ledger — today, this month and one row per local day — and behind the same
463
+ * {@link CAP_USAGE} this bridge now also answers `usage.session` with a
464
+ * `modelContextWindow` when the model catalog of the session's route declares
465
+ * one, so a client reads one new reply body and one new optional key off the
466
+ * wire and has to read the name before it asks. The stats half is independent
467
+ * of {@link CAP_USAGE} on purpose: it reads another plugin's HTTP routes, which
468
+ * a host may not mount at all, so a client written before this name existed
469
+ * keeps the two readings it had and the bridge reads no route on its behalf.
470
+ * No frame, no topic, no existing method and no existing key changes shape.
471
+ * 19 when the usage channel shipped: behind {@link CAP_USAGE} a client may call
472
+ * {@link METHOD_USAGE_SESSION} and read one session's context window and its
473
+ * request's estimated composition, and {@link METHOD_USAGE_BALANCE} and read the
474
+ * account behind one provider route, so it reads two new reply bodies off the
475
+ * wire and has to read the name before it asks — a bridge below this one answers
476
+ * `unknown-method` for both. No frame, no topic and no existing method changes
477
+ * shape.
478
+ * 18 when one card learned to lay out several sessions (§30 of
479
+ * `docs/protocol-v1.md` in the iphone_remote_use_dsh repository): `content-state`
480
+ * gains the optional `rows` key, so a phone reads up to three sessions off one
481
+ * lock-screen card instead of having to hold one card per session. It is a pure
482
+ * addition — no new method, no new capability name, no existing key or topic
483
+ * changes shape — so the minor counts the key alone, and a client that reads 18
484
+ * knows the order of the rows it is handed is the bridge's rather than one it
485
+ * has to derive.
486
+ * 17 when the live-activity channel shipped (§29.2): this bridge now sends the
487
+ * lock-screen card a suspended app cannot update itself, addressed to the
488
+ * per-card APNs tokens {@link METHOD_PUSH_REGISTER} already carries and projected
489
+ * per session rather than per bridge. It is a pure addition — no new method, no
490
+ * new capability name, and no existing frame, field or topic changes shape — so
491
+ * the minor counts it alone: a client that wants a card has to read 17 before it
492
+ * registers one, because a bridge below this one has no sending path at all and
493
+ * would answer `ok:true` to a registration it can never use.
494
+ * 16 when the push channel shipped: behind {@link CAP_PUSH} a client may call
495
+ * {@link METHOD_PUSH_REGISTER} and have the device table remember an APNs token,
496
+ * so a phone learns a turn ended — or that a question is waiting — while its
497
+ * socket is not open. No frame, no topic and no existing method changes shape;
498
+ * the minor is raised because a new reply body and a new announcement appear on
499
+ * the wire, and because a client has to read the name before it registers.
500
+ * 15 when the squads channel shipped: behind {@link CAP_SQUADS} a client may
501
+ * call {@link METHOD_SQUADS_STATE}, {@link METHOD_SQUADS_LIST},
502
+ * {@link METHOD_SQUADS_RUNS}, {@link METHOD_SQUADS_RUN_MEMBER} and
503
+ * {@link METHOD_SQUADS_RUN_SQUAD}, so it reads five new reply bodies off the wire
504
+ * and drives the squad domain instead of deriving its agents from anything else.
505
+ * 14 when the session-admin channel shipped: behind {@link CAP_WORKSPACE} a
506
+ * client may call {@link METHOD_WORKSPACE_LIST} and read the host's workspaces
507
+ * with both registry-global session sets, and behind {@link CAP_SESSION_ADMIN}
508
+ * it may call {@link METHOD_SESSION_RENAME}, {@link METHOD_SESSION_PIN},
509
+ * {@link METHOD_SESSION_UNPIN}, {@link METHOD_SESSION_ARCHIVE} and
510
+ * {@link METHOD_SESSION_UNARCHIVE}, so a phone long-presses a roster row for the
511
+ * same five actions the desktop offers it.
512
+ * 13 when the question list shipped: behind {@link CAP_QUESTION_LIST} a client
513
+ * may call {@link METHOD_QUESTION_LIST} and be answered the questions this
514
+ * bridge is still holding, so it reads a new reply body off the wire and the
515
+ * number rises with it. It is what lets a phone stop trusting a card it holds:
516
+ * the one retirement signal before it was `question.request` with
517
+ * `state: "settled"`, which a phone that was disconnected when the last client
518
+ * left never receives.
519
+ * 12 when the command channel shipped: behind {@link CAP_COMMANDS} a client may
520
+ * call {@link METHOD_SESSION_COMMANDS} and {@link METHOD_SESSION_COMMAND}, so it
521
+ * reads a new reply body off the wire and the number rises with it.
522
+ * 11 when the fork channel shipped: behind {@link CAP_SESSION_FORK} a client may
523
+ * call {@link METHOD_SESSION_FORK} and receive the host's own fork answer, so a
524
+ * phone branches a session that inherits the context of the one it forked. This
525
+ * is the second of two appends cut from 9 — the snapshot-`since` channel took
526
+ * 10 on the integration branch first — so the number steps over the one already
527
+ * on `dev`: the minor counts additions to this protocol, and a later landing
528
+ * steps over the earlier one instead of reusing its number.
529
+ * 10 when the snapshot became incremental on request: behind
530
+ * {@link CAP_SESSION_SNAPSHOT_SINCE} a `session.snapshot` that names `sinceSeq`
531
+ * is answered either the entries above that watermark or a full baseline
532
+ * carrying `mode` and `reset`, so a client reads a new reply shape off the
533
+ * wire and the number rises with it.
534
+ * 9 when the compact roster shipped: behind {@link CAP_ROSTER_COMPACT} a
535
+ * `session.list` that names one of the compact parameters is answered a
536
+ * shorter row and may be cut into pages, so a client reads a new row schema
537
+ * off the wire and the number rises with it.
538
+ * 8 when the outbound frame form became a capability: behind
539
+ * {@link CAP_FRAME_DEFLATE} a declaring client may be answered in binary
540
+ * frames carrying raw DEFLATE of the text, so the minor is raised for a change
541
+ * a client reads off the wire rather than for a name alone.
542
+ * 7 when the two channels met: the agent channel and the durable history
543
+ * channel each raised 5 to 6 on its own branch, so the protocol that carries
544
+ * both is 7. 6 when the agent channel shipped: behind {@link CAP_AGENTS}
545
+ * `presets.list` forwards the host's Agent-preset roster and `session.create`
546
+ * hands the host one creation request, both verbatim. 6 was also the durable
547
+ * history channel on its own: behind {@link CAP_SESSION_DEEP_HISTORY} a client
548
+ * may call {@link METHOD_SESSION_HISTORY_DEEP} and walk a session's store back
549
+ * to its oldest entry, below the follow window `session.history` slices. 5 when
550
+ * the roster stopped carrying archived sessions: behind
551
+ * {@link CAP_ROSTER_OMITS_ARCHIVED} `session.list` names no session the host's
552
+ * archive set holds, so a session archived between two listings arrives as a
553
+ * removal and one restored as a change. 4 when byte-level increments shipped:
554
+ * behind {@link CAP_DELTA} `session.list` and `board.snapshot` answer a reset
555
+ * or a delta against a `since` token. 3 was
556
+ * the background-job channel — behind {@link CAP_JOBS} a client may call
557
+ * `jobs.list` and receive `jobs.changed`. 2 was the subagent thread —
558
+ * a `user-message` delta may carry an `actor` and a `subagent` delta exists
559
+ * behind {@link CAP_SUBAGENT_THREAD}. 1 was the extension seam — a mounted
560
+ * plugin may answer methods outside {@link KNOWN_METHODS} once the client
561
+ * declares the capability that plugin requires. No addition changed the major
562
+ * version, a frozen field, or an existing method or topic name.
563
+ */
564
+ export declare const MINOR = 20;
565
+ /**
566
+ * The capabilities this bridge itself serves, as `hello` advertises them.
567
+ *
568
+ * A capability a mounted plugin adds is not listed here: the bridge cannot know
569
+ * what it is not the author of. A client learns such a capability from the
570
+ * plugin's own documentation, exactly as it did before this list existed.
571
+ */
572
+ export declare const SERVED_CAPABILITIES: readonly string[];
84
573
  /** `server` field of the hello response. */
85
574
  export declare const SERVER_ID = "dsh-remote-bridge";
86
575
  /** Exact route path of the bridge's WebSocket endpoint. */