dsh-web-fetch-playwright 0.2.6 → 0.2.8

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.
@@ -1,21 +1,34 @@
1
1
  /**
2
- * Browser half of `dsh-web-fetch-playwright`: registers the locale dictionary
3
- * and the plugin-configuration card keyed by the `web-fetch-playwright`
4
- * settings namespace, so the card pairs with the Host section the plugin half
5
- * registers — the shipped configurable-plugins tab dispatches it with no
6
- * changes.
2
+ * Browser half of `dsh-web-fetch-playwright`: registers the locale
3
+ * dictionary and the plugin-configuration card keyed by the
4
+ * `web-fetch-playwright` settings namespace (the composition entry id the
5
+ * host's settings service derives from the plugin's Config schema).
6
+ *
7
+ * Since dsh 0.1.7 the Plugins page owns a plugin's configuration, and its
8
+ * slot contract offers a bundle two seats: the bundle's own form on its
9
+ * package page (`plugins.bundle.config`, keyed by package name — what the
10
+ * user opens straight from the plugin list) and one row's page
11
+ * (`plugins.row.config`, keyed `<package name>#<row id>` — the row's
12
+ * configure control). This bundle is one plugin with one config, so BOTH
13
+ * seats inject the SAME card and controller: whichever way the user arrives,
14
+ * the form is on the first page they land on, and one staging area follows
15
+ * them between the two. The mounts ride `configForms.whileServed`, so a
16
+ * deployment that never composed the host entry shows no trace of the card.
7
17
  *
8
18
  * @module dsh-web-fetch-playwright/client
9
19
  */
10
20
 
11
21
  import type { Context } from 'cordis'
12
- // Type-only: pulls the ctx.locale / ctx.slots / ctx.settingsScope Context
13
- // merges, and the 'settings.plugin.item' SlotMap declaration from the
14
- // ui-settings-plugins package that owns the slot contract.
22
+ // Type-only: pulls the ctx.configForms Context merge (the shared forms
23
+ // service) from the owning client package, the ctx.slots merge from the
24
+ // renderer, and the 'plugins.bundle.config' / 'plugins.row.config' SlotMap
25
+ // declarations from the Plugins page (type-only imports are erased before
26
+ // the purity gate).
15
27
  import type {} from '@deepseek-ai/dsh-client-locale/client'
16
28
  import type {} from '@deepseek-ai/dsh-client-ui-slots'
29
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
17
30
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
18
- import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client'
31
+ import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
19
32
  import { PlaywrightCardController, WEB_FETCH_PLAYWRIGHT_NS } from './controller.ts'
20
33
  import { PlaywrightCard } from './card.tsx'
21
34
  import { en, zh } from './locales.ts'
@@ -23,23 +36,56 @@ import { en, zh } from './locales.ts'
23
36
  /** Dictionary namespace owned by this plugin. */
24
37
  const NS = 'web-fetch-playwright'
25
38
 
39
+ /**
40
+ * This bundle's package name — the Plugins page keys a bundle's own
41
+ * configuration by it. Spelled here rather than read from any manifest:
42
+ * this bundle must stay self-contained.
43
+ */
44
+ const PACKAGE_NAME = 'dsh-web-fetch-playwright'
45
+
46
+ /**
47
+ * The row's configuration key `<package name>#<row id>` with the row id as
48
+ * the bundle's patch declares it.
49
+ */
50
+ const ROW_CONFIG_KEY = `${PACKAGE_NAME}#web-fetch-playwright`
51
+
26
52
  /** Required services (cordis fiber inject). */
27
- export const inject = ['slots', 'locale', 'settingsScope']
53
+ export const inject = ['slots', 'locale', 'configForms']
28
54
 
29
55
  /**
30
- * Mount the Playwright plugin-configuration card.
56
+ * Mount the Playwright plugin-configuration card while the Host serves the
57
+ * `web-fetch-playwright` namespace.
31
58
  * @param ctx - the browser plugin context.
32
59
  */
