@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
@@ -9,8 +9,8 @@ export type PairEntryProps = PropsLocale<'remote-bridge'> & {
9
9
  copy: (text: string) => Promise<boolean>;
10
10
  };
11
11
  /**
12
- * Render the pairing seat trigger and, when open, the panel.
12
+ * Render the pairing seat trigger and, while it is open or leaving, the panel.
13
13
  * @param props - the footer seat's column state, the injected actions and the locale seat.
14
- * @returns the trigger and the panel portal.
14
+ * @returns the trigger and, when present, the official Modal holding the panel.
15
15
  */
16
16
  export declare function PairEntry({ wide, read, copy, t }: PairEntryProps): import("react").JSX.Element;
@@ -43,13 +43,21 @@ export interface PairPanelProps {
43
43
  /** This page's own `host:port`, named in the origin warning. */
44
44
  host: string;
45
45
  copy: PairCopyState;
46
+ /** Whether the modal is mounted at all (the entry keeps it for the leave leg). */
47
+ showing: boolean;
48
+ /** Whether the leave leg is running; the card stays mounted until it ends. */
49
+ closing: boolean;
50
+ /** The panel element's id, so the seat trigger can name what it expands. */
51
+ id: string;
46
52
  onClose(): void;
53
+ /** The leave leg reported completion: the entry may unmount the modal now. */
54
+ onExited(): void;
47
55
  onRefresh(): void;
48
- onCopy(token: string): void;
56
+ onCopy(payload: string): void;
49
57
  }
50
58
  /**
51
59
  * Render the pairing panel.
52
60
  * @param props - locale seat, view state, clock, page host and actions.
53
61
  * @returns the panel element tree.
54
62
  */
