@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.
- package/README.i18n.yaml +2 -2
- package/README.md +75 -18
- package/README.zh.md +74 -18
- package/lib/client.js +783 -260
- package/lib/client.js.map +1 -1
- package/lib/index.js +15849 -2913
- package/lib/types/client/PairEntry.d.ts +2 -2
- package/lib/types/client/PairPanel.d.ts +10 -2
- package/lib/types/client/UiPresentRow.d.ts +13 -0
- package/lib/types/client/icons.d.ts +5 -13
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/locales.d.ts +24 -15
- package/lib/types/client/semantic.d.ts +9 -5
- package/lib/types/client/toolview-slot.d.ts +68 -0
- package/lib/types/client/ui-card.d.ts +160 -0
- package/lib/types/core/commands.d.ts +59 -0
- package/lib/types/core/connection.d.ts +106 -0
- package/lib/types/core/devices.d.ts +102 -2
- package/lib/types/core/extension.d.ts +13 -0
- package/lib/types/core/hub.d.ts +129 -15
- package/lib/types/core/liveactivity.d.ts +324 -0
- package/lib/types/core/protocol.d.ts +328 -5
- package/lib/types/core/push.d.ts +186 -0
- package/lib/types/core/questions.d.ts +61 -9
- package/lib/types/core/session-meta.d.ts +55 -1
- package/lib/types/core/squads.d.ts +130 -0
- package/lib/types/core/turn-end-quiet.d.ts +135 -0
- package/lib/types/core/ui.d.ts +238 -0
- package/lib/types/core/usage-stats.d.ts +160 -0
- package/lib/types/core/usage.d.ts +294 -0
- package/lib/types/host/apns.d.ts +151 -0
- package/lib/types/host/squads-ledger.d.ts +39 -0
- package/lib/types/host/squads.d.ts +77 -0
- package/lib/types/host/ui-tools.d.ts +80 -0
- package/lib/types/host/usage-stats.d.ts +75 -0
- package/lib/types/host/watchers.d.ts +95 -0
- package/lib/types/index.d.ts +47 -3
- package/package.json +15 -14
- package/src/client/PairEntry.tsx +58 -31
- package/src/client/PairPanel.tsx +181 -97
- package/src/client/UiPresentRow.tsx +149 -0
- package/src/client/icons.tsx +17 -60
- package/src/client/index.ts +11 -0
- package/src/client/locales.ts +36 -24
- package/src/client/panel.module.css +239 -186
- package/src/client/semantic.ts +10 -6
- package/src/client/toolview-slot.ts +84 -0
- package/src/client/ui-card.ts +368 -0
- package/src/client/ui-present.module.css +87 -0
- package/src/core/commands.ts +95 -0
- package/src/core/connection.ts +811 -12
- package/src/core/devices.ts +337 -5
- package/src/core/extension.ts +20 -0
- package/src/core/hub.ts +518 -43
- package/src/core/liveactivity.ts +833 -0
- package/src/core/protocol.ts +370 -5
- package/src/core/push.ts +385 -0
- package/src/core/questions.ts +81 -10
- package/src/core/session-meta.ts +73 -1
- package/src/core/squads.ts +345 -0
- package/src/core/turn-end-quiet.ts +388 -0
- package/src/core/ui.ts +398 -0
- package/src/core/usage-stats.ts +424 -0
- package/src/core/usage.ts +937 -0
- package/src/core/wire.ts +8 -0
- package/src/host/apns.ts +320 -0
- package/src/host/squads-ledger.ts +105 -0
- package/src/host/squads.ts +206 -0
- package/src/host/ui-tools.ts +233 -0
- package/src/host/usage-stats.ts +155 -0
- package/src/host/watchers.ts +296 -0
- package/src/index.ts +327 -10
package/src/client/PairPanel.tsx
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The protocol v1 pairing panel
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* relay (never this machine's loopback address), and the code is one-shot.
|
|
2
|
+
* The protocol v1 pairing panel: the QR symbol, the countdown with its expiry
|
|
3
|
+
* state, the one address fact the reader must not miss, and the two actions that
|
|
4
|
+
* keep a fresh code on screen.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The shell is the official headless `Modal` and every action is the official
|
|
7
|
+
* `Button`, so the overlay, the mask, the card, the focus trap, the Escape
|
|
8
|
+
* command and the interaction states belong to the library. This file owns the
|
|
9
|
+
* information order and the state presentation only: every state and action
|
|
10
|
+
* arrives through props, and the clock is a prop, so the expiry flip is
|
|
11
|
+
* deterministic instead of read from `Date.now()` here.
|
|
10
12
|
*/
|
|
11
|
-
import { memo } from 'react'
|
|
13
|
+
import { memo, useLayoutEffect, useRef } from 'react'
|
|
12
14
|
import { QRCodeSVG } from 'qrcode.react'
|
|
15
|
+
import {
|
|
16
|
+
Button, IconCheckOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,
|
|
17
|
+
IconRefreshOutlineRegular, IconWarningOutlineRegular, Modal,
|
|
18
|
+
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
13
19
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
14
|
-
import {
|
|
15
|
-
|
|
20
|
+
import {
|
|
21
|
+
EXPIRED_ATTR, PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PLUGIN_ATTR, QR_VALUE_ATTR,
|
|
22
|
+
} from './semantic.ts'
|
|
16
23
|
import css from './panel.module.css'
|
|
17
24
|
|
|
25
|
+
/** The custom property carrying the dialog's own enter keyframe name. */
|
|
26
|
+
const EXIT_NAME_VAR = '--pair-exit-name'
|
|
27
|
+
|
|
18
28
|
/** What the panel is currently showing. */
|
|
19
29
|
export type PairPanelState =
|
|
20
30
|
/** A read is in flight. */
|
|
@@ -45,9 +55,17 @@ export interface PairPanelProps {
|
|
|
45
55
|
/** This page's own `host:port`, named in the origin warning. */
|
|
46
56
|
host: string
|
|
47
57
|
copy: PairCopyState
|
|
58
|
+
/** Whether the modal is mounted at all (the entry keeps it for the leave leg). */
|
|
59
|
+
showing: boolean
|
|
60
|
+
/** Whether the leave leg is running; the card stays mounted until it ends. */
|
|
61
|
+
closing: boolean
|
|
62
|
+
/** The panel element's id, so the seat trigger can name what it expands. */
|
|
63
|
+
id: string
|
|
48
64
|
onClose(): void
|
|
65
|
+
/** The leave leg reported completion: the entry may unmount the modal now. */
|
|
66
|
+
onExited(): void
|
|
49
67
|
onRefresh(): void
|
|
50
|
-
onCopy(
|
|
68
|
+
onCopy(payload: string): void
|
|
51
69
|
}
|
|
52
70
|
|
|
53
71
|
/**
|
|
@@ -62,14 +80,9 @@ const PairQrCode = memo(function PairQrCode({ value, label }: { value: string; l
|
|
|
62
80
|
return <QRCodeSVG value={value} size={184} level="M" marginSize={1} aria-label={label} />
|
|
63
81
|
})
|
|
64
82
|
|
|
65
|
-
/**
|
|
66
|
-
function
|
|
67
|
-
return (
|
|
68
|
-
<div className={css.notice} data-dsh-part={PART_NOTICE} data-tone={tone} role={tone === 'plain' ? 'status' : 'alert'}>
|
|
69
|
-
<p className={css.noticeTitle}>{title}</p>
|
|
70
|
-
{body !== undefined && <p className={css.noticeBody}>{body}</p>}
|
|
71
|
-
</div>
|
|
72
|
-
)
|
|
83
|
+
/** The one string the panel hands out: what the symbol encodes, what copy copies. */
|
|
84
|
+
function payloadOf(state: PairPanelState): string {
|
|
85
|
+
return state.kind === 'ready' ? (state.pairingUrl ?? state.token) : ''
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
/**
|
|
@@ -77,107 +90,178 @@ function Notice({ tone, title, body }: { tone: 'plain' | 'warning' | 'alert'; ti
|
|
|
77
90
|
* @param props - locale seat, view state, clock, page host and actions.
|
|
78
91
|
* @returns the panel element tree.
|
|
79
92
|
*/
|
|
80
|
-
export function PairPanel({
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
export function PairPanel({
|
|
94
|
+
t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy,
|
|
95
|
+
}: PairPanelProps) {
|
|
96
|
+
const panel = useRef<HTMLDivElement | null>(null)
|
|
97
|
+
const ready = state.kind === 'ready'
|
|
98
|
+
const remainingMs = ready ? Math.max(0, state.expiresAt - now) : 0
|
|
99
|
+
const expired = ready && remainingMs <= 0
|
|
83
100
|
const seconds = Math.ceil(remainingMs / 1000)
|
|
84
|
-
const windowMs =
|
|
101
|
+
const windowMs = ready ? Math.max(1, state.expiresAt - state.issuedAt) : 1
|
|
85
102
|
const percent = Math.min(100, Math.max(0, Math.round((remainingMs / windowMs) * 100)))
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
103
|
+
const payload = payloadOf(state)
|
|
104
|
+
// Only a live code can be handed out. An expired one is still on screen, so
|
|
105
|
+
// its button stays put and reports that it is switched off.
|
|
106
|
+
const canCopy = !expired && payload !== ''
|
|
107
|
+
// A refusal the host raised is retried; a live or expired code is minted again.
|
|
108
|
+
const primaryLabel = state.kind === 'failed' || state.kind === 'unreachable' ? t('action.retry') : t('pair.refresh')
|
|
109
|
+
const located = ready && state.pairingUrl !== null
|
|
110
|
+
|
|
111
|
+
// The library owns the enter animation and the bundler scopes its keyframe
|
|
112
|
+
// name, so the leave leg cannot name it in CSS. Read the mounted dialog's own
|
|
113
|
+
// animation at the moment closing starts and hand it to the card: the exit
|
|
114
|
+
// then plays that exact keyframe backwards (M2, same path reversed). Clearing
|
|
115
|
+
// it on reopen is what lets the same card come back to full opacity.
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
const element = panel.current
|
|
118
|
+
if (element === null) return
|
|
119
|
+
if (!closing) {
|
|
120
|
+
element.style.removeProperty(EXIT_NAME_VAR)
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
const dialog = element.parentElement
|
|
124
|
+
const enter = dialog === null ? '' : window.getComputedStyle(dialog).animationName
|
|
125
|
+
if (enter !== '' && enter !== 'none') element.style.setProperty(EXIT_NAME_VAR, enter)
|
|
126
|
+
}, [closing])
|
|
89
127
|
|
|
90
128
|
return (
|
|
91
|
-
<
|
|
92
|
-
<div className={css.mask} aria-hidden="true" onClick={onClose} />
|
|
129
|
+
<Modal open={showing} onClose={onClose} title={t('title')} headless className={css.dialog}>
|
|
93
130
|
<div
|
|
131
|
+
ref={panel}
|
|
132
|
+
id={id}
|
|
94
133
|
className={css.panel}
|
|
95
|
-
role="dialog"
|
|
96
|
-
aria-modal="true"
|
|
97
|
-
aria-label={t('title')}
|
|
98
134
|
data-dsh-plugin={PLUGIN_ATTR}
|
|
99
135
|
data-dsh-part={PART_PANEL}
|
|
136
|
+
data-closing={closing || undefined}
|
|
137
|
+
onAnimationEnd={(event) => {
|
|
138
|
+
if (closing && event.target === event.currentTarget) onExited()
|
|
139
|
+
}}
|
|
140
|
+
onTransitionEnd={(event) => {
|
|
141
|
+
if (closing && event.target === event.currentTarget && event.propertyName === 'opacity') onExited()
|
|
142
|
+
}}
|
|
100
143
|
>
|
|
101
|
-
<
|
|
144
|
+
<header className={css.header}>
|
|
102
145
|
<div className={css.heading}>
|
|
103
146
|
<h2 className={css.title}>{t('title')}</h2>
|
|
104
147
|
<p className={css.subtitle}>{t('subtitle')}</p>
|
|
105
148
|
</div>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
)}
|
|
116
|
-
|
|
117
|
-
{state.kind === 'failed' && (
|
|
118
|
-
<Notice tone="alert" title={t('failed.title')} body={t('failed.body', { status: String(state.status) })} />
|
|
119
|
-
)}
|
|
149
|
+
<Button
|
|
150
|
+
className={css.close}
|
|
151
|
+
variant="ghost"
|
|
152
|
+
size="sm"
|
|
153
|
+
aria-label={t('action.close')}
|
|
154
|
+
icon={<IconCloseOutlineRegular />}
|
|
155
|
+
onClick={onClose}
|
|
156
|
+
/>
|
|
157
|
+
</header>
|
|
120
158
|
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
<div className={css.body}>
|
|
160
|
+
{(state.kind === 'forbidden' || state.kind === 'failed' || state.kind === 'unreachable') && (
|
|
161
|
+
<div className={css.notice} data-dsh-part={PART_NOTICE} data-tone="alert" role="alert">
|
|
162
|
+
<span className={css.noticeIcon} aria-hidden="true"><IconWarningOutlineRegular /></span>
|
|
163
|
+
<div className={css.noticeCopy}>
|
|
164
|
+
<p className={css.noticeTitle}>
|
|
165
|
+
{state.kind === 'forbidden' && t('forbidden.title')}
|
|
166
|
+
{state.kind === 'failed' && t('failed.title')}
|
|
167
|
+
{state.kind === 'unreachable' && t('unreachable.title')}
|
|
168
|
+
</p>
|
|
169
|
+
<p className={css.noticeText}>
|
|
170
|
+
{state.kind === 'forbidden' && t('forbidden.body')}
|
|
171
|
+
{state.kind === 'failed' && t('failed.body', { status: String(state.status) })}
|
|
172
|
+
{state.kind === 'unreachable' && t('unreachable.body')}
|
|
173
|
+
</p>
|
|
130
174
|
</div>
|
|
131
|
-
{expired ? (
|
|
132
|
-
<Notice tone="alert" title={t('pair.expired')} body={t('pair.expiredHint')} />
|
|
133
|
-
) : (
|
|
134
|
-
<div className={css.countdown}>
|
|
135
|
-
<span className={css.countdownText}>{t('pair.countdown', { s: String(seconds) })}</span>
|
|
136
|
-
<span className={css.bar}>
|
|
137
|
-
<span className={css.barFill} style={{ width: `${String(percent)}%` }} />
|
|
138
|
-
</span>
|
|
139
|
-
</div>
|
|
140
|
-
)}
|
|
141
175
|
</div>
|
|
176
|
+
)}
|
|
142
177
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
178
|
+
{(state.kind === 'reading' || ready) && (
|
|
179
|
+
<>
|
|
180
|
+
<div className={css.qrCard}>
|
|
181
|
+
<div
|
|
182
|
+
className={css.qrSlot}
|
|
183
|
+
data-dsh-part={PART_QR}
|
|
184
|
+
{...{ [QR_VALUE_ATTR]: payload }}
|
|
185
|
+
{...{ [EXPIRED_ATTR]: expired || undefined }}
|
|
186
|
+
>
|
|
187
|
+
{ready ? (
|
|
188
|
+
<PairQrCode value={payload} label={t('pair.qrLabel')} />
|
|
189
|
+
) : (
|
|
190
|
+
<span className={css.skeleton} aria-hidden="true" />
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
<div className={css.status}>
|
|
194
|
+
{!ready && <p className={css.statusText}>{t('state.reading')}</p>}
|
|
195
|
+
{ready && expired && <p className={css.statusText} role="status">{t('pair.expired')}</p>}
|
|
196
|
+
{ready && !expired && (
|
|
197
|
+
<>
|
|
198
|
+
<p className={css.statusText}>{t('pair.countdown', { s: String(seconds) })}</p>
|
|
199
|
+
<span className={css.bar} aria-hidden="true">
|
|
200
|
+
<span className={css.barFill} style={{ width: `${String(percent)}%` }} />
|
|
201
|
+
</span>
|
|
202
|
+
</>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
147
206
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{copy === 'copied' ? <CheckIcon /> : <CopyIcon />}
|
|
157
|
-
{copy === 'copied' ? t('action.copied') : copy === 'failed' ? t('action.copyFailed') : t('action.copy')}
|
|
158
|
-
</button>
|
|
207
|
+
<p className={css.address} data-tone={located ? 'plain' : 'warning'}>
|
|
208
|
+
{ready && located && t('origin.located', { origin: state.origin ?? '' })}
|
|
209
|
+
{ready && !located && t('origin.missing', { host })}
|
|
210
|
+
</p>
|
|
211
|
+
<p className={css.hint}>{t('pair.usedHint')}</p>
|
|
212
|
+
</>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
159
215
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
216
|
+
{/* The row exists only while it holds an action: a refusal offers
|
|
217
|
+
nothing to press, and copy itself needs a code to hand out. An
|
|
218
|
+
actionless row would still spend the panel's own gap. */}
|
|
219
|
+
{state.kind !== 'forbidden' && (
|
|
220
|
+
<footer className={css.actions}>
|
|
221
|
+
{ready && (
|
|
222
|
+
<Button
|
|
223
|
+
variant="outline"
|
|
224
|
+
size="sm"
|
|
225
|
+
data-dsh-part={PART_COPY}
|
|
226
|
+
disabled={!canCopy}
|
|
227
|
+
icon={copy === 'copied' ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}
|
|
228
|
+
onClick={() => { onCopy(payload) }}
|
|
229
|
+
>
|
|
230
|
+
<span className={css.labels}>
|
|
231
|
+
<span className={css.label} data-visible={copy === 'idle'} aria-hidden={copy !== 'idle'}>
|
|
232
|
+
{t('action.copy')}
|
|
233
|
+
</span>
|
|
234
|
+
<span className={css.label} data-visible={copy === 'copied'} aria-hidden={copy !== 'copied'}>
|
|
235
|
+
{t('action.copied')}
|
|
236
|
+
</span>
|
|
237
|
+
<span className={css.label} data-visible={copy === 'failed'} aria-hidden={copy !== 'failed'}>
|
|
238
|
+
{t('action.copyFailed')}
|
|
239
|
+
</span>
|
|
240
|
+
</span>
|
|
241
|
+
</Button>
|
|
168
242
|
)}
|
|
169
|
-
|
|
243
|
+
<Button
|
|
244
|
+
variant="primary"
|
|
245
|
+
size="sm"
|
|
246
|
+
data-dsh-part={PART_REFRESH}
|
|
247
|
+
disabled={state.kind === 'reading'}
|
|
248
|
+
icon={<IconRefreshOutlineRegular />}
|
|
249
|
+
onClick={onRefresh}
|
|
250
|
+
>
|
|
251
|
+
{primaryLabel}
|
|
252
|
+
</Button>
|
|
253
|
+
</footer>
|
|
170
254
|
)}
|
|
171
255
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
)}
|
|
256
|
+
{/* Renaming the button under the pointer is not announced: a control's
|
|
257
|
+
label is reported when focus lands on it, not when it changes. The
|
|
258
|
+
outcome is said once from this region instead, and said as nothing
|
|
259
|
+
while there is no outcome to report. */}
|
|
260
|
+
<div className={css.announce} role="status">
|
|
261
|
+
{copy === 'copied' && t('action.copied')}
|
|
262
|
+
{copy === 'failed' && t('action.copyFailed')}
|
|
179
263
|
</div>
|
|
180
264
|
</div>
|
|
181
|
-
</
|
|
265
|
+
</Modal>
|
|
182
266
|
)
|
|
183
267
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The transcript row of one `ui.present` call: the whole page an agent handed
|
|
3
|
+
* into the session, drawn in a controlled frame (protocol §35.11).
|
|
4
|
+
*
|
|
5
|
+
* The row renders and does not answer. The frame carries `srcdoc` and the one
|
|
6
|
+
* sandbox value §35.7 allows — never `allow-same-origin`, which is what turns a
|
|
7
|
+
* sandboxed document back into a same-origin one and would hand an agent page the
|
|
8
|
+
* GUI's own storage and cookies. There is no host request on any path here: an
|
|
9
|
+
* action the page posts arrives as one visible sentence telling the operator to
|
|
10
|
+
* answer on the phone, and nothing is forwarded, stored or sent.
|
|
11
|
+
*
|
|
12
|
+
* Height is measured from the inside because the frame is opaque from the
|
|
13
|
+
* outside: the injected reporter posts the document's own content height, the
|
|
14
|
+
* presenter's suggested `height` carries the first frame, and the measurement
|
|
15
|
+
* replaces it as soon as one arrives. The theme is handed in as variables read
|
|
16
|
+
* off the GUI root, so a card follows the running theme without importing one;
|
|
17
|
+
* a theme that cannot be read costs the injected variables, never the card.
|
|
18
|
+
*/
|
|
19
|
+
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
20
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
21
|
+
import {
|
|
22
|
+
CARD_DEFAULT_HEIGHT,
|
|
23
|
+
FRAME_HEIGHT_CHANNEL,
|
|
24
|
+
FRAME_PERMISSIONS,
|
|
25
|
+
FRAME_SANDBOX,
|
|
26
|
+
cardThemeTokens,
|
|
27
|
+
clampCardHeight,
|
|
28
|
+
frameDocument,
|
|
29
|
+
frameEventOf,
|
|
30
|
+
presentReadOf,
|
|
31
|
+
type ThemeToken,
|
|
32
|
+
} from './ui-card.ts'
|
|
33
|
+
import { PLUGIN_ATTR } from './semantic.ts'
|
|
34
|
+
import css from './ui-present.module.css'
|
|
35
|
+
|
|
36
|
+
export type UiPresentRowProps = PropsLocale<'remote-bridge'> & {
|
|
37
|
+
/** The stage the Tool slot published (`preparing`, `start` or `result`). */
|
|
38
|
+
readonly phase?: unknown
|
|
39
|
+
/** The call material of that stage: the argument view, argument text, meta. */
|
|
40
|
+
readonly block?: unknown
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @returns the GUI root's theme tokens, or none when the theme cannot be read. */
|
|
44
|
+
function readThemeTokens(): readonly ThemeToken[] {
|
|
45
|
+
try {
|
|
46
|
+
return cardThemeTokens(getComputedStyle(document.documentElement))
|
|
47
|
+
} catch {
|
|
48
|
+
return []
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Render one card, or the neutral line of a call that carries no page.
|
|
54
|
+
* @param props - the stage, the call material and the locale seat.
|
|
55
|
+
* @returns the card body placed inside the official tool row.
|
|
56
|
+
*/
|
|
57
|
+
export function UiPresentRow({ phase, block, t }: UiPresentRowProps) {
|
|
58
|
+
const read = useMemo(() => presentReadOf(phase, block), [phase, block])
|
|
59
|
+
const card = read.kind === 'card' ? read.card : undefined
|
|
60
|
+
const frame = useRef<HTMLIFrameElement | null>(null)
|
|
61
|
+
// Read once, before the first paint: a token list that arrived after mount
|
|
62
|
+
// would be a second document load for a card that already showed one.
|
|
63
|
+
const [tokens, setTokens] = useState<readonly ThemeToken[]>(readThemeTokens)
|
|
64
|
+
const [measured, setMeasured] = useState<number | undefined>(undefined)
|
|
65
|
+
const [interacted, setInteracted] = useState(false)
|
|
66
|
+
|
|
67
|
+
// The GUI switches between light and dark while a card is on screen; the
|
|
68
|
+
// document is rebuilt from the tokens of whichever theme is now in force.
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
let media: MediaQueryList | undefined
|
|
71
|
+
try {
|
|
72
|
+
media = window.matchMedia('(prefers-color-scheme: dark)')
|
|
73
|
+
} catch {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
const sync = (): void => { setTokens(readThemeTokens()) }
|
|
77
|
+
if (typeof media.addEventListener === 'function') {
|
|
78
|
+
media.addEventListener('change', sync)
|
|
79
|
+
return () => { media.removeEventListener('change', sync) }
|
|
80
|
+
}
|
|
81
|
+
media.addListener(sync)
|
|
82
|
+
return () => { media.removeListener(sync) }
|
|
83
|
+
}, [])
|
|
84
|
+
|
|
85
|
+
// A new page is a new measurement and a new notice: carrying either across
|
|
86
|
+
// would size the next card to the previous one's content.
|
|
87
|
+
const html = card?.html
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
setMeasured(undefined)
|
|
90
|
+
setInteracted(false)
|
|
91
|
+
}, [html])
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const onMessage = (event: MessageEvent): void => {
|
|
95
|
+
const element = frame.current
|
|
96
|
+
// Identity is the frame element, not the origin: a sandboxed document has
|
|
97
|
+
// an opaque origin and can assert nothing about itself.
|
|
98
|
+
if (element === null || element.contentWindow === null || event.source !== element.contentWindow) return
|
|
99
|
+
const frameEvent = frameEventOf(event.data)
|
|
100
|
+
if (frameEvent === undefined) return
|
|
101
|
+
if (frameEvent.kind === 'height') {
|
|
102
|
+
setMeasured(clampCardHeight(frameEvent.height))
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
// The page asked the desktop for an answer. Nothing leaves this row; the
|
|
106
|
+
// operator is told where answering actually happens.
|
|
107
|
+
setInteracted(true)
|
|
108
|
+
}
|
|
109
|
+
window.addEventListener('message', onMessage)
|
|
110
|
+
return () => { window.removeEventListener('message', onMessage) }
|
|
111
|
+
}, [])
|
|
112
|
+
|
|
113
|
+
const srcdoc = useMemo(
|
|
114
|
+
() => (card === undefined ? '' : frameDocument(card.html, tokens, FRAME_HEIGHT_CHANNEL)),
|
|
115
|
+
[card, tokens],
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
if (card === undefined) {
|
|
119
|
+
return (
|
|
120
|
+
<div className={css.row} data-dsh-plugin={PLUGIN_ATTR} data-tone={read.kind}>
|
|
121
|
+
<p className={css.notice} role="status">{read.kind === 'oversize' ? t('card.oversize') : t('card.empty')}</p>
|
|
122
|
+
</div>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const height = measured ?? clampCardHeight(card.height ?? CARD_DEFAULT_HEIGHT)
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<section className={css.card} data-dsh-plugin={PLUGIN_ATTR} data-state={card.state}>
|
|
130
|
+
<header className={css.head}>
|
|
131
|
+
{card.title !== undefined && <span className={css.title}>{card.title}</span>}
|
|
132
|
+
<span className={css.badge}>{card.state === 'open' ? t('card.waiting') : t('card.settled')}</span>
|
|
133
|
+
</header>
|
|
134
|
+
<iframe
|
|
135
|
+
ref={frame}
|
|
136
|
+
className={css.frame}
|
|
137
|
+
style={{ height: `${height}px` }}
|
|
138
|
+
title={card.title ?? t('card.frameLabel')}
|
|
139
|
+
srcDoc={srcdoc}
|
|
140
|
+
sandbox={FRAME_SANDBOX}
|
|
141
|
+
allow={FRAME_PERMISSIONS}
|
|
142
|
+
referrerPolicy="no-referrer"
|
|
143
|
+
/>
|
|
144
|
+
<p className={css.notice} role="status">
|
|
145
|
+
{interacted ? t('card.interacted') : t('card.answerOnPhone')}
|
|
146
|
+
</p>
|
|
147
|
+
</section>
|
|
148
|
+
)
|
|
149
|
+
}
|
package/src/client/icons.tsx
CHANGED
|
@@ -1,72 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `@deepseek-ai/dsh-client-ui-primitives`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
|
|
10
|
-
/** Shared svg attrs for the 16px stroke icon family. */
|
|
11
|
-
function iconProps(props: SVGProps<SVGSVGElement>): SVGProps<SVGSVGElement> {
|
|
12
|
-
return {
|
|
13
|
-
width: 16,
|
|
14
|
-
height: 16,
|
|
15
|
-
viewBox: '0 0 16 16',
|
|
16
|
-
fill: 'none',
|
|
17
|
-
stroke: 'currentColor',
|
|
18
|
-
strokeWidth: 1.3,
|
|
19
|
-
strokeLinecap: 'round',
|
|
20
|
-
strokeLinejoin: 'round',
|
|
21
|
-
'aria-hidden': true,
|
|
22
|
-
...props,
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
10
|
/** A QR-symbol glyph: three finder squares plus a payload dot. */
|
|
27
11
|
export function QrIcon(props: SVGProps<SVGSVGElement>) {
|
|
28
12
|
return (
|
|
29
|
-
<svg
|
|
13
|
+
<svg
|
|
14
|
+
width={16}
|
|
15
|
+
height={16}
|
|
16
|
+
viewBox="0 0 16 16"
|
|
17
|
+
fill="none"
|
|
18
|
+
stroke="currentColor"
|
|
19
|
+
strokeWidth={1.3}
|
|
20
|
+
strokeLinecap="round"
|
|
21
|
+
strokeLinejoin="round"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
30
25
|
<path d="M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z" />
|
|
31
26
|
<path d="M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z" />
|
|
32
27
|
</svg>
|
|
33
28
|
)
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
/** Copy glyph. */
|
|
37
|
-
export function CopyIcon(props: SVGProps<SVGSVGElement>) {
|
|
38
|
-
return (
|
|
39
|
-
<svg {...iconProps(props)}>
|
|
40
|
-
<rect x="5.5" y="5.5" width="9" height="9" rx="1.5" />
|
|
41
|
-
<path d="M2.5 10.5v-7A1.5 1.5 0 0 1 4 2h5.5" />
|
|
42
|
-
</svg>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Check glyph for the transient copied state. */
|
|
47
|
-
export function CheckIcon(props: SVGProps<SVGSVGElement>) {
|
|
48
|
-
return (
|
|
49
|
-
<svg {...iconProps(props)}>
|
|
50
|
-
<path d="M3 8.5 6.5 12l6.5-8" />
|
|
51
|
-
</svg>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Close glyph for the panel header. */
|
|
56
|
-
export function CloseIcon(props: SVGProps<SVGSVGElement>) {
|
|
57
|
-
return (
|
|
58
|
-
<svg {...iconProps(props)}>
|
|
59
|
-
<path d="M4 4l8 8M12 4l-8 8" />
|
|
60
|
-
</svg>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Refresh glyph for the mint-again action. */
|
|
65
|
-
export function RefreshIcon(props: SVGProps<SVGSVGElement>) {
|
|
66
|
-
return (
|
|
67
|
-
<svg {...iconProps(props)}>
|
|
68
|
-
<path d="M13 8a5 5 0 1 1-1.8-3.85" />
|
|
69
|
-
<path d="M13.2 2.4V5.6H10" />
|
|
70
|
-
</svg>
|
|
71
|
-
)
|
|
72
|
-
}
|
package/src/client/index.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -25,6 +29,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'
|
|
|
25
29
|
import { writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
26
30
|
import { PairEntry } from './PairEntry.tsx'
|
|
27
31
|
import { readPairToken } from './pair-token.ts'
|
|
32
|
+
import { registerPresentToolview } from './toolview-slot.ts'
|
|
28
33
|
import { en, zh, type RemoteBridgeKey } from './locales.ts'
|
|
29
34
|
|
|
30
35
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -73,6 +78,12 @@ export function apply(ctx: ClientContext): void {
|
|
|
73
78
|
return () => {}
|
|
74
79
|
}
|
|
75
80
|
})
|
|
81
|
+
|
|
82
|
+
// The transcript card of an interactive presentation (§35.11): one keyed
|
|
83
|
+
// registration under the wire Tool name draws the body of a `ui.present` call,
|
|
84
|
+
// so the official Tool row keeps everything else — identity, timing and the
|
|
85
|
+
// dispatch tree — and no Chat Node renderer is shadowed.
|
|
86
|
+
registerPresentToolview(ctx, NS)
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
export type { PairEntryProps } from './PairEntry.tsx'
|