33
60
  export function apply(ctx: Context): void {
34
61
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'web-fetch-playwright: card dictionary')
35
62
 
36
63
  const controller = new PlaywrightCardController(
37
- ctx.settingsScope.bind({ namespace: WEB_FETCH_PLAYWRIGHT_NS }),
64
+ ctx.configForms.get(WEB_FETCH_PLAYWRIGHT_NS),
65
+ )
66
+ ctx.effect(() => () => { controller.dispose() }, 'web-fetch-playwright: form subscription')
67
+
68
+ // The card's two seats on the Plugins page, one shared controller behind
69
+ // both: the bundle's own page shows the form between its description and
70
+ // its rows, and the row keeps its configure control opening the same form
71
+ // under the plugin's own title. `whileServed` owns both mounts, so a host
72
+ // without the entry never renders an empty section.
73
+ ctx.effect(
74
+ () => ctx.configForms.whileServed([WEB_FETCH_PLAYWRIGHT_NS], () => {
75
+ const offBundle = ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
76
+ name: 'plugins.bundle.config',
77
+ key: PACKAGE_NAME,
78
+ locale: NS,
79
+ inject: () => controller.inject(),
80
+ }, PlaywrightCard))
81
+ const offRow = ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
82
+ name: 'plugins.row.config',
83
+ key: ROW_CONFIG_KEY,
84
+ locale: NS,
85
+ inject: () => controller.inject(),
86
+ }, PlaywrightCard))
87
+ return () => { offBundle(); offRow() }
88
+ }),
89
+ 'web-fetch-playwright: plugins-page card',
38
90
  )
39
- ctx.slots.inject('settings.plugin.item', () => ctx.slots.register({
40
- name: 'settings.plugin.item',
41
- key: WEB_FETCH_PLAYWRIGHT_NS,
42
- locale: NS,
43
- inject: () => controller.inject(),
44
- }, PlaywrightCard))
45
91
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  /** Locale keys this card renders. */
9
9
  export type PlaywrightCardLocaleKey =
10
- | 'title' | 'description'
10
+ | 'description'
11
11
  | 'backendLabel' | 'backendLocal' | 'backendLocalHint' | 'backendCdp' | 'backendCdpHint'
12
12
  | 'playwrightPath' | 'playwrightPathHint' | 'playwrightPathPlaceholder'
13
13
  | 'cdpEndpoint' | 'cdpEndpointHint'
@@ -15,8 +15,8 @@ export type PlaywrightCardLocaleKey =
15
15
  | 'denoise' | 'denoiseHint'
16
16
  | 'maxConcurrency' | 'maxConcurrencyHint' | 'maxConcurrencyPlaceholder'
17
17
  | 'challengeWaitMs' | 'challengeWaitMsHint' | 'challengeWaitMsPlaceholder'
18
- | 'overridden' | 'reset' | 'readOnly' | 'expand' | 'collapse'
19
- | 'save' | 'saving' | 'discard' | 'unsaved' | 'saveFailed' | 'invalidText'
18
+ | 'overridden' | 'reset' | 'readOnly'
19
+ | 'save' | 'saving' | 'discard' | 'saveFailed' | 'invalidText'
20
20
 
21
21
  /** This plugin's dictionary namespace, merged into the locale key map. */
