dsh-web-fetch-playwright 0.2.13 → 0.2.15
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.md +31 -5
- package/README.zh-CN.md +25 -5
- package/lib/client.js +94 -30
- package/lib/index.js +634 -140
- package/lib/types/cdp-pool.d.ts +48 -79
- package/lib/types/client/card.d.ts +1 -1
- package/lib/types/client/controller.d.ts +4 -2
- package/lib/types/client/fields.d.ts +3 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config.d.ts +17 -4
- package/lib/types/index.d.ts +1 -1
- package/lib/types/provider.d.ts +12 -7
- package/lib/types/session-window.d.ts +9 -0
- package/lib/types/types.d.ts +8 -3
- package/package.json +6 -5
- package/src/cdp-pool.ts +352 -167
- package/src/client/card.tsx +37 -7
- package/src/client/controller.ts +6 -2
- package/src/client/fields.module.css +10 -1
- package/src/client/fields.tsx +8 -3
- package/src/client/locales.ts +21 -2
- package/src/config.ts +19 -4
- package/src/index.ts +10 -4
- package/src/provider.ts +131 -19
- package/src/session-window.ts +229 -0
- package/src/types.ts +8 -3
package/lib/types/cdp-pool.d.ts
CHANGED
|
@@ -1,100 +1,69 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* it closes when done — in an isolated throwaway context (`isolated` mode),
|
|
5
|
-
* or in the remote browser's default context (`profile` mode, whose cookies
|
|
6
|
-
* and localStorage are the real profile's, so its persistent logins apply;
|
|
7
|
-
* that context is never closed, only the tab is). The connection itself
|
|
8
|
-
* outlives fetches — reconnecting per fetch would spend 100–500ms per call
|
|
9
|
-
* and open one socket per concurrent tab for no benefit.
|
|
10
|
-
*
|
|
11
|
-
* Liveness is handled three ways: `isConnected()` is checked before reuse, a
|
|
12
|
-
* `disconnected` event (when the backend emits it) drops the reference
|
|
13
|
-
* immediately, and an open-lease failure against a dead connection triggers
|
|
14
|
-
* exactly one reconnect-and-retry before the error surfaces. A changed
|
|
15
|
-
* endpoint (settings edit) replaces the connection.
|
|
16
|
-
*
|
|
1
|
+
/** Session-dedicated or global/profile-shared CDP connections and page leases.
|
|
2
|
+
* Retired generations drain
|
|
3
|
+
* before disconnecting; named contexts belong to a generation, never a profile.
|
|
17
4
|
* @module dsh-web-fetch-playwright/cdp-pool
|
|
18
5
|
*/
|
|
19
6
|
import type { PlaywrightBrowser, PlaywrightContext, PlaywrightPage } from './types.ts';
|
|
20
|
-
|
|
7
|
+
export type SessionPageFactory = (context: PlaywrightContext, browser: PlaywrightBrowser, timeoutMs: number) => Promise<PlaywrightPage>;
|
|
21
8
|
export type CdpConnect = (endpoint: string, timeoutMs: number) => Promise<PlaywrightBrowser>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
export type CdpAcquireMode = 'isolated' | 'profile' | {
|
|
10
|
+
scope: 'session' | 'global';
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
25
13
|
export interface CdpLease {
|
|
26
|
-
/** The shared connection — close only what the lease owns, never this. */
|
|
27
14
|
browser: PlaywrightBrowser;
|
|
28
|
-
/**
|
|
29
|
-
* The context the page lives in: fetch-owned (`isolated`) or the remote
|
|
30
|
-
* browser's default context (`profile`). NEVER close the latter — closing
|
|
31
|
-
* it tears down the whole shared connection (playwright-core maps a
|
|
32
|
-
* default-context close to "close browser" for this connection).
|
|
33
|
-
*/
|
|
34
15
|
context: PlaywrightContext;
|
|
35
|
-
/** The fetch-owned tab; {@link CdpConnectionPool.release} always closes it. */
|
|
36
16
|
page: PlaywrightPage;
|
|
37
|
-
/**
|
|
17
|
+
/** Retained context: never close it directly on fetch completion. */
|
|
38
18
|
persistent: boolean;
|
|
19
|
+
/** Idempotent, bounded cleanup; use this rather than closing context/browser. */
|
|
20
|
+
release(): Promise<void>;
|
|
39
21
|
}
|
|
40
|
-
/** A reusable `connectOverCDP` session handing out per-fetch pages. */
|
|
41
22
|
export declare class CdpConnectionPool {
|
|
42
23
|
private readonly connect;
|
|
43
|
-
private
|
|
44
|
-
private
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
private
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
private readonly sessionPageFactory;
|
|
25
|
+
private current?;
|
|
26
|
+
private readonly sessionConnections;
|
|
27
|
+
private policy?;
|
|
28
|
+
private epoch;
|
|
29
|
+
private readonly generations;
|
|
30
|
+
private readonly closes;
|
|
31
|
+
constructor(connect: CdpConnect, sessionPageFactory?: SessionPageFactory);
|
|
32
|
+
/** Serialize create/reuse/new-tab and tab-close/empty-check/context-close as
|
|
33
|
+
* whole transactions. Different session keys never wait for each other.
|
|
34
|
+
* A failed operation cannot poison the queue, and the map only drops the
|
|
35
|
+
* exact tail it owns (a queued acquisition may already have replaced it).
|
|
52
36
|
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* connect attempt.
|
|
58
|
-
*
|
|
59
|
-
* @param endpoint - normalized CDP endpoint URL.
|
|
60
|
-
* @param timeoutMs - connect timeout budget.
|
|
61
|
-
* @param mode - `isolated` (default): a fresh throwaway context plus a page
|
|
62
|
-
* in it; `profile`: a page in the remote browser's default context — the
|
|
63
|
-
* real profile — which is never closed, only the page is.
|
|
64
|
-
* @returns the shared browser, the page's context, and the page the caller
|
|
65
|
-
* must release.
|
|
66
|
-
* @throws whatever the connect function throws when no connection can be
|
|
67
|
-
* established (the provider wraps it in a structured WebError), or a
|
|
68
|
-
* diagnostic error when `profile` mode finds no default context.
|
|
37
|
+
private withLock;
|
|
38
|
+
/** Call synchronously for every fetch, including local-backend fetches.
|
|
39
|
+
* Keys must encode backend, endpoint and effective context policy. A change
|
|
40
|
+
* prevents new leases on the old generation but preserves existing pages.
|
|
69
41
|
*/
|
|
42
|
+
setPolicy(key: string): void;
|
|
70
43
|
acquire(endpoint: string, timeoutMs: number, mode?: CdpAcquireMode): Promise<CdpLease>;
|
|
71
|
-
/**
|
|
72
|
-
* Open one lease's page on a live connection. The profile-mode handle is
|
|
73
|
-
* taken fresh every call (never cached across connections): a reconnect
|
|
74
|
-
* yields a new Browser object whose `contexts()[0]` must be re-read.
|
|
75
|
-
*/
|
|
76
|
-
private openLease;
|
|
77
|
-
/**
|
|
78
|
-
* Close a fetch-owned page, plus its context when the lease owns one. The
|
|
79
|
-
* remote default context (persistent leases) and the shared connection
|
|
80
|
-
* stay for the next fetch.
|
|
81
|
-
* @param lease - the lease whose page (and, when isolated, context) goes away.
|
|
82
|
-
*/
|
|
83
44
|
release(lease: CdpLease): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* still in flight is abandoned — its own continuation closes the stray
|
|
88
|
-
* browser (nothing here waits on it, so teardown cannot deadlock).
|
|
45
|
+
/** Teardown is stronger than policy retirement: close owned contexts and
|
|
46
|
+
* disconnect even with active leases. Pending creations clean up on arrival.
|
|
47
|
+
* The remote default context is NEVER explicitly closed.
|
|
89
48
|
*/
|
|
90
49
|
dispose(): Promise<void>;
|
|
91
|
-
/** The shared connection for `endpoint`, connecting or reconnecting as needed. */
|
|
92
50
|
private ensure;
|
|
93
|
-
|
|
94
|
-
private
|
|
95
|
-
|
|
96
|
-
private
|
|
97
|
-
/**
|
|
98
|
-
|
|
51
|
+
private attach;
|
|
52
|
+
private assertCurrent;
|
|
53
|
+
private createContext;
|
|
54
|
+
private namedContext;
|
|
55
|
+
/** Invalidate the exact entry, not its key: a concurrent request may already
|
|
56
|
+
* have installed a replacement. namedContext removes only the Promise it read.
|
|
57
|
+
* Best-effort close attempts to release Playwright's local handle after an
|
|
58
|
+
* external CDP deletion (some versions retain it until disconnect); it never
|
|
59
|
+
* touches a sibling context or the default profile.
|
|
60
|
+
*/
|
|
61
|
+
private invalidateContext;
|
|
62
|
+
private releaseNamedContext;
|
|
63
|
+
private openLease;
|
|
64
|
+
private retire;
|
|
65
|
+
private drain;
|
|
66
|
+
/** Bound cleanup and deduplicate close calls, including release/dispose races. */
|
|
67
|
+
private close;
|
|
99
68
|
private isLive;
|
|
100
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Playwright plugin-configuration card: backend radio group (each option
|
|
3
3
|
* carrying its backend-specific inputs nested inside — local path under Local
|
|
4
|
-
* Playwright, CDP endpoint and
|
|
4
|
+
* Playwright, CDP endpoint and context-mode radios under Remote CDP) plus
|
|
5
5
|
* the denoise checkbox, staged and saved through the card form like the
|
|
6
6
|
* built-in plugin cards.
|
|
7
7
|
*
|
|
@@ -29,9 +29,10 @@ export interface PlaywrightSettings {
|
|
|
29
29
|
/**
|
|
30
30
|
* CDP backend: whether fetches share the remote browser's context (its
|
|
31
31
|
* real profile — cookies, localStorage, persistent logins) as tabs, or
|
|
32
|
-
*
|
|
32
|
+
* reuse an isolated context per session or globally. Absent = schema default (true).
|
|
33
33
|
*/
|
|
34
34
|
shareBrowserContext?: boolean;
|
|
35
|
+
contextIsolationScope?: 'session' | 'global';
|
|
35
36
|
/** Whether the Readability + DOMPurify pipeline runs. */
|
|
36
37
|
denoise?: boolean;
|
|
37
38
|
/** How many fetches may render at once (1–200); blank = backend default. */
|
|
@@ -50,8 +51,9 @@ export interface PlaywrightCardState extends CardShell {
|
|
|
50
51
|
playwrightPath: CardFieldState;
|
|
51
52
|
/** CDP endpoint input. */
|
|
52
53
|
cdpEndpoint: CardFieldState;
|
|
53
|
-
/** CDP shared-context
|
|
54
|
+
/** CDP shared-context radio (draft 'true'/'false'). */
|
|
54
55
|
shareBrowserContext: CardFieldState;
|
|
56
|
+
contextIsolationScope: CardFieldState;
|
|
55
57
|
/** Denoise checkbox (draft 'true'/'false'). */
|
|
56
58
|
denoise: CardFieldState;
|
|
57
59
|
/** Concurrency input (draft decimal integer). */
|
|
@@ -44,6 +44,9 @@ export interface RadioOption {
|
|
|
44
44
|
}
|
|
45
45
|
/** A staged radio group: the backend selector. */
|
|
46
46
|
export declare function RadioGroupField(props: {
|
|
47
|
+
embedded?: boolean;
|
|
48
|
+
/** Render options without card borders or backgrounds. */
|
|
49
|
+
plainOptions?: boolean;
|
|
47
50
|
label: string;
|
|
48
51
|
options: readonly RadioOption[];
|
|
49
52
|
text: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module dsh-web-fetch-playwright/client/locales
|
|
6
6
|
*/
|
|
7
7
|
/** Locale keys this card renders. */
|
|
8
|
-
export type PlaywrightCardLocaleKey = 'description' | 'backendLabel' | 'backendLocal' | 'backendLocalHint' | 'backendCdp' | 'backendCdpHint' | 'playwrightPath' | 'playwrightPathHint' | 'playwrightPathPlaceholder' | 'cdpEndpoint' | 'cdpEndpointHint' | 'shareBrowserContext' | 'shareBrowserContextHint' | 'denoise' | 'denoiseHint' | 'maxConcurrency' | 'maxConcurrencyHint' | 'maxConcurrencyPlaceholder' | 'challengeWaitMs' | 'challengeWaitMsHint' | 'challengeWaitMsPlaceholder' | 'overridden' | 'reset' | 'readOnly' | 'save' | 'saving' | 'discard' | 'saveFailed' | 'invalidText';
|
|
8
|
+
export type PlaywrightCardLocaleKey = 'description' | 'backendLabel' | 'backendLocal' | 'backendLocalHint' | 'backendCdp' | 'backendCdpHint' | 'playwrightPath' | 'playwrightPathHint' | 'playwrightPathPlaceholder' | 'cdpEndpoint' | 'cdpEndpointHint' | 'shareBrowserContext' | 'shareBrowserContextHint' | 'contextMode' | 'isolateBrowserContext' | 'isolateBrowserContextHint' | 'contextIsolationScope' | 'contextScopeSession' | 'contextScopeSessionHint' | 'contextScopeGlobal' | 'contextScopeGlobalHint' | 'denoise' | 'denoiseHint' | 'maxConcurrency' | 'maxConcurrencyHint' | 'maxConcurrencyPlaceholder' | 'challengeWaitMs' | 'challengeWaitMsHint' | 'challengeWaitMsPlaceholder' | 'overridden' | 'reset' | 'readOnly' | 'save' | 'saving' | 'discard' | 'saveFailed' | 'invalidText';
|
|
9
9
|
/** This plugin's dictionary namespace, merged into the locale key map. */
|
|
10
10
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
11
11
|
interface LocaleNamespaceMap {
|
package/lib/types/config.d.ts
CHANGED
|
@@ -47,10 +47,12 @@ export declare const MAX_CHALLENGE_RETRIES = 3;
|
|
|
47
47
|
/** Which browser backend serves a fetch. */
|
|
48
48
|
export type PlaywrightBackend = 'local' | 'cdp';
|
|
49
49
|
/**
|
|
50
|
-
* How the CDP backend scopes a fetch: a
|
|
50
|
+
* How the CDP backend scopes a fetch: a reusable isolated context, or a tab
|
|
51
51
|
* in the remote browser's real profile (default context).
|
|
52
52
|
*/
|
|
53
53
|
export type CdpContextMode = 'isolated' | 'profile';
|
|
54
|
+
/** Isolation key: an on-demand context per DSH session or one retained global context. */
|
|
55
|
+
export type ContextIsolationScope = 'session' | 'global';
|
|
54
56
|
/** Plugin config: everything optional — the schema fills the defaults. */
|
|
55
57
|
export interface Config {
|
|
56
58
|
/** Backend selector: local Playwright launch or a remote CDP endpoint. */
|
|
@@ -67,10 +69,18 @@ export interface Config {
|
|
|
67
69
|
* CDP backend only. `true` (default): each fetch is a tab in the remote
|
|
68
70
|
* browser's default context — the real profile — so cookies/localStorage
|
|
69
71
|
* come from (and are written back to) it and its persistent logins apply.
|
|
70
|
-
* `false`:
|
|
71
|
-
*
|
|
72
|
+
* `false`: use an on-demand isolated context per session or a retained global context.
|
|
73
|
+
* Meaningless for the local backend (collapses to isolated).
|
|
72
74
|
*/
|
|
73
75
|
shareBrowserContext?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* CDP isolated context scope; defaults to global (retained between fetches).
|
|
78
|
+
* Session contexts are created on demand; concurrent same-session fetches
|
|
79
|
+
* share the context but each opens and closes its own tab. The context closes
|
|
80
|
+
* when no active/pending fetches and no other open tabs remain, so the next
|
|
81
|
+
* fetch starts with fresh cookies/localStorage. Profile mode is unaffected.
|
|
82
|
+
*/
|
|
83
|
+
contextIsolationScope?: ContextIsolationScope;
|
|
74
84
|
/** Whether the Readability + DOMPurify denoise pipeline runs before markdown. */
|
|
75
85
|
denoise?: boolean;
|
|
76
86
|
/**
|
|
@@ -98,6 +108,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
98
108
|
playwrightPath: z<string, string, "volatile-defined">;
|
|
99
109
|
cdpEndpoint: z<string, string, "volatile-defined">;
|
|
100
110
|
shareBrowserContext: z<boolean, boolean, "volatile-defined">;
|
|
111
|
+
contextIsolationScope: z<"session" | "global", "session" | "global", "volatile-defined">;
|
|
101
112
|
denoise: z<boolean, boolean, "volatile-defined">;
|
|
102
113
|
maxConcurrency: z<number, number, "volatile">;
|
|
103
114
|
challengeWaitMs: z<number, number, "volatile-defined">;
|
|
@@ -107,6 +118,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
107
118
|
playwrightPath: z<string, string, "volatile-defined">;
|
|
108
119
|
cdpEndpoint: z<string, string, "volatile-defined">;
|
|
109
120
|
shareBrowserContext: z<boolean, boolean, "volatile-defined">;
|
|
121
|
+
contextIsolationScope: z<"session" | "global", "session" | "global", "volatile-defined">;
|
|
110
122
|
denoise: z<boolean, boolean, "volatile-defined">;
|
|
111
123
|
maxConcurrency: z<number, number, "volatile">;
|
|
112
124
|
challengeWaitMs: z<number, number, "volatile-defined">;
|
|
@@ -127,6 +139,7 @@ export interface PlaywrightPluginConfig {
|
|
|
127
139
|
cdpEndpoint: Volatile<string>;
|
|
128
140
|
/** Shared-context toggle as a live reference. */
|
|
129
141
|
shareBrowserContext: Volatile<boolean>;
|
|
142
|
+
contextIsolationScope: Volatile<ContextIsolationScope>;
|
|
130
143
|
/** Denoise toggle as a live reference. */
|
|
131
144
|
denoise: Volatile<boolean>;
|
|
132
145
|
/**
|
|
@@ -195,7 +208,7 @@ export declare function effectiveChallengeRetries(config: Pick<Config, 'challeng
|
|
|
195
208
|
/**
|
|
196
209
|
* The context mode a fetch actually runs with: profile (a tab in the remote
|
|
197
210
|
* browser's real profile) requires the CDP backend — a local launch has no
|
|
198
|
-
* meaningful shared profile — and the
|
|
211
|
+
* meaningful shared profile — and the share option (which defaults on, so an
|
|
199
212
|
* absent value reads as `true`, mirroring the schema default); everything
|
|
200
213
|
* else collapses to isolated.
|
|
201
214
|
*
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { Context } from '@deepseek-ai/cordis';
|
|
17
17
|
import type { PlaywrightPluginConfig } from './config.ts';
|
|
18
18
|
export { Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, normalizeCdpEndpoint, resolveConfig, snapshotsOf, } from './config.ts';
|
|
19
|
-
export type { Config as PlaywrightFetchConfig, CdpContextMode, PlaywrightBackend, PlaywrightPluginConfig, ResolvedConfig, } from './config.ts';
|
|
19
|
+
export type { Config as PlaywrightFetchConfig, CdpContextMode, ContextIsolationScope, PlaywrightBackend, PlaywrightPluginConfig, ResolvedConfig, } from './config.ts';
|
|
20
20
|
export { CdpConnectionPool } from './cdp-pool.ts';
|
|
21
21
|
export type { CdpAcquireMode, CdpConnect, CdpLease } from './cdp-pool.ts';
|
|
22
22
|
export { CHALLENGE_DOM_PROBE, CHALLENGE_FINISH_RESERVE_MS, CHALLENGE_POLL_INTERVAL_MS, CHALLENGE_TITLE_RE, classifyChallengeHtml, classifyChallengeResponse, isChallengeCompatibleResponse } from './challenge.ts';
|
package/lib/types/provider.d.ts
CHANGED
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
* ({@link recoverDownloadResponse}) — instead of a `WEB_PROVIDER_ERROR`.
|
|
20
20
|
*
|
|
21
21
|
* Lifecycle: the local backend launches a browser per fetch and closes it —
|
|
22
|
-
* nothing outlives the call.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* nothing outlives the call. CDP session isolation keeps one connection per
|
|
23
|
+
* DSH session until its context becomes idle; this also isolates gateways that
|
|
24
|
+
* map a connection's first context to a separate browser process. Global/profile
|
|
25
|
+
* modes share a provider-lifetime connection. Each fetch owns only its page;
|
|
26
|
+
* contexts are per-session until idle, global until teardown, or (the default,
|
|
27
|
+
* `shareBrowserContext`) in the remote
|
|
26
28
|
* browser's default context so its profile, cookies, and persistent logins
|
|
27
29
|
* apply; that default context is never closed. The concurrency cap counts
|
|
28
30
|
* tabs, not browsers. Either way, an aborted signal closes the fetch's page.
|
|
@@ -77,8 +79,10 @@ export interface BrowserSession {
|
|
|
77
79
|
page: PlaywrightPage;
|
|
78
80
|
/** True when `browser` is the CDP pool's shared connection — never closed per fetch. */
|
|
79
81
|
sharedBrowser?: boolean;
|
|
80
|
-
/** True
|
|
82
|
+
/** True for retained contexts (remote profile or pool-owned named context). */
|
|
81
83
|
persistent?: boolean;
|
|
84
|
+
/** Pool cleanup: closes this tab and, for session isolation, its idle context. */
|
|
85
|
+
release?: () => Promise<void>;
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
88
|
* A single abort deadline composing the caller's signal with this provider's
|
|
@@ -103,6 +107,7 @@ declare class Deadline {
|
|
|
103
107
|
*/
|
|
104
108
|
export declare class PlaywrightFetchProvider implements WebFetchProvider {
|
|
105
109
|
private readonly configSource;
|
|
110
|
+
private readonly sessionIdSource;
|
|
106
111
|
readonly id = "playwright";
|
|
107
112
|
private readonly semaphore;
|
|
108
113
|
/** Shared CDP connection; injectable so the suite can substitute a fake. */
|
|
@@ -111,7 +116,7 @@ export declare class PlaywrightFetchProvider implements WebFetchProvider {
|
|
|
111
116
|
* @param configSource - thunk returning the currently authoritative config.
|
|
112
117
|
* @param cdpPool - optional pool over the CDP backend (tests inject fakes).
|
|
113
118
|
*/
|
|
114
|
-
constructor(configSource: () => ResolvedConfig, cdpPool?: CdpConnectionPool);
|
|
119
|
+
constructor(configSource: () => ResolvedConfig, cdpPool?: CdpConnectionPool, sessionIdSource?: () => string | undefined);
|
|
115
120
|
/** Cheap and side-effect free; backend problems surface per fetch instead. */
|
|
116
121
|
available(): boolean;
|
|
117
122
|
/**
|
|
@@ -128,7 +133,7 @@ export declare class PlaywrightFetchProvider implements WebFetchProvider {
|
|
|
128
133
|
* @param deadline - the fetch budget, applied to launch/connect timeouts.
|
|
129
134
|
* @returns the browser session the fetch will use.
|
|
130
135
|
*/
|
|
131
|
-
protected openSession(config: ResolvedConfig, deadline: Deadline): Promise<BrowserSession>;
|
|
136
|
+
protected openSession(config: ResolvedConfig, deadline: Deadline, sessionId?: string): Promise<BrowserSession>;
|
|
132
137
|
/**
|
|
133
138
|
* Navigate, settle, and decode one URL inside an open session's tab —
|
|
134
139
|
* waiting out any Cloudflare interstitial within the bounded challenge
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Explicit CDP window allocation for session-owned Playwright contexts. */
|
|
2
|
+
import type { PlaywrightBrowser, PlaywrightContext, PlaywrightPage } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Caller serializes creation and release for this context. A bootstrap supplies
|
|
5
|
+
* its public CDP identity; the real first tab explicitly requests a NEW window.
|
|
6
|
+
* Subsequent tabs must match that window. Never falls back to the profile.
|
|
7
|
+
* On timeout only owned pages/targets are cleaned; existing leases stay alive.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSessionPage(context: PlaywrightContext, browser: PlaywrightBrowser, timeoutMs: number): Promise<PlaywrightPage>;
|
package/lib/types/types.d.ts
CHANGED
|
@@ -96,14 +96,19 @@ export interface PlaywrightPage {
|
|
|
96
96
|
request?: PlaywrightRequestContext;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* A browser context: fetch-owned and isolated
|
|
100
|
-
*
|
|
101
|
-
*
|
|
99
|
+
* A browser context: fetch-owned and isolated, a pool-owned named context,
|
|
100
|
+
* or the remote browser's default context carrying its real profile. Named
|
|
101
|
+
* session contexts close when idle; global contexts are retained until teardown.
|
|
102
|
+
* The default context is never explicitly closed.
|
|
102
103
|
*/
|
|
103
104
|
export interface PlaywrightContext {
|
|
104
105
|
newPage(): Promise<PlaywrightPage>;
|
|
106
|
+
/** Currently open tabs; used before releasing an idle session context. */
|
|
107
|
+
pages?(): PlaywrightPage[];
|
|
105
108
|
route(glob: string, handler: (route: PlaywrightRoute) => Promise<void>): Promise<void>;
|
|
106
109
|
close(): Promise<void>;
|
|
110
|
+
/** Invalidate cached named contexts when the remote context closes. */
|
|
111
|
+
on?(event: 'close', listener: () => void): unknown;
|
|
107
112
|
}
|
|
108
113
|
/** A route interception decision. */
|
|
109
114
|
export interface PlaywrightRoute {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-web-fetch-playwright",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
},
|
|
75
75
|
"disclosure": {
|
|
76
76
|
"cloud": false,
|
|
77
|
-
"network": [],
|
|
77
|
+
"network": [ ],
|
|
78
78
|
"offlineMode": false,
|
|
79
|
-
"apiKeys": [],
|
|
79
|
+
"apiKeys": [ ],
|
|
80
80
|
"permissions": [
|
|
81
81
|
"network:fetch (renders the URLs the user requests in a local browser)",
|
|
82
82
|
"network:connect (user-configured CDP endpoint, default 127.0.0.1:9222)",
|
|
83
83
|
"fs:read (user-configured playwright/browser executable path)",
|
|
84
84
|
"network:fetch (CDP profile mode: renders the URLs the user requests WITH the remote browser's logged-in sessions)"
|
|
85
85
|
],
|
|
86
|
-
"jurisdiction": [],
|
|
86
|
+
"jurisdiction": [ ],
|
|
87
87
|
"retention": "none (profile mode: site data lands in the remote browser's own persistent user-data-dir, which this plugin never cleans)"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@mozilla/readability": "^0.6.0",
|
|
93
93
|
"dompurify": "^3.2.4",
|
|
94
94
|
"jsdom": "^26.0.0",
|
|
95
|
-
"playwright-core": "^1.
|
|
95
|
+
"playwright-core": "^1.65.0",
|
|
96
96
|
"turndown": "^7.2.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
|
|
115
115
|
"@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
|
|
116
116
|
"@deepseek-ai/dsh-web": "0.1.7-rc.2",
|
|
117
|
+
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
117
118
|
"@types/jsdom": "^30.0.0",
|
|
118
119
|
"@types/node": "^24.0.0",
|
|
119
120
|
"@types/react": "^18.3.1",
|