dsh-web-fetch-enhanced 0.0.1 → 0.0.3

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.en.md CHANGED
@@ -53,7 +53,7 @@ dsh plugin --profile web add link:/absolute/path/to/dsh-web-fetch-enhanced
53
53
 
54
54
  Open DSH Web and go to:
55
55
 
56
- **Settings → Plugins → Configurable plugins → Enhanced web fetch allowlist**
56
+ **Settings → Plugins → Configurable plugins → Web Fetch Enhanced**
57
57
 
58
58
  Expand the card and enter one network per line under **Allowed CIDRs**. For a typical Clash / Mihomo fake-IP setup:
59
59
 
@@ -178,7 +178,7 @@ Most users only need the two allowlists exposed in DSH Web. Manage other values
178
178
  | `maxRedirects` | `5` | Maximum same-origin redirect hops; `0` disables following |
179
179
  | `userAgent` | `dsh-web-fetch-enhanced/0.1.0` | User-Agent sent with each request |
180
180
 
181
- The default bundle uses the separate `http-enhanced` provider ID and leaves the native `http` provider installed. For manual composition or drop-in replacement, see:
181
+ The default bundle uses the separate `http-enhanced` provider ID and explicitly disables the native `web-fetch-http` provider to avoid `WEB_PROVIDER_AMBIGUOUS` when subsequent Web plugins (such as search plugins) overwrite `id: web` configuration and unpin `fetchProvider`. For manual composition or drop-in replacement, see:
182
182
 
183
183
  - [coexisting provider example](examples/coexist.cordis.yml)
184
184
  - [drop-in replacement example](examples/drop-in.cordis.yml)
package/README.md CHANGED
@@ -53,7 +53,7 @@ dsh plugin --profile web add link:/absolute/path/to/dsh-web-fetch-enhanced
53
53
 
54
54
  打开 DSH Web,进入:
55
55
 
56
- **设置 → 插件 → 可配置插件 → WebFetch白名单**
56
+ **设置 → 插件 → 可配置插件 → Web Fetch Enhanced**
57
57
 
58
58
  展开卡片,在“允许的 CIDR”中每行填写一个网段。例如 Clash / Mihomo 的常见 Fake-IP 配置:
59
59
 
@@ -178,7 +178,7 @@ wiki.corp.example
178
178
  | `maxRedirects` | `5` | 同源重定向最大跳数;`0` 表示不跟随 |
179
179
  | `userAgent` | `dsh-web-fetch-enhanced/0.1.0` | 每个请求使用的 User-Agent |
180
180
 
181
- 默认安装采用独立的 `http-enhanced` provider ID,并保留原生 `http` provider。需要手动组合或 drop-in 替换时,参考:
181
+ 默认安装(通过 bundle `cordis.patch.yml`)采用独立的 `http-enhanced` provider ID,并显式禁用原生的 `web-fetch-http`,以避免后续其他 Web 插件(如 search 插件)覆盖 `id: web` 的 config 时因 `fetchProvider` 变成未指定而触发 `WEB_PROVIDER_AMBIGUOUS`。需要自定义组合或 drop-in 替换时,参考:
182
182
 
183
183
  - [独立 provider 示例](examples/coexist.cordis.yml)
184
184
  - [drop-in 替换示例](examples/drop-in.cordis.yml)
package/cordis.patch.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  # Optional Profile Bundle: select the enhanced HTTP fetch provider on the Host plane.
2
- # This layer is applied after @deepseek-ai/dsh-base. A patch replaces a row's
3
- # entire config, so both WebRuntime selector fields are restated here.
2
+ # Disable the native HTTP fetch provider to avoid WEB_PROVIDER_AMBIGUOUS when fetchProvider is unpinned by later bundles.
3
+ - id: web-fetch-http
4
+ disabled: true
5
+
4
6
  - id: web
5
7
  config:
6
- searchProvider: deepseek-official
7
8
  fetchProvider: http-enhanced
8
9
 
9
10
  - insert:
@@ -47,13 +47,13 @@ flowchart LR
47
47
  <code>ctx.web</code> 的选择是 ID 驱动而不是注册顺序驱动:
48
48
 
49
49
  - 配置 <code>fetchProvider: http-enhanced</code> 时只选择本插件默认 ID;
50
- - 保留原生 <code>http</code> provider 不会产生歧义,因为选择已显式固定;
50
+ - 默认 bundle 会在 Profile 中显式禁用原生的 <code>web-fetch-http</code>,从而在多 Web 插件(如 search 插件)覆盖 <code>id: web</code> config 导致 <code>fetchProvider</code> 未固定时,系统只存在唯一的可用 fetch provider,避免 <code>WEB_PROVIDER_AMBIGUOUS</code>;
51
51
  - 未配置 ID 且存在多个可用 provider 时会报 <code>WEB_PROVIDER_AMBIGUOUS</code>;
