@linxin666/dsh-client-ui-browser-view 0.4.18 → 0.4.20
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 +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +18 -2
- package/lib/client.js.map +1 -1
- package/lib/index.js +325 -85
- package/lib/types/client/settings-form.d.ts +2 -0
- package/lib/types/core/chrome.d.ts +9 -2
- package/lib/types/host/auth.d.ts +25 -0
- package/lib/types/host/service.d.ts +27 -5
- package/lib/types/index.d.ts +16 -0
- package/package.json +16 -16
|
@@ -111,6 +111,8 @@ export interface NumberConstraints {
|
|
|
111
111
|
integer?: boolean;
|
|
112
112
|
/** The accepted value must be at least this. */
|
|
113
113
|
min?: number;
|
|
114
|
+
/** The accepted value must be at most this. */
|
|
115
|
+
max?: number;
|
|
114
116
|
}
|
|
115
117
|
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
|
|
116
118
|
export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
|
|
@@ -180,6 +180,11 @@ export declare class ChromeProcess {
|
|
|
180
180
|
get info(): Readonly<ChromeHandle>;
|
|
181
181
|
/** Whether {@link dispose} already ran. */
|
|
182
182
|
get isDisposed(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Subscribe to child-process exit so attached transports mark themselves
|
|
185
|
+
* closed without waiting for idle WebSocket teardown (#2051).
|
|
186
|
+
*/
|
|
187
|
+
onExit(listener: () => void): () => void;
|
|
183
188
|
/**
|
|
184
189
|
* What the disposal achieved, once it ran. A caller that needs to know
|
|
185
190
|
* whether a browser survived the shutdown reads this instead of assuming.
|
|
@@ -195,7 +200,8 @@ export declare class ChromeProcess {
|
|
|
195
200
|
}
|
|
196
201
|
/**
|
|
197
202
|
* Delete the profile directory this launch created, without ever following a
|
|
198
|
-
* link out of it.
|
|
203
|
+
* link out of it. Retries briefly on transient file locks left behind while
|
|
204
|
+
* browser subprocesses release handles (#2051).
|
|
199
205
|
*
|
|
200
206
|
* `fs.rm({ recursive: true })` is banned repository-wide: recursion walks a
|
|
201
207
|
* junction or symlink happily and deletes whatever it points at, so a temp
|
|
@@ -205,5 +211,6 @@ export declare class ChromeProcess {
|
|
|
205
211
|
* Failures are swallowed: a leftover file in the OS temp directory is a lesser
|
|
206
212
|
* problem than failing the dispose path that the caller is awaiting.
|
|
207
213
|
* @param dir - absolute path of the profile directory created by this launch.
|
|
214
|
+
* @param retryDelaysMs - backoff delays after locked removals.
|
|
208
215
|
*/
|
|
209
|
-
export declare function removeTempProfile(dir: string): Promise<void>;
|
|
216
|
+
export declare function removeTempProfile(dir: string, retryDelaysMs?: readonly number[]): Promise<void>;
|
package/lib/types/host/auth.d.ts
CHANGED
|
@@ -42,6 +42,31 @@ export interface AuthenticatedUrlSource {
|
|
|
42
42
|
* @returns true when the document is the challenge rather than a real page.
|
|
43
43
|
*/
|
|
44
44
|
export declare function isAuthChallengeText(text: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a page's visible text is the bare refusal of route admission. The
|
|
47
|
+
* body is generic — any local service can answer it — so a caller must also
|
|
48
|
+
* know the page came from this host's own listener before trusting it.
|
|
49
|
+
* @param text - `document.body.innerText` of the page that just loaded.
|
|
50
|
+
* @returns true when the document is only the word `unauthorized`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isAdmissionRejectionText(text: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether a URL names the same loopback listener as an origin: both
|
|
55
|
+
* authorities loopback, the same protocol, and the same port. A different
|
|
56
|
+
* port is a different local service, and a non-loopback host is never ours.
|
|
57
|
+
* @param url - the URL a navigation was asked to open.
|
|
58
|
+
* @param origin - the host's own listener origin.
|
|
59
|
+
* @returns true when the two name one loopback listener.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isSameLoopbackOrigin(url: string, origin: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a URL names the site root. DSH's token exchange answers only
|
|
64
|
+
* `GET /` with the cookie-setting redirect, so a bare refusal anywhere else
|
|
65
|
+
* cannot be cleared by a ticketed retry.
|
|
66
|
+
* @param url - the URL a navigation was asked to open.
|
|
67
|
+
* @returns true when the URL has no path beyond the root.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isHostRootUrl(url: string): boolean;
|
|
45
70
|
/**
|
|
46
71
|
* Whether a navigation target is one this DSH process serves on loopback: a
|
|
47
72
|
* `localhost` name, 127/8, or `[::1]`. A remote site can render any text it
|
|
@@ -95,6 +95,12 @@ export interface BrowserViewServiceOptions {
|
|
|
95
95
|
* the loader from `ctx.get('connection')`; absent here means no auth top-up.
|
|
96
96
|
*/
|
|
97
97
|
authenticatedUrl?: (url: string) => string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The running host's own listener origin, or undefined while it has not
|
|
100
|
+
* bound. It decides whether a bare `unauthorized` page came from this host
|
|
101
|
+
* rather than from another local service on its own port.
|
|
102
|
+
*/
|
|
103
|
+
hostOrigin?: () => string | undefined;
|
|
98
104
|
/** Live browser source; called for state and every new connection. */
|
|
99
105
|
resolveConfig?: () => BrowserConnectionConfig;
|
|
100
106
|
/**
|
|
@@ -143,6 +149,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
143
149
|
private readonly openSession;
|
|
144
150
|
private readonly resolveConfig;
|
|
145
151
|
private readonly authenticatedUrl;
|
|
152
|
+
private readonly hostOrigin;
|
|
146
153
|
private readonly idleCloseDays;
|
|
147
154
|
private readonly sweepIntervalMs;
|
|
148
155
|
private idleTimer;
|
|
@@ -177,7 +184,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
177
184
|
* @param options - quality, viewport, clock, and the browser factory seam.
|
|
178
185
|
*/
|
|
179
186
|
constructor(options?: BrowserViewServiceOptions);
|
|
180
|
-
/** Whether a browser is currently running. */
|
|
187
|
+
/** Whether a browser is currently running with an open transport. */
|
|
181
188
|
get running(): boolean;
|
|
182
189
|
/** The current panel-facing state; safe to call before anything started. */
|
|
183
190
|
state(): BrowserPanelState;
|
|
@@ -252,6 +259,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
252
259
|
* @returns the tab view.
|
|
253
260
|
*/
|
|
254
261
|
tabFor(sessionId: string | undefined, tabId?: string): Promise<BrowserTabView>;
|
|
262
|
+
private doTabFor;
|
|
255
263
|
/**
|
|
256
264
|
* Apply {@link tabFor}'s resolution order against an already open manager.
|
|
257
265
|
* @param tabs - the live tab manager.
|
|
@@ -273,6 +281,7 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
273
281
|
* @returns the tab view.
|
|
274
282
|
*/
|
|
275
283
|
ensureTab(sessionId?: string): Promise<BrowserTabView>;
|
|
284
|
+
private doEnsureTab;
|
|
276
285
|
/** Create a tab, bind it, and make it the one the panel watches. */
|
|
277
286
|
private createBoundTab;
|
|
278
287
|
/**
|
|
@@ -319,10 +328,14 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
319
328
|
*/
|
|
320
329
|
private authTicketUrl;
|
|
321
330
|
/**
|
|
322
|
-
* Whether the tab's current document is DSH's authentication page.
|
|
323
|
-
*
|
|
324
|
-
*
|
|
331
|
+
* Whether the tab's current document is DSH's authentication page. Two
|
|
332
|
+
* pages count: the token exchange's own sentence, and the bare
|
|
333
|
+
* `unauthorized` a post-#8266 Host answers when route admission refuses the
|
|
334
|
+
* site root before that exchange runs. The bare refusal is generic to every
|
|
335
|
+
* local service, so it only counts when the requested URL names this host's
|
|
336
|
+
* own listener.
|
|
325
337
|
* @param tabId - tab to read.
|
|
338
|
+
* @param url - the URL the caller asked to open.
|
|
326
339
|
* @returns true when the page body is the challenge.
|
|
327
340
|
*/
|
|
328
341
|
private documentShowsAuthChallenge;
|
|
@@ -470,7 +483,16 @@ export declare class BrowserViewService implements BrowserViewBackend {
|
|
|
470
483
|
* @returns the live session.
|
|
471
484
|
*/
|
|
472
485
|
private replaceSession;
|
|
473
|
-
/**
|
|
486
|
+
/**
|
|
487
|
+
* Run one operation against a live session; if a reused transport closes
|
|
488
|
+
* mid-command, recycle the dead session and replay once so transient socket
|
|
489
|
+
* drops self-heal in-flight (#2051).
|
|
490
|
+
*/
|
|
491
|
+
private runWithSession;
|
|
492
|
+
/**
|
|
493
|
+
* Start the browser once (retrying isolated launches once on transient
|
|
494
|
+
* startup errors), recording persistent failures for the panel.
|
|
495
|
+
*/
|
|
474
496
|
private startSession;
|
|
475
497
|
/** Start the screencast for the tab the panel watches. */
|
|
476
498
|
private startStreaming;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -33,6 +33,22 @@ declare module '@deepseek-ai/cordis' {
|
|
|
33
33
|
export declare const name = "browser-view";
|
|
34
34
|
/** Services required before the routes and the tools can mount. */
|
|
35
35
|
export declare const inject: string[];
|
|
36
|
+
interface EntryUrlCandidate {
|
|
37
|
+
readonly url?: string;
|
|
38
|
+
readonly open?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Minimal Cordis context surface needed to resolve an authenticated DSH URL. */
|
|
41
|
+
export interface AuthenticatedUrlContext {
|
|
42
|
+
get?(name: string): unknown;
|
|
43
|
+
readonly webServer?: unknown;
|
|
44
|
+
emit?(subject: unknown, event: string, baseUrl: string, entries: EntryUrlCandidate[]): unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the host's authenticated entry URL for `url` across SDK cohorts:
|
|
48
|
+
* legacy hosts expose `connection.authenticatedUrl(url)`, while peer-auth
|
|
49
|
+
* hosts collect entry URLs via `ctx.emit(webServer, 'webserver/entry-url', url, entries)`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveAuthenticatedUrl(ctx: AuthenticatedUrlContext, url: string): string | undefined;
|
|
36
52
|
/**
|
|
37
53
|
* Mount the routes, the tools, and the browser lifetime.
|
|
38
54
|
* @param ctx - host plugin context carrying webServer and tools.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-browser-view",
|
|
3
3
|
"description": "Right-docked live browser view for the DSH Web GUI: a CDP-driven Chromium the agent operates, a screencast panel the user watches, and screenshots attached to every tool result.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.20",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dsh": {
|
|
24
24
|
"engines": {
|
|
25
|
-
"dsh": ">=0.2.2-rc.
|
|
25
|
+
"dsh": ">=0.2.2-rc.3"
|
|
26
26
|
},
|
|
27
27
|
"bundle": {
|
|
28
28
|
"patch": "./cordis.patch.yml"
|
|
@@ -45,25 +45,25 @@
|
|
|
45
45
|
"ws": "^8.18.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh": ">=0.2.2-rc.
|
|
48
|
+
"@deepseek-ai/dsh": ">=0.2.2-rc.3",
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
54
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.
|
|
55
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.
|
|
56
|
-
"@deepseek-ai/dsh-client-store": "0.2.2-rc.
|
|
57
|
-
"@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.
|
|
58
|
-
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-rc.
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.2-rc.
|
|
63
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.
|
|
64
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.
|
|
65
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.
|
|
66
|
-
"@deepseek-ai/dsh-tools": "^0.2.2-rc.
|
|
54
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.3",
|
|
55
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.3",
|
|
56
|
+
"@deepseek-ai/dsh-client-store": "0.2.2-rc.3",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.3",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-rc.3",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.3",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.3",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.3",
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.2-rc.3",
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.3",
|
|
64
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.3",
|
|
65
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.3",
|
|
66
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.3",
|
|
67
67
|
"@deepseek-ai/schemastery": "^3.19.0",
|
|
68
68
|
"@types/node": "^22.20.0",
|
|
69
69
|
"@types/react": "~18.3.1",
|