22
22
  declare module '@deepseek-ai/dsh-client-ui-slots' {
@@ -27,7 +27,6 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
27
27
 
28
28
  /** English copy. */
29
29
  export const en: Record<PlaywrightCardLocaleKey, string> = {
30
- title: 'Playwright web fetch',
31
30
  description: 'Fetches pages with a real browser (local Playwright or CDP) and returns denoised markdown.',
32
31
  backendLabel: 'Playwright backend',
33
32
  backendLocal: 'Local Playwright',
@@ -52,19 +51,15 @@ export const en: Record<PlaywrightCardLocaleKey, string> = {
52
51
  overridden: 'Overridden',
53
52
  reset: 'Reset to default',
54
53
  readOnly: 'This deployment stores settings read-only.',
55
- expand: 'Show settings',
56
- collapse: 'Hide settings',
57
54
  save: 'Save',
58
55
  saving: 'Saving…',
59
56
  discard: 'Discard',
60
- unsaved: 'Unsaved',
61
57
  saveFailed: 'The deployment did not accept these values; they were left for you to correct.',
62
58
  invalidText: 'This value is not accepted here.',
63
59
  }
64
60
 
65
61
  /** Simplified Chinese copy. */
66
62
  export const zh: Record<PlaywrightCardLocaleKey, string> = {
67
- title: 'Playwright 网页爬取',
68
63
  description: '用真实浏览器(本地 Playwright 或 CDP)抓取网页,降噪后转为 Markdown。',
69
64
  backendLabel: 'Playwright 后端',
70
65
  backendLocal: '本地 Playwright',
@@ -89,12 +84,9 @@ export const zh: Record<PlaywrightCardLocaleKey, string> = {
89
84
  overridden: '已覆盖',
90
85
  reset: '恢复默认',
91
86
  readOnly: '本部署的设置为只读。',
92
- expand: '展开设置',
93
- collapse: '收起设置',
94
87
  save: '保存',
95
88
  saving: '保存中…',
96
89
  discard: '放弃修改',
97
- unsaved: '未保存',
98
90
  saveFailed: '本部署没有接受这些值,已保留供你修改。',
99
91
  invalidText: '该值不被此设置项接受。',
100
92
  }
package/src/config.ts CHANGED
@@ -4,9 +4,16 @@
4
4
  * resolved shape, and the small pure normalizers the provider applies per
5
5
  * fetch (CDP endpoint shaping) — kept network-free for unit tests.
6
6
  *
7
+ * Since dsh 0.1.7 the settings service derives a plugin's configuration page
8
+ * from its composition entry's `Config` schema: every field marked
9
+ * `.volatile()` is editable live (Settings → Plugins), and a committed edit
10
+ * is pushed into the running plugin's volatile references without a remount —
11
+ * this schema IS the `web-fetch-playwright` settings section.
12
+ *
7
13
  * @module dsh-web-fetch-playwright/config
8
14
  */
9
15
 
16
+ import type { Volatile } from '@deepseek-ai/cordis'
10
17
  import z from '@deepseek-ai/schemastery'
11
18
 
12
19
  /** Default CDP endpoint when the settings section leaves it blank. */
@@ -99,23 +106,98 @@ export interface Config {
99
106
  maxConcurrency?: number
100
107
  }
101
108
 
102
- export const Config: z<Config> = z.object({
103
- // union-of-consts rather than z.enum: the profile's published schemastery
104
- // build does not expose `.enum`, and this schema executes at runtime
105
- // against that copy.
106
- backend: z.union([z.const('local'), z.const('cdp')]).default('local'),
107
- playwrightPath: z.string().default(''),
108
- cdpEndpoint: z.string().default(''),
109
- shareBrowserContext: z.boolean().default(true),
110
- denoise: z.boolean().default(true),
109
+ // union-of-consts rather than z.enum: the profile's published schemastery
110
+ // build does not expose `.enum`, and this schema executes at runtime
111
+ // against that copy. Every field is `.volatile()`: the whole section is
112
+ // live-editable from the Plugins page and a commit reaches the running
113
+ // provider without a remount.
114
+ export const Config = z.object({
115
+ backend: z.union([z.const('local'), z.const('cdp')]).default('local').volatile(),
116
+ playwrightPath: z.string().default('').volatile(),
117
+ cdpEndpoint: z.string().default('').volatile(),
118
+ shareBrowserContext: z.boolean().default(true).volatile(),
119
+ denoise: z.boolean().default(true).volatile(),
111
120
  // Optional on purpose: the effective default depends on `backend`, which a
112
121
  // static schema default cannot express.
113
- maxConcurrency: z.number().step(1).min(1).max(MAX_CONCURRENCY_CEILING),
122
+ maxConcurrency: z.number().step(1).min(1).max(MAX_CONCURRENCY_CEILING).volatile(),
114
123
  // The bounded natural-wait knobs; 0 disables the whole challenge path.
115
- challengeWaitMs: z.number().step(100).min(0).max(MAX_CHALLENGE_WAIT_MS).default(DEFAULT_CHALLENGE_WAIT_MS),
116
- challengeRetries: z.number().step(1).min(0).max(MAX_CHALLENGE_RETRIES).default(DEFAULT_CHALLENGE_RETRIES),
124
+ challengeWaitMs: z.number().step(100).min(0).max(MAX_CHALLENGE_WAIT_MS).default(DEFAULT_CHALLENGE_WAIT_MS).volatile(),
125
+ challengeRetries: z.number().step(1).min(0).max(MAX_CHALLENGE_RETRIES).default(DEFAULT_CHALLENGE_RETRIES).volatile(),
117
126
  })
118
127
 
128
+ /**
129
+ * The config `apply` receives once the schema resolves: every volatile field
130
+ * arrives as a live reference whose snapshot a settings commit replaces in
131
+ * place, so the provider re-reads them per fetch (the plugin never remounts
132
+ * for an edit).
133
+ */
134
+ export interface PlaywrightPluginConfig {
135
+ /** Backend selector as a live reference. */
136
+ backend: Volatile<PlaywrightBackend>
137
+ /** Local backend executable path as a live reference. */
138
+ playwrightPath: Volatile<string>
139
+ /** CDP endpoint as a live reference. */
140
+ cdpEndpoint: Volatile<string>
141
+ /** Shared-context toggle as a live reference. */
142
+ shareBrowserContext: Volatile<boolean>
143
+ /** Denoise toggle as a live reference. */
144
+ denoise: Volatile<boolean>
145
+ /**
146
+ * Concurrency limit as a live reference; `undefined` while unset (the
147
+ * field owns no default — the backend resolves one).
148
+ */
149
+ maxConcurrency: Volatile<number | undefined>
150
+ /** Challenge wait budget (ms) as a live reference. */
151
+ challengeWaitMs: Volatile<number>
152
+ /** Challenge retry count as a live reference. */
153
+ challengeRetries: Volatile<number>
154
+ }
155
+
156
+ /**
157
+ * Read the live references `apply` holds into one plain input for
158
+ * {@link resolveConfig}; a settings commit has usually replaced the
159
+ * snapshots since the last call, which is the whole point.
160
+ *
161
+ * @param config - the plugin config as the loader resolved it.
162
+ * @returns the current snapshots, ready for resolution.
163
+ */
164
+ export function snapshotsOf(config: PlaywrightPluginConfig): Config {
165
+ return {
166
+ backend: config.backend.get(),
167
+ playwrightPath: config.playwrightPath.get(),
168
+ cdpEndpoint: config.cdpEndpoint.get(),
169
+ shareBrowserContext: config.shareBrowserContext.get(),
170
+ denoise: config.denoise.get(),
171
+ maxConcurrency: config.maxConcurrency.get(),
172
+ challengeWaitMs: config.challengeWaitMs.get(),
173
+ challengeRetries: config.challengeRetries.get(),
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Resolve any accepted config input into the fully-defaulted, plain form the
179
+ * provider consumes per fetch. Validation goes through the schema, so the
180
+ * volatile wrappers that produces are unwrapped immediately — the provider
181
+ * consumes plain values. The input face is `Partial` by design (composition
182
+ * entries and volatile snapshots both omit fields; defaults supply them).
183
+ *
184
+ * @param config - composition entry, settings-section value, or volatile snapshots.
185
+ * @returns the resolved config.
186
+ */
187
+ export function resolveConfig(config: Partial<Config>): ResolvedConfig {
188
+ const resolved = Config(config as never) as PlaywrightPluginConfig
189
+ return {
190
+ backend: resolved.backend.get(),
191
+ playwrightPath: resolved.playwrightPath.get(),
192
+ cdpEndpoint: resolved.cdpEndpoint.get(),
193
+ shareBrowserContext: resolved.shareBrowserContext.get(),
194
+ denoise: resolved.denoise.get(),
195
+ maxConcurrency: resolved.maxConcurrency.get(),
196
+ challengeWaitMs: resolved.challengeWaitMs.get(),
197
+ challengeRetries: resolved.challengeRetries.get(),
198
+ }
199
+ }
200
+
119
201
  /**
120
202
  * Complete config after schemastery applies the field defaults it owns.
121
203
  * `maxConcurrency` stays optional — {@link effectiveMaxConcurrency} resolves
package/src/index.ts CHANGED
@@ -1,24 +1,44 @@
1
1
  /**
2
2
  * `dsh-web-fetch-playwright`: registers the Playwright/CDP
3
- * {@link PlaywrightFetchProvider} with `ctx.web` and exposes its settings
4
- * section ('web-fetch-playwright') so the web client's plugin-configuration
5
- * card can edit it live.
3
+ * {@link PlaywrightFetchProvider} with `ctx.web`.
4
+ *
5
+ * The `web-fetch-playwright` settings section is derived from this plugin's
6
+ * `Config` schema (dsh ≥ 0.1.7): its volatile fields are editable live on
7
+ * the Plugins page, and a committed change is pushed into the running
8
+ * config's volatile references — the provider re-reads them per fetch, so an
9
+ * edit reaches the next request without a restart or re-registration.
6
10
  *
7
11
  * A function plugin (NOT a default-export service): like the shipped search
8
- * providers, it registers INTO the seam's fetch registry.
12
+ * providers, it registers INTO the web seam's fetch registry.
9
13
  *
10
14
  * @module dsh-web-fetch-playwright
11
15
  */
12
16
 
13
17
  import type { Context } from '@deepseek-ai/cordis'
14
- import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings'
15
18
  import type {} from '@deepseek-ai/dsh-web'
16
- import { Config } from './config.ts'
17
- import type { ResolvedConfig } from './config.ts'
19
+ import { resolveConfig, snapshotsOf } from './config.ts'
20
+ import type { PlaywrightPluginConfig } from './config.ts'
18
21
  import { PlaywrightFetchProvider } from './provider.ts'
19
22
 
20
- export { Config, DEFAULT_CDP_ENDPOINT, DEFAULT_CHALLENGE_RETRIES, DEFAULT_CHALLENGE_WAIT_MS, effectiveChallengeRetries, effectiveChallengeWaitMs, effectiveContextMode, normalizeCdpEndpoint } from './config.ts'
21
- export type { Config as PlaywrightFetchConfig, CdpContextMode, PlaywrightBackend, ResolvedConfig } from './config.ts'
23
+ export {
24
+ Config,
25
+ DEFAULT_CDP_ENDPOINT,
26
+ DEFAULT_CHALLENGE_RETRIES,
27
+ DEFAULT_CHALLENGE_WAIT_MS,
28
+ effectiveChallengeRetries,
29
+ effectiveChallengeWaitMs,
30
+ effectiveContextMode,
31
+ normalizeCdpEndpoint,
32
+ resolveConfig,
33
+ snapshotsOf,
34
+ } from './config.ts'
35
+ export type {
36
+ Config as PlaywrightFetchConfig,
37
+ CdpContextMode,
38
+ PlaywrightBackend,
39
+ PlaywrightPluginConfig,
40
+ ResolvedConfig,
41
+ } from './config.ts'
22
42
  export { CdpConnectionPool } from './cdp-pool.ts'
23
43
  export type { CdpAcquireMode, CdpConnect, CdpLease } from './cdp-pool.ts'
24
44
  export { CHALLENGE_DOM_PROBE, CHALLENGE_FINISH_RESERVE_MS, CHALLENGE_POLL_INTERVAL_MS, CHALLENGE_TITLE_RE, classifyChallengeHtml, classifyChallengeResponse, isChallengeCompatibleResponse } from './challenge.ts'
@@ -30,31 +50,34 @@ export type { DenoiseMode, DenoiseResult } from './markdown.ts'
30
50
  /** Cordis plugin name used by loader diagnostics. */
31
51
  export const name = 'dsh-web-fetch-playwright'
32
52
 
33
- /** The web seam this provider registers into. */
53
+ /**
54
+ * The capability seam this plugin registers into. The settings section
55
+ * needs no inject: the host's settings service derives it from the entry's
56
+ * `Config` schema (its volatile fields) by entry id.
57
+ */
34
58
  export const inject = ['web']
35
59
 
36
- /** Settings namespace carrying this provider's configuration card. */
37
- export const WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE = settingsNamespace('web-fetch-playwright')
60
+ /**
61
+ * Settings namespace carrying this provider's configuration page: the
62
+ * composition entry id, which is what the settings service keys the
63
+ * derived section by.
64
+ */
65
+ export const WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE = 'web-fetch-playwright'
38
66
 
39
- /** Register the Playwright fetch provider with `ctx.web`. */
40
- export function apply(ctx: Context, config: Config): void {
41
- // `current` is REASSIGNED by setSource when the settings scope attaches
42
- // (possibly after this function returns), so the provider must receive an
43
- // indirection — `() => current()` — never the thunk's value at this moment.
44
- // Passing `current` directly would pin the composition entry forever (the
45
- // web-search-deepseek provider uses the same wrapper idiom).
46
- let current: () => ResolvedConfig = () => config as ResolvedConfig
47
- installSettingsSection(ctx, WEB_FETCH_PLAYWRIGHT_SETTINGS_NAMESPACE, Config, config, {
48
- setSource: (source) => {
49
- current = source as () => ResolvedConfig
50
- },
51
- // The provider projects the section per fetch, so a committed change
52
- // needs no re-registration.
53
- onChange: () => {},
54
- })
67
+ /**
68
+ * Register the Playwright fetch provider with `ctx.web`.
69
+ *
70
+ * @param ctx - plugin context supplying the web seam.
71
+ * @param config - the loader-resolved plugin config; its volatile fields are
72
+ * live references a settings commit updates in place.
73
+ */
74
+ export function apply(ctx: Context, config: PlaywrightPluginConfig): void {
75
+ // Re-read AND re-resolve per fetch: `snapshotsOf` dereferences the volatile
76
+ // references each time, so a section committed from the settings page
77
+ // between two fetches serves the second one.
78
+ const provider = new PlaywrightFetchProvider(() => resolveConfig(snapshotsOf(config)))
55
79
  // The CDP backend holds one shared connection for the provider's lifetime;
56
80
  // drop it when this plugin unloads so restarts don't strand sockets.
57
- const provider = new PlaywrightFetchProvider(() => current())
58
81
  ctx.effect(() => () => { void provider.dispose() }, 'dsh-web-fetch-playwright: shared CDP connection')
59
82
  ctx.web.registerFetchProvider(provider)
60
83
  }
package/dsh.plugin.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "name": "dsh-web-fetch-playwright",
3
- "version": "0.2.6",
4
- "description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
5
- "entry": {
6
- "name": "dsh-web-fetch-playwright",
7
- "inject": []
8
- },
9
- "client": {
10
- "platform": "web"
11
- },
12
- "contributes": {
13
- "tools": [],
14
- "skills": []
15
- }
16
- }