52
52
  - 两个 provider 注册相同 ID 会立即报 <code>WEB_DUPLICATE_PROVIDER</code>。
53
53
 
54
54
  所以“覆盖原生”有两种明确模式:
55
55
 
56
- 1. 推荐模式:本插件使用 <code>http-enhanced</code>,修改现有 web 行的 <code>fetchProvider</code>;
56
+ 1. 推荐模式:本插件使用 <code>http-enhanced</code>,修改现有 web 行的 <code>fetchProvider</code> 并禁用原生 <code>web-fetch-http</code>(由随包附带的 <code>cordis.patch.yml</code> 自动处理);
57
57
  2. drop-in 模式:禁用原生 provider,本插件配置 <code>providerId: http</code>。
58
58
 
59
59
  不存在 last-wins 或自动 fallback。
@@ -1,8 +1,6 @@
1
1
  # Profile user patch after installing the bundle, retaining fetchProvider: http.
2
- # A patch replaces a row's whole config, so both WebRuntime fields are restated.
3
2
  - id: web
4
3
  config:
5
- searchProvider: deepseek-official
6
4
  fetchProvider: http
7
5
 
8
6
  # The native provider MUST be disabled to avoid duplicate provider id "http".
@@ -1,8 +1,10 @@
1
1
  # Manual Host overlay when the package is resolvable but its dsh.bundle layer
2
2
  # is not active. Bundle users should use coexist.cordis.yml instead.
3
+ - id: web-fetch-http
4
+ disabled: true
5
+
3
6
  - id: web
4
7
  config:
5
- searchProvider: deepseek-official
6
8
  fetchProvider: http-enhanced
7
9
 
8
10
  - insert:
