@linxin666/dsh-remote-bridge 0.4.21 → 0.4.23
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 +12 -13
- package/README.zh.md +13 -14
- package/lib/client.js +195 -39
- package/lib/client.js.map +1 -1
- package/lib/index.js +2550 -715
- package/lib/types/client/PairEntry.d.ts +1 -1
- package/lib/types/client/PairPanel.d.ts +2 -2
- package/lib/types/client/RemoteConnectionExtension.d.ts +12 -0
- package/lib/types/client/UiPresentRow.d.ts +1 -1
- package/lib/types/client/index.d.ts +2 -1
- package/lib/types/core/usage.d.ts +42 -0
- package/lib/types/host/dsh-home.d.ts +13 -3
- package/package.json +24 -23
- package/src/client/PairEntry.tsx +1 -1
- package/src/client/PairPanel.tsx +3 -3
- package/src/client/RemoteConnectionExtension.tsx +161 -0
- package/src/client/UiPresentRow.tsx +1 -1
- package/src/client/index.ts +22 -2
- package/src/client/panel.module.css +51 -0
- package/src/core/connection.ts +29 -8
- package/src/core/usage.ts +173 -7
- package/src/core/wire.ts +1 -1
- package/src/host/dsh-home.ts +35 -12
- package/src/host/routes.ts +1 -4
- package/src/host/ui-tools.ts +1 -0
- package/src/index.ts +28 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
1
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client';
|
|
2
2
|
import type { PairTokenOutcome } from './pair-token.ts';
|
|
3
3
|
export type PairEntryProps = PropsLocale<'remote-bridge'> & {
|
|
4
4
|
/** Whether the sidebar renders wide content (false = 56px rail). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
1
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client';
|
|
2
2
|
import { type PairOriginSource } from '../core/pair-address.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Where a reader of the beta build can reach the people running it. The URL is
|
|
@@ -6,7 +6,7 @@ import { type PairOriginSource } from '../core/pair-address.ts';
|
|
|
6
6
|
* destination, so a translation cannot retarget the link and a check can assert
|
|
7
7
|
* the real one.
|
|
8
8
|
*/
|
|
9
|
-
export declare const COMMUNITY_INVITE_URL = "https://discord.gg/
|
|
9
|
+
export declare const COMMUNITY_INVITE_URL = "https://discord.gg/JdKTTdpUH";
|
|
10
10
|
/** What the panel is currently showing. */
|
|
11
11
|
export type PairPanelState =
|
|
12
12
|
/** A read is in flight. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client';
|
|
2
|
+
import type { PairTokenOutcome } from './pair-token.ts';
|
|
3
|
+
export type RemoteConnectionExtensionCardProps = Partial<PropsRuntime<'settings.remoteConnection.extensions'>> & PropsLocale<'remote-bridge'> & {
|
|
4
|
+
/** Reads a fresh one-shot token from this package's own Host route. */
|
|
5
|
+
read: () => Promise<PairTokenOutcome>;
|
|
6
|
+
/** Puts the token on the OS clipboard; false means the write was refused. */
|
|
7
|
+
copy: (text: string) => Promise<boolean>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Extension card registered into `settings.remoteConnection.extensions`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function RemoteConnectionExtension({ read, copy, t }: RemoteConnectionExtensionCardProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
1
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client';
|
|
2
2
|
export type UiPresentRowProps = PropsLocale<'remote-bridge'> & {
|
|
3
3
|
/** The stage the Tool slot published (`preparing`, `start` or `result`). */
|
|
4
4
|
readonly phase?: unknown;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
22
22
|
import { type RemoteBridgeKey } from './locales.ts';
|
|
23
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
23
|
+
declare module '@deepseek-ai/dsh-client-ui-slots/client' {
|
|
24
24
|
interface LocaleNamespaceMap {
|
|
25
25
|
/** Protocol v1 pairing panel copy. */
|
|
26
26
|
'remote-bridge': RemoteBridgeKey;
|
|
@@ -34,6 +34,7 @@ export declare const inject: string[];
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function apply(ctx: ClientContext): void;
|
|
36
36
|
export type { PairEntryProps } from './PairEntry.tsx';
|
|
37
|
+
export type { RemoteConnectionExtensionCardProps } from './RemoteConnectionExtension.tsx';
|
|
37
38
|
export type { PairCopyState, PairPanelProps, PairPanelState } from './PairPanel.tsx';
|
|
38
39
|
export type { PairTokenFetch, PairTokenOutcome, PairTokenResponse, ReadPairTokenOptions } from './pair-token.ts';
|
|
39
40
|
export type { RemoteBridgeKey } from './locales.ts';
|
|
@@ -196,6 +196,44 @@ export interface SessionRouteFace {
|
|
|
196
196
|
readonly model: string;
|
|
197
197
|
} | undefined>;
|
|
198
198
|
}
|
|
199
|
+
/** 官方 DeepSeek 请求鉴权服务(`ctx.deepseekAuth`,DSH 0.2.3-alpha.2+)。 */
|
|
200
|
+
export interface DeepSeekAuthFace {
|
|
201
|
+
authorize(request: {
|
|
202
|
+
readonly consumer: string;
|
|
203
|
+
readonly accepts: readonly ('account' | 'api-key')[];
|
|
204
|
+
readonly billing: 'auto' | 'account' | 'api-key';
|
|
205
|
+
readonly route?: string;
|
|
206
|
+
readonly destination: {
|
|
207
|
+
readonly path: string;
|
|
208
|
+
};
|
|
209
|
+
}, signal?: AbortSignal): Promise<{
|
|
210
|
+
readonly kind: 'account' | 'api-key';
|
|
211
|
+
readonly endpoint: string;
|
|
212
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
213
|
+
} | undefined>;
|
|
214
|
+
}
|
|
215
|
+
/** 官方 DeepSeek 账号钱包条目(`ctx.deepseekAccount`)。 */
|
|
216
|
+
export interface DeepSeekAccountWalletFace {
|
|
217
|
+
readonly currency: string;
|
|
218
|
+
readonly balance: string;
|
|
219
|
+
}
|
|
220
|
+
/** 官方 DeepSeek 账号余额服务(`ctx.deepseekAccount`)。 */
|
|
221
|
+
export interface DeepSeekAccountFace {
|
|
222
|
+
getState(): Promise<{
|
|
223
|
+
readonly status: 'signed-out' | 'credential-stored';
|
|
224
|
+
}>;
|
|
225
|
+
getBalance(client: {
|
|
226
|
+
readonly version: string;
|
|
227
|
+
readonly locale: string;
|
|
228
|
+
readonly timezoneOffsetSeconds: number;
|
|
229
|
+
}): Promise<{
|
|
230
|
+
readonly status: 'ready';
|
|
231
|
+
readonly value: readonly DeepSeekAccountWalletFace[];
|
|
232
|
+
readonly bonusWallets: readonly DeepSeekAccountWalletFace[];
|
|
233
|
+
} | {
|
|
234
|
+
readonly status: 'failed';
|
|
235
|
+
} | null>;
|
|
236
|
+
}
|
|
199
237
|
/** 本模块要读的宿主服务;每一个都可能不存在。 */
|
|
200
238
|
export interface UsageFaces {
|
|
201
239
|
/** 活会话的存储:`usage.session` 靠它区分「不存在」与「存在但没读数」。 */
|
|
@@ -208,6 +246,10 @@ export interface UsageFaces {
|
|
|
208
246
|
readonly settings?: SettingsFace | undefined;
|
|
209
247
|
/** 会话此刻的路由:`modelContextWindow` 的来源。 */
|
|
210
248
|
readonly route?: SessionRouteFace | undefined;
|
|
249
|
+
/** 官方 DeepSeek 请求鉴权服务(优先于手工凭据解析)。 */
|
|
250
|
+
readonly deepseekAuth?: DeepSeekAuthFace | undefined;
|
|
251
|
+
/** 官方 DeepSeek App 托管账户余额服务。 */
|
|
252
|
+
readonly deepseekAccount?: DeepSeekAccountFace | undefined;
|
|
211
253
|
}
|
|
212
254
|
/** 上游探测用的 fetch 一角。 */
|
|
213
255
|
export type FetchFace = (url: string, init?: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DSH_HOME resolution shared by the plugin family's Host
|
|
3
|
-
* environment
|
|
4
|
-
*
|
|
2
|
+
* DSH_HOME and DSH_AGENTS_HOME resolution shared by the plugin family's Host
|
|
3
|
+
* halves: environment overrides win (blank values treated as unset), then the
|
|
4
|
+
* platform home fallbacks follow — mirroring `@deepseek-ai/dsh-home-paths`.
|
|
5
5
|
*/
|
|
6
6
|
/** Expand a leading ~ (or ~user) in a path, platform-style. */
|
|
7
7
|
export declare function expandHome(path: string, home?: string): string;
|
|
@@ -14,3 +14,13 @@ export declare function expandHome(path: string, home?: string): string;
|
|
|
14
14
|
export declare function resolveDshHome(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
15
15
|
/** Resolve the DSH home directory from the live environment. */
|
|
16
16
|
export declare function dshHome(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the shared agent configuration root (`$DSH_AGENTS_HOME`, defaulting
|
|
19
|
+
* to `<home>/.agents`), matching `@deepseek-ai/dsh-home-paths`'s `resolveAgentsHome`.
|
|
20
|
+
* @param env - process environment to read DSH_AGENTS_HOME from.
|
|
21
|
+
* @param home - platform home directory fallback (test seam).
|
|
22
|
+
* @returns the absolute shared agents home path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveAgentsHome(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
25
|
+
/** Resolve the shared agent configuration root from the live environment. */
|
|
26
|
+
export declare function agentsHome(): string;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-remote-bridge",
|
|
3
3
|
"description": "DSH remote bridge: the host half serves protocol v1 over one exact /ios/v1 WebSocket route — session roster, history baseline, prompting, live turn increments with tool activity, interrupt, and in-process agent approval — to a device paired by a one-shot bootstrap token and a P-256 challenge-response, with the token endpoint admitted only from this machine; the browser half adds one sidebar-foot panel that shows that same one-shot token as a QR symbol and draws an interactive card inside the tool row without answering it, and adds no wire surface",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.23",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "^24.22.3 || >=26.13.1"
|
|
9
9
|
},
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"types": "lib/types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"dsh": {
|
|
39
39
|
"engines": {
|
|
40
|
-
"dsh": ">=0.2.
|
|
40
|
+
"dsh": ">=0.2.3-alpha.4"
|
|
41
41
|
},
|
|
42
42
|
"bundle": {
|
|
43
43
|
"patch": "./cordis.patch.yml"
|
|
@@ -57,31 +57,32 @@
|
|
|
57
57
|
"yaml": "^2.8.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
61
|
-
"react": "^
|
|
62
|
-
"react-dom": "^
|
|
60
|
+
"@deepseek-ai/dsh": ">=0.2.3-alpha.4",
|
|
61
|
+
"react": "^19.3.1",
|
|
62
|
+
"react-dom": "^19.3.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@deepseek-ai/cordis": "
|
|
66
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.
|
|
67
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
68
|
-
"@deepseek-ai/dsh-client-
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-
|
|
71
|
-
"@deepseek-ai/dsh-client-ui-
|
|
72
|
-
"@deepseek-ai/dsh-
|
|
73
|
-
"@deepseek-ai/dsh-
|
|
74
|
-
"@deepseek-ai/dsh-
|
|
75
|
-
"@deepseek-ai/dsh-
|
|
76
|
-
"@deepseek-ai/dsh-
|
|
65
|
+
"@deepseek-ai/cordis": "~4.2.0-alpha.3",
|
|
66
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.3-alpha.4",
|
|
67
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.4",
|
|
68
|
+
"@deepseek-ai/dsh-client-remote-connection": "^0.2.3-alpha.4",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.4",
|
|
70
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.4",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.3-alpha.4",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.4",
|
|
73
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.4",
|
|
74
|
+
"@deepseek-ai/dsh-session": "^0.2.3-alpha.4",
|
|
75
|
+
"@deepseek-ai/dsh-tools": "^0.2.3-alpha.4",
|
|
76
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.4",
|
|
77
|
+
"@deepseek-ai/dsh-user-approval": "^0.2.3-alpha.4",
|
|
77
78
|
"@testing-library/dom": "^10.4.1",
|
|
78
|
-
"@testing-library/react": "^16.3.
|
|
79
|
+
"@testing-library/react": "^16.3.3",
|
|
79
80
|
"@types/node": "^22.20.0",
|
|
80
|
-
"@types/react": "~
|
|
81
|
-
"@types/react-dom": "~
|
|
81
|
+
"@types/react": "~19.3.2",
|
|
82
|
+
"@types/react-dom": "~19.3.0",
|
|
82
83
|
"jsdom": "29.1.1",
|
|
83
|
-
"react": "^
|
|
84
|
-
"react-dom": "^
|
|
84
|
+
"react": "^19.3.1",
|
|
85
|
+
"react-dom": "^19.3.1",
|
|
85
86
|
"tsdown": "^0.22.2",
|
|
86
87
|
"typescript": "^6.0.3",
|
|
87
88
|
"vitest": "^4.1.8"
|
package/src/client/PairEntry.tsx
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* can be driven by a test without patching a module.
|
|
14
14
|
*/
|
|
15
15
|
import { useCallback, useEffect, useId, useRef, useState } from 'react'
|
|
16
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
16
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
17
17
|
import { PairPanel, type PairCopyState, type PairPanelState } from './PairPanel.tsx'
|
|
18
18
|
import type { PairTokenOutcome } from './pair-token.ts'
|
|
19
19
|
import { PART_ENTRY, PLUGIN_ATTR } from './semantic.ts'
|
package/src/client/PairPanel.tsx
CHANGED
|
@@ -15,8 +15,8 @@ import { QRCodeSVG } from 'qrcode.react'
|
|
|
15
15
|
import {
|
|
16
16
|
Button, IconCheckOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,
|
|
17
17
|
IconRefreshOutlineRegular, IconWarningOutlineRegular, Modal,
|
|
18
|
-
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
19
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
18
|
+
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
19
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
20
20
|
import { isLanOrigin, type PairOriginSource } from '../core/pair-address.ts'
|
|
21
21
|
import {
|
|
22
22
|
EXPIRED_ATTR, PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PLUGIN_ATTR, QR_VALUE_ATTR,
|
|
@@ -32,7 +32,7 @@ const EXIT_NAME_VAR = '--pair-exit-name'
|
|
|
32
32
|
* destination, so a translation cannot retarget the link and a check can assert
|
|
33
33
|
* the real one.
|
|
34
34
|
*/
|
|
35
|
-
export const COMMUNITY_INVITE_URL = 'https://discord.gg/
|
|
35
|
+
export const COMMUNITY_INVITE_URL = 'https://discord.gg/JdKTTdpUH'
|
|
36
36
|
|
|
37
37
|
/** What the panel is currently showing. */
|
|
38
38
|
export type PairPanelState =
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official `settings.remoteConnection.extensions` extension card for protocol
|
|
3
|
+
* v1 (iOS App) pairing.
|
|
4
|
+
*
|
|
5
|
+
* Renders beneath the official Remote Connection settings panel so operators
|
|
6
|
+
* discover mobile-app pairing alongside official browser remote access, while
|
|
7
|
+
* reusing the same loopback-only pair-token modal (`PairPanel`) and existing
|
|
8
|
+
* localized copy.
|
|
9
|
+
* @module @linxin666/dsh-remote-bridge/client/RemoteConnectionExtension
|
|
10
|
+
*/
|
|
11
|
+
import { useCallback, useEffect, useId, useRef, useState } from 'react'
|
|
12
|
+
import type {} from '@deepseek-ai/dsh-client-remote-connection/client'
|
|
13
|
+
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
14
|
+
import { Button } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
15
|
+
import { PairPanel, type PairCopyState, type PairPanelState } from './PairPanel.tsx'
|
|
16
|
+
import type { PairTokenOutcome } from './pair-token.ts'
|
|
17
|
+
import { PLUGIN_ATTR } from './semantic.ts'
|
|
18
|
+
import { QrIcon } from './icons.tsx'
|
|
19
|
+
import css from './panel.module.css'
|
|
20
|
+
|
|
21
|
+
const COPY_FEEDBACK_MS = 1_500
|
|
22
|
+
const TICK_MS = 1_000
|
|
23
|
+
const EXIT_TIMEOUT_MS = 260
|
|
24
|
+
|
|
25
|
+
type Presence = 'closed' | 'open' | 'closing'
|
|
26
|
+
|
|
27
|
+
export type RemoteConnectionExtensionCardProps =
|
|
28
|
+
& Partial<PropsRuntime<'settings.remoteConnection.extensions'>>
|
|
29
|
+
& PropsLocale<'remote-bridge'>
|
|
30
|
+
& {
|
|
31
|
+
/** Reads a fresh one-shot token from this package's own Host route. */
|
|
32
|
+
read: () => Promise<PairTokenOutcome>
|
|
33
|
+
/** Puts the token on the OS clipboard; false means the write was refused. */
|
|
34
|
+
copy: (text: string) => Promise<boolean>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function panelStateOf(outcome: PairTokenOutcome, issuedAt: number): PairPanelState {
|
|
38
|
+
switch (outcome.kind) {
|
|
39
|
+
case 'ok':
|
|
40
|
+
return {
|
|
41
|
+
kind: 'ready',
|
|
42
|
+
token: outcome.token,
|
|
43
|
+
issuedAt,
|
|
44
|
+
expiresAt: outcome.expiresAt,
|
|
45
|
+
origin: outcome.origin,
|
|
46
|
+
originSource: outcome.originSource,
|
|
47
|
+
pairingUrl: outcome.pairingUrl,
|
|
48
|
+
}
|
|
49
|
+
case 'forbidden': return { kind: 'forbidden' }
|
|
50
|
+
case 'unreachable': return { kind: 'unreachable' }
|
|
51
|
+
case 'failed': return { kind: 'failed', status: outcome.status }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extension card registered into `settings.remoteConnection.extensions`.
|
|
57
|
+
*/
|
|
58
|
+
export function RemoteConnectionExtension({ read, copy, t }: RemoteConnectionExtensionCardProps) {
|
|
59
|
+
const [presence, setPresence] = useState<Presence>('closed')
|
|
60
|
+
const [state, setState] = useState<PairPanelState>({ kind: 'reading' })
|
|
61
|
+
const [copyState, setCopyState] = useState<PairCopyState>('idle')
|
|
62
|
+
const [now, setNow] = useState<number>(() => Date.now())
|
|
63
|
+
const panelId = useId()
|
|
64
|
+
const generation = useRef(0)
|
|
65
|
+
|
|
66
|
+
const mint = useCallback((): void => {
|
|
67
|
+
const request = ++generation.current
|
|
68
|
+
setState({ kind: 'reading' })
|
|
69
|
+
void read().then((outcome) => {
|
|
70
|
+
if (request !== generation.current) return
|
|
71
|
+
const issuedAt = Date.now()
|
|
72
|
+
setNow(issuedAt)
|
|
73
|
+
setState(panelStateOf(outcome, issuedAt))
|
|
74
|
+
})
|
|
75
|
+
}, [read])
|
|
76
|
+
|
|
77
|
+
const openPanel = useCallback((): void => {
|
|
78
|
+
setPresence('open')
|
|
79
|
+
setCopyState('idle')
|
|
80
|
+
mint()
|
|
81
|
+
}, [mint])
|
|
82
|
+
|
|
83
|
+
const requestClose = useCallback((): void => {
|
|
84
|
+
generation.current += 1
|
|
85
|
+
setPresence((current) => (current === 'closed' ? 'closed' : 'closing'))
|
|
86
|
+
}, [])
|
|
87
|
+
|
|
88
|
+
const finishClose = useCallback((): void => {
|
|
89
|
+
setPresence((current) => (current === 'closing' ? 'closed' : current))
|
|
90
|
+
}, [])
|
|
91
|
+
|
|
92
|
+
const closing = presence === 'closing'
|
|
93
|
+
const showing = presence !== 'closed'
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!closing) return
|
|
97
|
+
const timer = window.setTimeout(() => { finishClose() }, EXIT_TIMEOUT_MS)
|
|
98
|
+
return () => { window.clearTimeout(timer) }
|
|
99
|
+
}, [closing, finishClose])
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (presence !== 'open' || state.kind !== 'ready') return
|
|
103
|
+
const deadline = state.expiresAt
|
|
104
|
+
const timer = window.setInterval(() => {
|
|
105
|
+
const current = Date.now()
|
|
106
|
+
setNow(current)
|
|
107
|
+
if (current >= deadline) window.clearInterval(timer)
|
|
108
|
+
}, TICK_MS)
|
|
109
|
+
return () => { window.clearInterval(timer) }
|
|
110
|
+
}, [presence, state])
|
|
111
|
+
|
|
112
|
+
const handleCopy = useCallback((payload: string): void => {
|
|
113
|
+
void copy(payload).then((ok) => {
|
|
114
|
+
setCopyState(ok ? 'copied' : 'failed')
|
|
115
|
+
window.setTimeout(() => { setCopyState('idle') }, COPY_FEEDBACK_MS)
|
|
116
|
+
})
|
|
117
|
+
}, [copy])
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<section
|
|
121
|
+
className={css.extensionCard}
|
|
122
|
+
data-dsh-plugin={PLUGIN_ATTR}
|
|
123
|
+
data-dsh-part="remote-connection-extension"
|
|
124
|
+
>
|
|
125
|
+
<div className={css.extensionBody}>
|
|
126
|
+
<div className={css.extensionHeader}>
|
|
127
|
+
<span className={css.extensionIcon} aria-hidden="true"><QrIcon /></span>
|
|
128
|
+
<h4 className={css.extensionTitle}>{t('title')}</h4>
|
|
129
|
+
</div>
|
|
130
|
+
<p className={css.extensionSubtitle}>{t('subtitle')}</p>
|
|
131
|
+
</div>
|
|
132
|
+
<div className={css.extensionActions}>
|
|
133
|
+
<Button
|
|
134
|
+
variant="outline"
|
|
135
|
+
size="sm"
|
|
136
|
+
aria-expanded={showing}
|
|
137
|
+
aria-controls={showing ? panelId : undefined}
|
|
138
|
+
onClick={openPanel}
|
|
139
|
+
>
|
|
140
|
+
{t('entry.label')}
|
|
141
|
+
</Button>
|
|
142
|
+
</div>
|
|
143
|
+
{showing && (
|
|
144
|
+
<PairPanel
|
|
145
|
+
id={panelId}
|
|
146
|
+
t={t}
|
|
147
|
+
state={state}
|
|
148
|
+
now={now}
|
|
149
|
+
host={window.location.host}
|
|
150
|
+
copy={copyState}
|
|
151
|
+
showing={showing}
|
|
152
|
+
closing={closing}
|
|
153
|
+
onClose={requestClose}
|
|
154
|
+
onExited={finishClose}
|
|
155
|
+
onRefresh={mint}
|
|
156
|
+
onCopy={handleCopy}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
</section>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* a theme that cannot be read costs the injected variables, never the card.
|
|
18
18
|
*/
|
|
19
19
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
20
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
20
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
21
21
|
import {
|
|
22
22
|
CARD_DEFAULT_HEIGHT,
|
|
23
23
|
FRAME_HEIGHT_CHANNEL,
|
package/src/client/index.ts
CHANGED
|
@@ -26,13 +26,16 @@ import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
|
26
26
|
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
27
27
|
// Type-only: pulls the ui-sidebar SlotMap merge (the 'sidebar.footer.action' hole).
|
|
28
28
|
import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'
|
|
29
|
-
|
|
29
|
+
// Type-only: pulls the official remote-connection SlotMap merge ('settings.remoteConnection.extensions').
|
|
30
|
+
import type {} from '@deepseek-ai/dsh-client-remote-connection/client'
|
|
31
|
+
import { writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
30
32
|
import { PairEntry } from './PairEntry.tsx'
|
|
33
|
+
import { RemoteConnectionExtension } from './RemoteConnectionExtension.tsx'
|
|
31
34
|
import { readPairToken } from './pair-token.ts'
|
|
32
35
|
import { registerPresentToolview } from './toolview-slot.ts'
|
|
33
36
|
import { en, zh, type RemoteBridgeKey } from './locales.ts'
|
|
34
37
|
|
|
35
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
38
|
+
declare module '@deepseek-ai/dsh-client-ui-slots/client' {
|
|
36
39
|
interface LocaleNamespaceMap {
|
|
37
40
|
/** Protocol v1 pairing panel copy. */
|
|
38
41
|
'remote-bridge': RemoteBridgeKey
|
|
@@ -79,6 +82,22 @@ export function apply(ctx: ClientContext): void {
|
|
|
79
82
|
}
|
|
80
83
|
})
|
|
81
84
|
|
|
85
|
+
// Official Settings -> Remote Connection extension seat (DSH 0.2.3-alpha.2+):
|
|
86
|
+
// surface native iOS App pairing beneath the official browser remote access cards.
|
|
87
|
+
ctx.slots.inject('settings.remoteConnection.extensions', () => {
|
|
88
|
+
try {
|
|
89
|
+
return ctx.slots.register({
|
|
90
|
+
name: 'settings.remoteConnection.extensions',
|
|
91
|
+
id: `${ENTRY_ID}-ios`,
|
|
92
|
+
order: 20,
|
|
93
|
+
locale: NS,
|
|
94
|
+
inject: () => ({ read: readPairToken, copy: writeClipboard }),
|
|
95
|
+
}, RemoteConnectionExtension)
|
|
96
|
+
} catch {
|
|
97
|
+
return () => {}
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
82
101
|
// The transcript card of an interactive presentation (§35.11): one keyed
|
|
83
102
|
// registration under the wire Tool name draws the body of a `ui_present` call,
|
|
84
103
|
// so the official Tool row keeps everything else — identity, timing and the
|
|
@@ -87,6 +106,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
87
106
|
}
|
|
88
107
|
|
|
89
108
|
export type { PairEntryProps } from './PairEntry.tsx'
|
|
109
|
+
export type { RemoteConnectionExtensionCardProps } from './RemoteConnectionExtension.tsx'
|
|
90
110
|
export type { PairCopyState, PairPanelProps, PairPanelState } from './PairPanel.tsx'
|
|
91
111
|
export type { PairTokenFetch, PairTokenOutcome, PairTokenResponse, ReadPairTokenOptions } from './pair-token.ts'
|
|
92
112
|
export type { RemoteBridgeKey } from './locales.ts'
|
|
@@ -442,3 +442,54 @@
|
|
|
442
442
|
clip: rect(0, 0, 0, 0);
|
|
443
443
|
clip-path: inset(0);
|
|
444
444
|
}
|
|
445
|
+
|
|
446
|
+
/* ── Official Remote Connection settings extension card ── */
|
|
447
|
+
|
|
448
|
+
.extensionCard {
|
|
449
|
+
display: flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
justify-content: space-between;
|
|
452
|
+
gap: 16px;
|
|
453
|
+
padding: 16px;
|
|
454
|
+
border-radius: 12px;
|
|
455
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
456
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.extensionBody {
|
|
460
|
+
display: flex;
|
|
461
|
+
flex-direction: column;
|
|
462
|
+
gap: 4px;
|
|
463
|
+
min-width: 0;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.extensionHeader {
|
|
467
|
+
display: flex;
|
|
468
|
+
align-items: center;
|
|
469
|
+
gap: 8px;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.extensionIcon {
|
|
473
|
+
display: inline-flex;
|
|
474
|
+
align-items: center;
|
|
475
|
+
color: var(--dsw-alias-label-secondary);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.extensionTitle {
|
|
479
|
+
margin: 0;
|
|
480
|
+
font-size: 14px;
|
|
481
|
+
font-weight: 600;
|
|
482
|
+
line-height: 20px;
|
|
483
|
+
color: var(--dsw-alias-label-primary);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.extensionSubtitle {
|
|
487
|
+
margin: 0;
|
|
488
|
+
font-size: 13px;
|
|
489
|
+
line-height: 20px;
|
|
490
|
+
color: var(--dsw-alias-label-secondary);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.extensionActions {
|
|
494
|
+
flex: none;
|
|
495
|
+
}
|
package/src/core/connection.ts
CHANGED
|
@@ -724,6 +724,26 @@ function effortIdsOf(groups: unknown, provider: string, model: string): readonly
|
|
|
724
724
|
* @param efforts - the host's preference table.
|
|
725
725
|
* @returns the rows to publish, with the remembered levels injected.
|
|
726
726
|
*/
|
|
727
|
+
/**
|
|
728
|
+
* Providers whose own routes still accept `off` in requests but hide it from
|
|
729
|
+
* picker choices unless the model declares `off` as its default effort (DSH #9860).
|
|
730
|
+
*/
|
|
731
|
+
const OFF_HIDDEN_PROVIDERS: ReadonlySet<string> = new Set(['deepseek-account', 'deepseek-official'])
|
|
732
|
+
|
|
733
|
+
/** Hide `off` from DeepSeek picker rows unless it is the model's declared default effort. */
|
|
734
|
+
function filterPickerReasoning(provider: string, row: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>> {
|
|
735
|
+
if (!OFF_HIDDEN_PROVIDERS.has(provider)) return row
|
|
736
|
+
const reasoning = row.reasoning
|
|
737
|
+
if (!isRecord(reasoning) || !Array.isArray(reasoning.efforts)) return row
|
|
738
|
+
const defaultEffort = optionalText(reasoning.defaultEffort)
|
|
739
|
+
const filtered = reasoning.efforts.filter(effort => {
|
|
740
|
+
const id = isRecord(effort) ? optionalText(effort.id) : undefined
|
|
741
|
+
return id !== 'off' || id === defaultEffort
|
|
742
|
+
})
|
|
743
|
+
if (filtered.length === reasoning.efforts.length) return row
|
|
744
|
+
return { ...row, reasoning: { ...reasoning, efforts: filtered } }
|
|
745
|
+
}
|
|
746
|
+
|
|
727
747
|
function withPreferredEfforts(groups: unknown, efforts: ModelEffortPreferences): readonly unknown[] {
|
|
728
748
|
if (!Array.isArray(groups)) return []
|
|
729
749
|
return groups.map(group => {
|
|
@@ -734,9 +754,10 @@ function withPreferredEfforts(groups: unknown, efforts: ModelEffortPreferences):
|
|
|
734
754
|
...group,
|
|
735
755
|
models: group.models.map(row => {
|
|
736
756
|
if (!isRecord(row)) return row
|
|
737
|
-
const
|
|
757
|
+
const visible = filterPickerReasoning(provider, row)
|
|
758
|
+
const model = optionalText(visible.id)
|
|
738
759
|
const preferred = model === undefined ? undefined : efforts.effortOf(provider, model)
|
|
739
|
-
return preferred === undefined ?
|
|
760
|
+
return preferred === undefined ? visible : { ...visible, preferredEffort: preferred }
|
|
740
761
|
}),
|
|
741
762
|
}
|
|
742
763
|
})
|
|
@@ -2027,9 +2048,9 @@ export class BridgeConnection {
|
|
|
2027
2048
|
async #sessionModels(payload: Readonly<Record<string, unknown>>): Promise<DispatchOutcome> {
|
|
2028
2049
|
const sessionId = stringArg(payload, 'sessionId')
|
|
2029
2050
|
if (sessionId === undefined) return refusal(CODE_INVALID_ARGS, 'session.models requires sessionId')
|
|
2030
|
-
const catalog = await this.#unary('
|
|
2051
|
+
const catalog = await this.#unary('models', 'catalog')
|
|
2031
2052
|
if (!catalog.ok) return catalog
|
|
2032
|
-
if (!isRecord(catalog.value)) return refusal(CODE_INTERNAL, '
|
|
2053
|
+
if (!isRecord(catalog.value)) return refusal(CODE_INTERNAL, 'models/catalog returned no catalog')
|
|
2033
2054
|
const folded = await this.#sessionCurrent(sessionId, catalog.value)
|
|
2034
2055
|
if (!folded.ok) return folded
|
|
2035
2056
|
await this.#options.modelEfforts.load()
|
|
@@ -2059,7 +2080,7 @@ export class BridgeConnection {
|
|
|
2059
2080
|
catalog: Readonly<Record<string, unknown>>,
|
|
2060
2081
|
): Promise<{ readonly ok: true; readonly current: ModelSelection; readonly fallback: ModelSelection } | CallFailure> {
|
|
2061
2082
|
const fallback = selectionOf(catalog.default)
|
|
2062
|
-
if (fallback === undefined) return refusal(CODE_INTERNAL, '
|
|
2083
|
+
if (fallback === undefined) return refusal(CODE_INTERNAL, 'models/catalog returned no default model')
|
|
2063
2084
|
const projections = await this.#unary('session', 'projections', { sessionId })
|
|
2064
2085
|
if (!projections.ok) return projections
|
|
2065
2086
|
const folded = modelSelectionOf(projections.value)
|
|
@@ -2120,7 +2141,7 @@ export class BridgeConnection {
|
|
|
2120
2141
|
async #rememberedEffort(provider: string, model: string): Promise<string | undefined> {
|
|
2121
2142
|
const remembered = this.#options.modelEfforts.effortOf(provider, model)
|
|
2122
2143
|
if (remembered === undefined) return undefined
|
|
2123
|
-
const catalog = await this.#unary('
|
|
2144
|
+
const catalog = await this.#unary('models', 'catalog')
|
|
2124
2145
|
// A catalog this call cannot read is not evidence the level went stale: the
|
|
2125
2146
|
// stored value crosses exactly as it did before this check existed.
|
|
2126
2147
|
if (!catalog.ok || !isRecord(catalog.value)) return remembered
|
|
@@ -2163,9 +2184,9 @@ export class BridgeConnection {
|
|
|
2163
2184
|
// Read before any write: the table is rewritten whole, so a save must never
|
|
2164
2185
|
// overwrite rows this process has not read yet.
|
|
2165
2186
|
await this.#options.modelEfforts.load()
|
|
2166
|
-
const catalog = await this.#unary('
|
|
2187
|
+
const catalog = await this.#unary('models', 'catalog')
|
|
2167
2188
|
if (!catalog.ok) return catalog
|
|
2168
|
-
if (!isRecord(catalog.value)) return refusal(CODE_INTERNAL, '
|
|
2189
|
+
if (!isRecord(catalog.value)) return refusal(CODE_INTERNAL, 'models/catalog returned no catalog')
|
|
2169
2190
|
const offered = effortIdsOf(catalog.value.groups, provider, model)
|
|
2170
2191
|
if (offered === undefined) {
|
|
2171
2192
|
return refusal(CODE_INVALID_ARGS, `session.setEffort: this host publishes no model ${provider}/${model}`)
|