55
- export declare function PairPanel({ t, state, now, host, copy, onClose, onRefresh, onCopy }: PairPanelProps): import("react").JSX.Element;
63
+ export declare function PairPanel({ t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy, }: PairPanelProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
2
+ export type UiPresentRowProps = PropsLocale<'remote-bridge'> & {
3
+ /** The stage the Tool slot published (`preparing`, `start` or `result`). */
4
+ readonly phase?: unknown;
5
+ /** The call material of that stage: the argument view, argument text, meta. */
6
+ readonly block?: unknown;
7
+ };
8
+ /**
9
+ * Render one card, or the neutral line of a call that carries no page.
10
+ * @param props - the stage, the call material and the locale seat.
11
+ * @returns the card body placed inside the official tool row.
12
+ */
13
+ export declare function UiPresentRow({ phase, block, t }: UiPresentRowProps): import("react").JSX.Element;
@@ -1,18 +1,10 @@
1
1
  /**
2
- * Inline SVG icons for the pairing panel (16px stroke style matching the
3
- * shell's nav icons). Held here rather than imported from
4
- * `@deepseek-ai/dsh-client-ui-primitives` so the panel's rendered tree carries
5
- * no closure-factory bundle import: the component stays renderable under the
6
- * package's own test runner.
2
+ * The pairing seat's QR glyph. It is the one icon this package draws itself
3
+ * (I4 exception, recorded here): the official icon set in
4
+ * `@deepseek-ai/dsh-client-ui-primitives` ships no QR or scan metaphor, and a
5
+ * text or emoji stand-in is not an icon (I1). Every other glyph this panel
6
+ * needs — close, copy, check, refresh, warning — comes from that set.
7
7
  */
8
8
  import type { SVGProps } from 'react';
9
9
  /** A QR-symbol glyph: three finder squares plus a payload dot. */
10
10
  export declare function QrIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
11
- /** Copy glyph. */
12
- export declare function CopyIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
13
- /** Check glyph for the transient copied state. */
14
- export declare function CheckIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
15
- /** Close glyph for the panel header. */
16
- export declare function CloseIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
17
- /** Refresh glyph for the mint-again action. */
18
- export declare function RefreshIcon(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -11,6 +11,10 @@
11
11
  * the events are untouched — and it does not touch `dsh-remote-web-ui`'s pairing
12
12
  * service, its roster, or its browser cookie path.
13
13
  *
14
+ * The half also draws the transcript side of §35.11: one keyed `tool.call.toolview`
15
+ * entry renders a `ui.present` call's whole page in a controlled frame, while the
16
+ * phone stays the only place an action can be answered.
17
+ *
14
18
  * Export discipline (packages/AGENTS.md): the /client surface carries only what
15
19
  * cordis loading needs plus types.
16
20
  */
@@ -1,29 +1,31 @@
1
1
  /**
2
- * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy.
2
+ * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy and
3
+ * the header of an interactive card (§35.11).
3
4
  *
4
- * The panel has one job — show the operator the one-shot bootstrap token as a
5
- * QR symbol plus its plaintext — so the copy is dominated by the two facts a
6
- * reader has to get right: where the phone's origin points (the public relay,
7
- * never this machine's loopback address) and why the token vanished (30 s, one
8
- * use, or a fresh mint).
5
+ * The panel has one job — put the live one-shot code in front of the operator as
6
+ * a QR symbol — so its copy carries exactly four things: what to do with the
7
+ * symbol, how long it lives, which address the phone will actually dial, and why
8
+ * the code is single-use. No key states how the host finds its public address:
9
+ * that is an implementation fact the reader cannot act on.
10
+ *
11
+ * The card's keys say only what the transcript row can act on: whether the page
12
+ * is still waiting for the operator, that it is over, that this desktop renders
13
+ * without answering, and that a page carrying nothing or too much draws a
14
+ * sentence instead of a frame.
9
15
  */
10
16
  /** Simplified Chinese dictionary (the key-set source of truth). */
11
17
  export declare const zh: {
12
18
  readonly 'entry.label': "配对手机(协议 v1)";
13
19
  readonly title: "协议 v1 配对";
14
- readonly subtitle: "用手机 App 扫描下方二维码,即可以协议 v1 配对这台宿主。配对码由本机签发,仅在本机可读。";
20
+ readonly subtitle: "用手机 App 扫描二维码,即可让手机以协议 v1 连上这台宿主。配对码由本机签发,只在本机显示。";
15
21
  readonly 'state.reading': "正在取配对码…";
16
22
  readonly 'pair.qrLabel': "配对二维码";
17
- readonly 'pair.payloadLabel': "二维码内容(可复制后粘贴到手机)";
18
23
  readonly 'pair.countdown': "剩余 {s} 秒";
19
- readonly 'pair.expired': "配对码已过期(30 秒)";
20
- readonly 'pair.expiredHint': "过期的配对码不会被手机接受,请重新取码。";
21
- readonly 'pair.usedHint': "配对码一次性:手机调用 pair.begin 的瞬间即作废,重新取码也会作废上一张。";
24
+ readonly 'pair.expired': "配对码已过期";
22
25
  readonly 'pair.refresh': "重新取码";
23
- readonly 'origin.title': "没能自动定位公网地址,二维码只装裸配对码";
24
- readonly 'origin.body': "这台机器既没有 DSH_REMOTE_PUBLIC_BASE_URL,也没有中继注册表记录,因此无法把地址写进二维码。请先在手机 App 里把连接地址设成你的公网中继(形如 wss://<id>.dsh-market.com),再扫上面的码;本页所在的 {host} 只有本机能连,手机连不上。";
25
- readonly 'origin.located.title': "手机将直接连到公网中继(地址已写进二维码)";
26
- readonly 'origin.located.body': "二维码里已经带上 {origin}:手机扫一次就同时设好连接地址与配对码,不需要手填任何东西。";
26
+ readonly 'pair.usedHint': "配对码一次性有效:手机一开始配对即作废,重新取码也会作废上一张。";
27
+ readonly 'origin.located': "手机将连到 {origin}";
28
+ readonly 'origin.missing': "没有找到公网地址:请先在手机里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。";
27
29
  readonly 'forbidden.title': "这个页面不是从本机打开的";
28
30
  readonly 'forbidden.body': "配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。";
29
31
  readonly 'failed.title': "取配对码失败";
@@ -35,6 +37,13 @@ export declare const zh: {
35
37
  readonly 'action.copied': "已复制";
36
38
  readonly 'action.copyFailed': "复制失败";
37
39
  readonly 'action.retry': "重试";
40
+ readonly 'card.waiting': "等你操作";
41
+ readonly 'card.settled': "已结算";
42
+ readonly 'card.answerOnPhone': "在手机上作答";
43
+ readonly 'card.interacted': "已收到页面上的操作,但桌面端不作答:在手机上作答";
44
+ readonly 'card.frameLabel': "整页卡片";
45
+ readonly 'card.empty': "这次调用没有可渲染的页面";
46
+ readonly 'card.oversize': "页面超出大小上限,未渲染";
38
47
  };
39
48
  /** English dictionary, key-for-key with the zh source. */
40
49
  export declare const en: Record<RemoteBridgeKey, string>;
@@ -10,11 +10,9 @@ export declare const PLUGIN_ATTR = "remote-bridge";
10
10
  export declare const PART_ENTRY = "entry";
11
11
  /** The modal panel root. */
12
12
  export declare const PART_PANEL = "panel";
13
- /** The QR symbol's wrapper — it also mirrors the encoded string. */
13
+ /** The QR symbol's box — it also mirrors the encoded string. */
14
14
  export declare const PART_QR = "qr";
15
- /** The plaintext pairing code row. */
16
- export declare const PART_TOKEN = "token";
17
- /** A state notice: the origin warning, or a refusal the host raised. */
15
+ /** A refusal the host raised. */
18
16
  export declare const PART_NOTICE = "notice";
19
17
  /** The mint-again button. */
20
18
  export declare const PART_REFRESH = "refresh";
@@ -23,6 +21,12 @@ export declare const PART_COPY = "copy";
23
21
  /**
24
22
  * Attribute carrying the exact string the QR symbol encodes, so the operator
25
23
  * (and a UI check) can compare it against the host route's answer without
26
- * decoding the symbol. The same string is already on screen in plaintext.
24
+ * decoding the symbol. It is the only machine trace the panel renders.
27
25
  */
28
26
  export declare const QR_VALUE_ATTR = "data-dsh-qr-value";
27
+ /**
28
+ * Marks the QR part of a code that has run out of time. Expiry is state on the
29
+ * existing part, not a new part value: the cross-repository part enum is frozen
30
+ * and a plugin may not extend it for one visual state.
31
+ */
32
+ export declare const EXPIRED_ATTR = "data-expired";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The one seam through which this package registers its keyed Tool view.
3
+ *
4
+ * `tool.call.toolview` is declared by `@deepseek-ai/dsh-client-ui-tool`
5
+ * (`lib/types/client/contract/slots.d.ts`). That package is not installed in this
6
+ * workspace, so its types cannot be imported — a type-only import would itself be
7
+ * a new dependency, and a local `declare module` extension of the SDK's `SlotMap`
8
+ * would duplicate a contract another package owns and collide with the real
9
+ * declaration wherever both are loaded. This module therefore narrows
10
+ * `ctx.slots` to the two members the registration needs and states the slot's own
11
+ * shape locally:
12
+ *
13
+ * - the slot is keyed and session-scoped, and its key is the wire Tool name
14
+ * (`ui.present`), which is what makes one registration draw the card's body
15
+ * without shadowing the official `tool-call` renderer;
16
+ * - the owner publishes the call identity plus a stage union, mirrored here from
17
+ * the upstream `ToolCallPhaseProps`: `preparing`, `start` and `result`. The
18
+ * row reads the arguments at every stage but `result`, which is the only arm
19
+ * that carries the result node.
20
+ *
21
+ * Upstream changing that shape is a change to this file: the phase names, the
22
+ * keyed dispatch and the `locale` seat are the three facts the mirror carries.
23
+ *
24
+ * Technical debt, recorded rather than hidden: when this package next takes a
25
+ * dependency pass, adding `@deepseek-ai/dsh-client-ui-tool` as a devDependency
26
+ * lets this seam be replaced by `PropsRuntime<'tool.call.toolview'>` and by the
27
+ * typed `ctx.slots.register` overload directly.
28
+ * @module dsh-remote-bridge/client/toolview-slot
29
+ */
30
+ import type { ComponentType } from 'react';
31
+ import { type UiPresentRowProps } from './UiPresentRow.tsx';
32
+ /** The keyed Tool view slot the official row dispatches into. */
33
+ export declare const TOOLVIEW_SLOT = "tool.call.toolview";
34
+ /** The wire Tool name this package renders: the keyed cell it claims. */
35
+ export declare const PRESENT_TOOL = "ui.present";
36
+ /** The registration options this seam needs. */
37
+ export interface ToolviewRegistration {
38
+ /** Exact SlotMap key. */
39
+ readonly name: 'tool.call.toolview';
40
+ /** Keyed cell: the wire Tool name the owner dispatches by. */
41
+ readonly key: string;
42
+ /** Dictionary namespace the render machinery synthesizes `t` from. */
43
+ readonly locale: string;
44
+ }
45
+ /** The narrowed face of `ctx.slots` this package uses. */
46
+ export interface ToolviewSlotPort {
47
+ /** Run `seats` once the slot is declared; drop them if the declarer leaves. */
48
+ inject(name: string, seats: () => (() => void) | Iterable<() => void>): void;
49
+ /** Contribute one view to one keyed cell; the answer is its disposer. */
50
+ register(options: ToolviewRegistration, view: ComponentType<UiPresentRowProps>): () => void;
51
+ }
52
+ /** The host this seam needs: the client Context, structurally. */
53
+ export interface ToolviewSlotHost {
54
+ readonly slots: unknown;
55
+ }
56
+ /**
57
+ * Contribute the `ui.present` card into the Tool row.
58
+ *
59
+ * The contribution is declaration-aware: `inject` waits for the official slot
60
+ * declaration, so a GUI composed without a Tool layer has no keyed cell and thus
61
+ * no card — that is the capability being absent, not an error to report. A
62
+ * registration refused by the registry (an occupied cell at the same priority)
63
+ * is swallowed the same way it is for this package's other seat, so one occupied
64
+ * slot never takes the sidebar entry down with it.
65
+ * @param host - the client Context.
66
+ * @param locale - the dictionary namespace this package registered.
67
+ */
68
+ export declare function registerPresentToolview(host: ToolviewSlotHost, locale: string): void;
@@ -0,0 +1,160 @@
1
+ /**
2
+ * The transcript reading of one `ui.present` call (protocol §35.10, §35.11):
3
+ * what the desktop row draws, decided without touching the DOM.
4
+ *
5
+ * A card has two sources and neither may be dropped. While the call is still
6
+ * running the arguments are the only material on the wire, so the page comes out
7
+ * of `args` and the header says the operator has not acted yet. Once the result
8
+ * lands, the presentation payload `meta.ui` is the card's own record — its
9
+ * `state`, its `title` and the very document that crossed — and the arguments
10
+ * are only the fallback for a result that carries no payload.
11
+ *
12
+ * The argument view is read by shape rather than by import: a toolview receives a
13
+ * lazy `PartialArguments` when the call arrived as argument text and a plain
14
+ * payload when the call was dispatched as an object, and §35.10 fixes neither. A
15
+ * field reader therefore answers from all three shapes it can meet (lazy view,
16
+ * JSON text, parsed object) so a page is never lost to a shape this row did not
17
+ * anticipate.
18
+ *
19
+ * Two rules live here rather than in the renderer. A document above 256 KiB is
20
+ * never handed to a frame (§35.2 caps it on this side too), and a frame message is
21
+ * read by shape alone: the sandboxed document has an opaque origin, so identity
22
+ * comes from the frame element the row owns, never from what the message claims.
23
+ * Nothing read here is forwarded anywhere — the desktop renders and does not
24
+ * answer (§35.11).
25
+ * @module dsh-remote-bridge/client/ui-card
26
+ */
27
+ import { type UiState } from '../core/ui.ts';
28
+ /**
29
+ * The Tool slot's stage literals, as the composing contract publishes them
30
+ * (`ToolCallPhaseProps`). `result` is the settled arm; every other stage still
31
+ * has the call's arguments only.
32
+ */
33
+ export type PresentPhase = 'preparing' | 'start' | 'result';
34
+ /** One card as a row draws it, whichever source it came from. */
35
+ export interface PresentCard {
36
+ /** The whole self-contained document, `<!doctype html>` first. */
37
+ readonly html: string;
38
+ /** Whether the card still holds the call (`open`) or is only a notice. */
39
+ readonly state: UiState;
40
+ /** One header line; absent when the presenter named none. */
41
+ readonly title?: string;
42
+ /** The presenter's suggested first height in points; the measurement wins. */
43
+ readonly height?: number;
44
+ /** `"<sessionId>/<callId>"`, when the payload carries the card identity. */
45
+ readonly key?: string;
46
+ }
47
+ /** What one row read produced. */
48
+ export type PresentRead = {
49
+ readonly kind: 'card';
50
+ readonly card: PresentCard;
51
+ }
52
+ /** A page over {@link UI_HTML_MAX_BYTES}: refused visibly, never rendered. */
53
+ | {
54
+ readonly kind: 'oversize';
55
+ }
56
+ /** No page in either source: the row keeps a neutral line instead of a card. */
57
+ | {
58
+ readonly kind: 'empty';
59
+ };
60
+ /** One theme token as it is handed to a card's document. */
61
+ export type ThemeToken = readonly [name: string, value: string];
62
+ /**
63
+ * The theme tokens a card inherits from the GUI's own root element.
64
+ *
65
+ * Four roles and no more: the page needs a text colour it can trust, a quieter
66
+ * one, a surface and a border. A token the running theme does not define is
67
+ * simply not injected — the page then falls back to its own CSS, which is why an
68
+ * unreadable theme is a degraded look rather than a broken card.
69
+ */
70
+ export declare const CARD_THEME_TOKENS: readonly ["--dsw-alias-label-primary", "--dsw-alias-label-secondary", "--dsw-alias-bg-layer-1", "--dsw-alias-border-l2"];
71
+ /** The one sandbox value a card frame is allowed (§35.7, §35.11). */
72
+ export declare const FRAME_SANDBOX = "allow-scripts";
73
+ /**
74
+ * The permissions a card frame is explicitly denied.
75
+ *
76
+ * §35.7 refuses camera, microphone, location and clipboard reads on both ends.
77
+ * A sandboxed document already has an opaque origin, and this policy states the
78
+ * denial where the browser enforces it rather than leaving it to the default.
79
+ */
80
+ export declare const FRAME_PERMISSIONS: string;
81
+ /** The message type the injected reporter uses to publish the content height. */
82
+ export declare const FRAME_HEIGHT_CHANNEL = "dsh-ui-card-height";
83
+ /** The first height of a card whose presenter suggested none. */
84
+ export declare const CARD_DEFAULT_HEIGHT = 320;
85
+ /** The smallest and largest heights a measured card may take, in CSS pixels. */
86
+ export declare const CARD_MIN_HEIGHT = 96;
87
+ export declare const CARD_MAX_HEIGHT = 720;
88
+ /**
89
+ * Read the presentation payload a settled call carries (§35.10).
90
+ *
91
+ * The payload is the card's own record, so it is read only when it is one: a
92
+ * `html` that is not a string is no card at all, which keeps a malformed payload
93
+ * from becoming an empty frame. `state` outside the frozen pair reads as
94
+ * `settled` — a result-phase payload is a finished card by definition, and the
95
+ * `open` arm exists for a presenter that answers before its first event.
96
+ * @param meta - the result's `meta` value, carried verbatim.
97
+ * @returns the card, or undefined when this result carries no presentation.
98
+ */
99
+ export declare function readPresentation(meta: unknown): PresentCard | undefined;
100
+ /** @returns whether one document is within {@link UI_HTML_MAX_BYTES}. */
101
+ export declare function cardHtmlFits(html: string): boolean;
102
+ /**
103
+ * Decide what the row draws at one stage of the call.
104
+ *
105
+ * The settled stage prefers `meta.ui`, because that payload is the presentation
106
+ * the host published and carries its ending. A result without the payload falls
107
+ * back to the arguments — and then the card is still over, so it reads
108
+ * `settled`: the stage decides that, not a field that is absent.
109
+ * @param phase - the stage the Tool slot published.
110
+ * @param block - the call material of that stage.
111
+ * @returns a card, a refusal, or the neutral line.
112
+ */
113
+ export declare function presentReadOf(phase: unknown, block: unknown): PresentRead;
114
+ /**
115
+ * Read the theme tokens off a computed style, skipping the ones it does not carry.
116
+ * @param style - the GUI root element's computed style.
117
+ * @returns the tokens, in {@link CARD_THEME_TOKENS} order.
118
+ */
119
+ export declare function cardThemeTokens(style: {
120
+ getPropertyValue(name: string): string;
121
+ }): readonly ThemeToken[];
122
+ /**
123
+ * Build the document handed to a card's frame.
124
+ *
125
+ * The agent's page stays byte for byte what crossed; this only adds the theme
126
+ * variables its CSS may use and the height reporter. Insertion happens ahead of
127
+ * the closing tags rather than at the start of the string, because a snippet
128
+ * placed before `<!doctype html>` would put the document into quirks mode.
129
+ * @param html - the card document as the presenter wrote it.
130
+ * @param tokens - the theme tokens to hand the page.
131
+ * @param channel - the message type the reporter publishes on.
132
+ * @returns the frame document; the original page when it takes no injection.
133
+ */
134
+ export declare function frameDocument(html: string, tokens: readonly ThemeToken[], channel?: string): string;
135
+ /** One message a card's frame sent the parent. */
136
+ export type FrameEvent = {
137
+ readonly kind: 'height';
138
+ readonly height: number;
139
+ }
140
+ /** Anything else the page posted: an action this desktop never answers. */
141
+ | {
142
+ readonly kind: 'interaction';
143
+ };
144
+ /**
145
+ * Read one message a card's frame posted.
146
+ *
147
+ * Only the shape is read. The frame's origin is opaque, so the parent identifies
148
+ * the sender by the frame element it owns; what is left to decide here is what
149
+ * the payload means, and a page's own `{type, payload}` action means nothing
150
+ * beyond "the operator tried to act here".
151
+ * @param data - the message payload.
152
+ * @returns the event, or undefined when the message is not one this row reads.
153
+ */
154
+ export declare function frameEventOf(data: unknown): FrameEvent | undefined;
155
+ /**
156
+ * Hold a measured height inside the range a card may occupy.
157
+ * @param height - the content height the frame reported, in CSS pixels.
158
+ * @returns the height the card takes.
159
+ */
160
+ export declare function clampCardHeight(height: number): number;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The command channel's projection: the host's slash-command registry and one
3
+ * session's skill catalog folded into the single flat directory a phone lists.
4
+ *
5
+ * Nothing here is stateful. Every answer is read from the host on the call that
6
+ * answers it — no cache, no event, no snapshot — so a command a plugin
7
+ * registered a moment ago and a skill the session's own preset withdrew are
8
+ * both reflected in the next answer, and a phone never renders a directory that
9
+ * this bridge remembered on its behalf.
10
+ *
11
+ * The `line` of an item is the whole text a client completes into its draft,
12
+ * separator space included, because both host surfaces resolve a bare gesture
13
+ * only when whitespace or the end of the text follows the name: the command
14
+ * registry splits a line into name and input at that separator, and a skill
15
+ * gesture is `/(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/` in
16
+ * `@deepseek-ai/dsh-tool-skill`. A skill line is therefore text a client writes
17
+ * and the host reads out of the submitted prompt, never a command line: a skill
18
+ * is not registered with the command registry, so `commands/execute` answers
19
+ * `undefined` for it — which is exactly what a caller of `session.command` is
20
+ * told with `matched: false`.
21
+ * @module dsh-remote-bridge/core/commands
22
+ */
23
+ /** One row of the directory: a slash command or a skill, as the phone renders it. */
24
+ export interface CommandItem {
25
+ /** The host's own name for the row, without a leading slash. */
26
+ readonly name: string;
27
+ /** The host's own one-line summary, verbatim. */
28
+ readonly description: string;
29
+ /** Which host catalog the row came from; the two never mix order. */
30
+ readonly kind: 'command' | 'skill';
31
+ /** The complete draft text that invokes this row. */
32
+ readonly line: string;
33
+ }
34
+ /**
35
+ * Fold the host's two catalogs into one directory: every command first, in the
36
+ * order the host listed them, then every skill, in the order the host listed
37
+ * them. Neither list is re-sorted, de-duplicated or cut into pages — a name
38
+ * both catalogs carry stays two rows, because the two rows do different things.
39
+ * @param commands - the `commands/list` answer, as it arrived.
40
+ * @param skills - the `skills/list` answer's `skills` array, as it arrived.
41
+ * @returns the rows a client renders, in the one order this protocol promises.
42
+ */
43
+ export declare function commandItems(commands: readonly unknown[], skills: readonly unknown[]): readonly CommandItem[];
44
+ /**
45
+ * Whether a gateway failure means this host serves no endpoint behind the
46
+ * channel at all, rather than refusing this one call.
47
+ *
48
+ * The gateway reports an endpoint nothing exports as `invocation-unavailable`
49
+ * and a withdrawn strict definition as `definition-unavailable`; both leave the
50
+ * call with nowhere to go, which is the one case this bridge answers with its
51
+ * own `commands-unavailable`. A service that is merely still activating keeps
52
+ * its own code: that window is retried before it arrives here, and a retried
53
+ * failure is a broken deployment rather than an absent channel.
54
+ *
55
+ * Both spellings of each code are recognized, exactly as `gateway-errors.ts`
56
+ * recognizes them for the activation window.
57
+ * @param code - the failure's own code, as it crossed to the refusal.
58
+ */
59
+ export declare function commandsUnavailable(code: string): boolean;
@@ -19,10 +19,16 @@ import type { ApprovalRegistry } from './approvals.ts';
19
19
  import type { DeviceRoster } from './devices.ts';
20
20
  import type { RemoteBridgeRegistry } from './extension.ts';
21
21
  import { type JobRoster } from './jobs.ts';
22
+ import type { LiveActivityNotifier } from './liveactivity.ts';
22
23
  import type { PairingService } from './pairing.ts';
24
+ import type { PushNotifier } from './push.ts';
23
25
  import type { QuestionClaims } from './questions.ts';
26
+ import type { TurnEndQuietGate } from './turn-end-quiet.ts';
27
+ import type { UiCards } from './ui.ts';
28
+ import { type SquadTransport } from './squads.ts';
24
29
  import { type SessionMeta } from './session-meta.ts';
25
30
  import type { SessionPermissions } from './session-permissions.ts';
31
+ import { type UsageService } from './usage.ts';
26
32
  import type { BridgeGateway, GatewayPeer } from './wire.ts';
27
33
  /** Protocol-level heartbeat period: a frame is sent after this long without one. */
28
34
  export declare const IDLE_PING_MS = 20000;
@@ -84,10 +90,21 @@ export interface BridgeConnectionOptions {
84
90
  readonly approvals: ApprovalRegistry;
85
91
  /** Pending user questions: the claims this bridge holds and the answer path back to the host. */
86
92
  readonly questions: QuestionClaims;
93
+ /**
94
+ * 整页卡(§35):`ui.present` 持有的每一张卡,`ui.event` 结算它们,`ui.list`
95
+ * 把它们念回去。与提问表平级、各自认领各自结算——两条通道互不改形状(§35.8)。
96
+ */
97
+ readonly ui: UiCards;
87
98
  /** The host's background jobs: the read-only projection and the scopes this connection watches. */
88
99
  readonly jobs: JobRoster;
89
100
  /** Process-local session metadata: live titles and the host's archive set. */
90
101
  readonly sessionMeta: SessionMeta;
102
+ /**
103
+ * `usage.v1` 背后两半读数:一条会话的上下文窗口与请求组成估算,以及某条
104
+ * provider 路由背后账户的余额。两者都是宿主侧的事实而不是某个设备的事实,
105
+ * 所以一个宿主一份、所有连接共享(见 `core/usage.ts`)。
106
+ */
107
+ readonly usage: UsageService;
91
108
  /** Host-process permission presets, read and switched through their real service objects. */
92
109
  readonly permissions: SessionPermissions;
93
110
  /**
@@ -114,11 +131,100 @@ export interface BridgeConnectionOptions {
114
131
  * `KNOWN_METHODS` answers `unknown-method`.
115
132
  */
116
133
  readonly extensions?: RemoteBridgeRegistry;
134
+ /**
135
+ * The host's squad domain, behind the `squads.v1` channel. Absent is a host
136
+ * that serves no `dsh-agents` domain: the capability stays advertised and only
137
+ * a call that needs the domain answers `squads-unavailable`.
138
+ */
139
+ readonly squads?: SquadTransport;
140
+ /**
141
+ * The outbound notification path, behind the `push.v1` channel. Absent is a
142
+ * bridge that sends nothing: `push.register` still answers `ok:true` (the
143
+ * device row is written either way), and no notification is ever built. That
144
+ * is the default, because a sender needs an Apple signing key this bridge is
145
+ * not shipped with.
146
+ */
147
+ readonly push?: PushNotifier;
148
+ /**
149
+ * The lock-screen card path, behind the same `push.v1` channel. Absent — and it
150
+ * is absent whenever no APNs key is configured — is a bridge that never builds a
151
+ * card: the roster is still served and a question is still answered, because
152
+ * registering the phone's tokens and pushing to them are two different things
153
+ * (§28.3, §29).
154
+ */
155
+ readonly liveActivity?: LiveActivityNotifier;
156
+ /**
157
+ * The gate a finished turn is announced through (§28, §29).
158
+ *
159
+ * Absent is a bridge assembled without one — a suite, or an embedder — and then
160
+ * both channels report at the frame, exactly as they did before the gate
161
+ * existed. The mount always hands one, because it is the only assembly that can
162
+ * read the host's own answer.
163
+ */
164
+ readonly turnEndQuiet?: TurnEndQuietGate;
165
+ /**
166
+ * Called after a registration changed the device table.
167
+ *
168
+ * A session's first live-activity token is what asks this bridge to keep a
169
+ * follow stream of its own open for that session (`host/watchers.ts`), so the
170
+ * roster is the trigger. The hook is guarded at the call site: a standing
171
+ * watcher is this bridge's own background work and may never turn a
172
+ * `push.register` into a failure.
173
+ */
174
+ readonly onPushRegistered?: () => void;
117
175
  }
118
176
  /** A device the connection proved itself to be, resolved from the upgrade request. */
119
177
  export interface ConnectionAuth {
120
178
  readonly deviceId: string;
121
179
  }
180
+ /**
181
+ * Whether one follow increment proves its session is working again.
182
+ *
183
+ * Deliberately narrow, and never "anything that is not a turn end": a parent's
184
+ * stream also carries a settled child's message (`source.kind` `subagent-settled`
185
+ * or `agent-message`, which the frames read as an agent actor), the usage count the
186
+ * host publishes as an assistant message finishes, and the catalog changes of the
187
+ * threads that session spawned. Reading any of those as a new turn would drop the
188
+ * turn end a waiting phone has not been told about yet — the one whose session is
189
+ * still busy with a running child, which is the case §28's gate exists for.
190
+ *
191
+ * One shared rule on purpose: this connection's own drain and the standing watchers
192
+ * both read it, so the two paths cannot disagree about what a new turn looks like.
193
+ * @param delta - one increment of a follow stream.
194
+ * @returns whether assistant work is streaming, or this session's own user wrote.
195
+ */
196
+ export declare function isTurnStartDelta(delta: {
197
+ readonly kind: string;
198
+ readonly actor?: {
199
+ readonly kind?: string;
200
+ };
201
+ }): boolean;
202
+ /**
203
+ * One model selection, in the field names the protocol publishes.
204
+ *
205
+ * Exported beside {@link selectionOf} and {@link modelSelectionOf} because the
206
+ * host half resolves a session's current route for `usage.stats`'s neighbour
207
+ * key `usage.session`/`modelContextWindow` with exactly this fold: two readings
208
+ * of "which model is this session on" would let the two methods name different
209
+ * routes for the same session.
210
+ */
211
+ export type ModelSelection = {
212
+ readonly provider: string;
213
+ readonly model: string;
214
+ readonly reasoningEffort?: string;
215
+ };
216
+ /** @returns the selection this value describes, or undefined when it describes none. */
217
+ export declare function selectionOf(value: unknown): ModelSelection | undefined;
218
+ /**
219
+ * The durable model-selection fold of one `session/projections` answer.
220
+ *
221
+ * Both halves stay optional: a session that never ran has neither, and the
222
+ * catalog default is then the only truthful current value.
223
+ */
224
+ export declare function modelSelectionOf(value: unknown): {
225
+ readonly next?: ModelSelection;
226
+ readonly lastUsed?: ModelSelection;
227
+ };
122
228
  export declare class BridgeConnection {
123
229
  #private;
124
230
  constructor(options: BridgeConnectionOptions, transport: BridgeTransport, auth?: ConnectionAuth);