package/lib/client.js CHANGED
@@ -256,7 +256,7 @@ window.__ModuleLoader__.load({
256
256
  //#endregion
257
257
  //#region lib/types/client/locales.js
258
258
  const en = {
259
- title: "Enhanced web fetch allowlist",
259
+ title: "Web Fetch Enhanced",
260
260
  description: "Allow selected non-public destinations for web_fetch. Public addresses remain available by default.",
261
261
  expand: "Expand",
262
262
  collapse: "Collapse",
@@ -279,7 +279,7 @@ window.__ModuleLoader__.load({
279
279
  blank: "Blank entries are ignored."
280
280
  };
281
281
  const zh = {
282
- title: "WebFetch白名单",
282
+ title: "Web Fetch Enhanced",
283
283
  description: "允许 web_fetch 访问指定的非公网目标;公网地址默认仍可正常访问。",
284
284
  expand: "展开",
285
285
  collapse: "折叠",
package/lib/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
3
2
  import { isIP } from "node:net";
4
3
  import ipaddr from "ipaddr.js";
5
4
  import { WebError } from "@deepseek-ai/dsh-web";
@@ -552,12 +551,14 @@ function translateAbortOrNetwork(error, signal) {
552
551
  * @module dsh-web-fetch-enhanced
553
552
  */
554
553
  const MAX_NODE_TIMER_DELAY_MS = 2147483647;
554
+ const FIBER_DISPOSED = 4;
555
+ const FIBER_UNLOADING = 5;
555
556
  /** Explicit product User-Agent used by default. */
556
557
  const DEFAULT_USER_AGENT = "dsh-web-fetch-enhanced/0.1.0";
557
558
  /** Default provider id; select it in the dsh-web row with fetchProvider. */
558
559
  const DEFAULT_PROVIDER_ID = "http-enhanced";
559
560
  /** Settings namespace paired with the Web Profile configuration card. */
560
- const SETTINGS_NAMESPACE = settingsNamespace("web-fetch-enhanced");
561
+ const SETTINGS_NAMESPACE = "web-fetch-enhanced";
561
562
  /** Cordis plugin name used by loader diagnostics. */
562
563
  const name = "web-fetch-enhanced";
563
564
  /** The web seam this provider contributes to. */
@@ -593,19 +594,41 @@ function createProvider(config = {}) {
593
594
  };
594
595
  return new EnhancedHttpFetchProvider(resolved.providerId, limits, createAllowlistResolver(policy));
595
596
  }
597
+ function isUnloading(ctx) {
598
+ const state = ctx.fiber?.state;
599
+ return state === FIBER_UNLOADING || state === FIBER_DISPOSED;
600
+ }
596
601
  /** Register the enhanced fetch provider and its live Web Profile settings section. */
597
602
  function apply(ctx, config) {
598
603
  const providerId = resolveConfig(config).providerId;
599
604
  let current = () => config;
600
- installSettingsSection(ctx, SETTINGS_NAMESPACE, Config, config, {
601
- setSource: (source) => {
602
- current = source;
603
- },
604
- onChange: () => {},
605
- validate: (value) => {
606
- if (resolveConfig(value).providerId !== providerId) throw new Error("web-fetch-enhanced: providerId cannot be changed through live settings");
607
- createProvider(value);
605
+ ctx.inject(["settings"], (settingsCtx) => {
606
+ const settings = settingsCtx.settings;
607
+ if (typeof settings.installSection === "function") {
608
+ settings.installSection(ctx, SETTINGS_NAMESPACE, Config, config, {
609
+ setSource: (source) => {
610
+ current = source;
611
+ },
612
+ onChange: () => {},
613
+ validate: (value) => {
614
+ if (resolveConfig(value).providerId !== providerId) throw new Error("web-fetch-enhanced: providerId cannot be changed through live settings");
615
+ createProvider(value);
616
+ }
617
+ });
618
+ return;
608
619
  }
620
+ const scope = settings.register(SETTINGS_NAMESPACE, Config, {
621
+ base: config,
622
+ validate: (value) => {
623
+ if (resolveConfig(value).providerId !== providerId) throw new Error("web-fetch-enhanced: providerId cannot be changed through live settings");
624
+ createProvider(value);
625
+ }
626
+ });
627
+ current = () => scope.get();
628
+ settingsCtx.effect(() => () => {
629
+ if (isUnloading(ctx)) return;
630
+ current = () => config;
631
+ });
609
632
  });
610
633
  const dynamicProvider = {
611
634
  id: providerId,
@@ -1,5 +1,5 @@
1
1
  export declare const en: {
2
- readonly title: "Enhanced web fetch allowlist";
2
+ readonly title: "Web Fetch Enhanced";
3
3
  readonly description: "Allow selected non-public destinations for web_fetch. Public addresses remain available by default.";
4
4
  readonly expand: "Expand";
5
5
  readonly collapse: "Collapse";
@@ -6,13 +6,14 @@
6
6
  */
7
7
  import type { Context } from '@deepseek-ai/cordis';
8
8
  import z from '@deepseek-ai/schemastery';
9
+ import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
9
10
  import { EnhancedHttpFetchProvider } from './provider.ts';
10
11
  /** Explicit product User-Agent used by default. */
11
12
  export declare const DEFAULT_USER_AGENT = "dsh-web-fetch-enhanced/0.1.0";
12
13
  /** Default provider id; select it in the dsh-web row with fetchProvider. */
13
14
  export declare const DEFAULT_PROVIDER_ID = "http-enhanced";
14
15
  /** Settings namespace paired with the Web Profile configuration card. */
15
- export declare const SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
16
+ export declare const SETTINGS_NAMESPACE: SettingsNamespace;
16
17
  /** Cordis plugin name used by loader diagnostics. */
17
18
  export declare const name = "web-fetch-enhanced";
18
19
  /** The web seam this provider contributes to. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-web-fetch-enhanced",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Configurable non-public address allowlists for DeepSeek Harness web_fetch",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -68,19 +68,19 @@
68
68
  "node": "^22.19.0 || >=24.0.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "@deepseek-ai/cordis": "^4.0.1",
72
- "@deepseek-ai/dsh-timeout": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
73
- "@deepseek-ai/dsh-settings": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
74
- "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
75
- "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
76
- "@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
77
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
78
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
79
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2 || ^0.1.2-alpha.1",
80
- "@deepseek-ai/dsh-web": "^0.1.1-rc.2 || ^0.1.2-alpha.1"
71
+ "@deepseek-ai/cordis": "^4.0.1 || ^4.0.2",
72
+ "@deepseek-ai/dsh-timeout": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
73
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
74
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
75
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
76
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
77
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
78
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
79
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2",
80
+ "@deepseek-ai/dsh-web": "^0.1.1-rc.2 || ^0.1.2-alpha.1 || ^0.1.2-alpha.2"
81
81
  },
82
82
  "dependencies": {
83
- "@deepseek-ai/schemastery": "^3.18.1",
83
+ "@deepseek-ai/schemastery": "^3.18.1 || ^3.18.2",
84
84
  "ipaddr.js": "^2.5.0",
85
85
  "undici": "^8.10.0"
86
86
  },